A modern, type-safe TypeScript library for generating and parsing EPC (Electronic Product Code) identifiers used in UHF RFID tags.
๐ Stability
As of v1.0.0,@schie/epcfollows Semantic Versioning. Breaking changes ship only in a major version and are documented in UPGRADING.md.
npm install @schie/epc
import { encodeSgtin96, parseEpc } from '@schie/epc';
const epc = encodeSgtin96({
companyPrefix: '0614141',
itemReference: '812345',
serial: 6789,
filter: 3,
});
console.log(epc.hex);
console.log(epc.uri);
const parsed = parseEpc(epc.hex);
console.log(parsed.scheme); // sgtin-96
Convert an existing GTIN/EAN/UPC into an SGTIN-96 EPC, or reverse an SGTIN-96 EPC back into a GTIN-14:
import { encodeSgtin96FromGtin12, sgtin96ToGtin14 } from '@schie/epc';
// GTIN-12 (and its UPC-A barcode form) both work via encodeSgtin96FromGtin12 / encodeSgtin96FromUpcA
const fromGtin = encodeSgtin96FromGtin12({
gtin12: '036000291452',
companyPrefixLength: 6,
serial: 987,
});
sgtin96ToGtin14(fromGtin); // '00036000291452'
encodeSgtin96FromGtin13/encodeSgtin96FromEan13 and encodeSgtin96FromGtin8/encodeSgtin96FromEan8 work the same way for 13- and 8-digit codes.
Contributions are welcome! This project uses:
# Install dependencies
pnpm install
# Run tests
pnpm test
# Build
pnpm run build
# Lint
pnpm run lint
MIT License - see LICENSE file for details.
Made with โค๏ธ by @schie