@schie/epc - v1.0.0
    Preparing search index...

    @schie/epc - v1.0.0

    @schie/epc

    npm version CI CodeQL Super-Linter TypeScript codecov code style: prettier Commitizen friendly

    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/epc follows Semantic Versioning. Breaking changes ship only in a major version and are documented in UPGRADING.md.

    • ๐Ÿงฉ EPC Generation - Create EPCs from GS1 components
    • ๐Ÿ” Parsing - Decode EPC hex into structured data
    • ๐Ÿ”„ GTIN/EAN/UPC Conversion - Encode existing barcodes into SGTIN-96, or recover a GTIN-14 from one
    • ๐Ÿ›ก๏ธ Type Safe - Full TypeScript support with comprehensive types
    • ๐Ÿ“ฆ Zero Dependencies - Lightweight and fast
    • ๐Ÿงช 100% Test Coverage - Enforced on every change
    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.

    • ES Modules: Full ESM support with tree shaking
    • CommonJS: CJS builds included for compatibility
    • TypeScript: Complete type definitions included
    • Node.js: Requires Node.js 20+
    • SGTIN-96 - encode/parse, plus conversion from GTIN-8, GTIN-12/UPC-A, and GTIN-13/EAN-13 codes (and back to a GTIN-14)
    • GID-96 - encode/parse for non-GS1 identifiers
    • GS1 check digits - compute, append, and validate

    Contributions are welcome! This project uses:

    • TypeScript for type safety
    • Jest for testing
    • ESLint + Prettier for code quality
    • Commitizen for conventional commits
    # 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