Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 📱 tsndef
# tsndef — Type-safe TypeScript NDEF (NFC) library

[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
Expand All @@ -7,6 +7,10 @@

A modern, type-safe TypeScript library for creating and parsing NDEF (NFC Data Exchange Format) messages with full compile-time type checking and intelligent autocompletion.

- ✅ Type-safe records (URI, JSON, text, media…)
- 🚀 Zero deps, tree-shakable ESM
- 🧪 Well-tested parsing/serialization with robust errors

## ✨ Features

- **🔒 Type-Safe**: Full TypeScript support with compile-time type checking
Expand Down Expand Up @@ -251,6 +255,29 @@ Maintaining precise type information allows you to:
- Leverage TypeScript's powerful type system for safer NFC operations
- Ensure your code is more maintainable and less prone to runtime errors

## ❓ FAQ

### Which record types are supported?

tsndef supports the most common NDEF record types:
- **Well-Known**: URI records with automatic prefix optimization
- **Media**: JSON, plain text, HTML, images (PNG/JPEG), video (MP4), audio (MPEG)

All record types include full TypeScript type definitions for compile-time safety.

### Is it safe to parse unknown records?

Yes! Use `safeParseNDEFMessage()` for error-safe parsing that won't throw exceptions. Unknown record types are preserved with their raw payload accessible via `rawPayload()`, so you never lose data.

### How is this different from other NDEF libraries?

tsndef is the only NDEF library that provides:
- **Full compile-time type safety** with TypeScript
- **Intelligent type inference** that tracks exact record types
- **Zero dependencies** and tree-shakable architecture
- **Modern ES modules** with immutable-style API
- **Comprehensive error handling** with both throwing and safe parsing options

## 🧪 Testing

```bash
Expand Down
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@
"nfc",
"ndef",
"typescript",
"javascript",
"encoder",
"decoder",
"parser",
"uri-record",
"json",
"type-safe",
"nfc-data-exchange-format",
"near-field-communication",
"mobile",
"android",
"ios",
"web-nfc"
"browser"
],
"exports": {
".": "./dist/index.js",
Expand Down