upc-generator
    TypeScript icon, indicating that this package has built-in type declarations

    0.0.6 • Public • Published

    upc-generator

    A randomly generated UPC-12(UPC-A) code For Amazon

    中文| English

    Install

    npm install --save upc-generator

    Usage

    import UPC from 'upc-generator';
    let upc = new UPC({flagCode: '1'})
    const code = upc.create()
    // 132877019981

    For commonJS

    const UPC = require('upc-generator');

    API

    constructor(prop)

    prop?

    Type: object

    flagCode? Type: literals '0' | '1' | '6' | '7' | '8' | '9' | ''

    set First code of UPC bar code

    manufacturer? Type: string Default: ''

    Set gen upc number 2th to 6th, It represents the manufacturer code

    create(prop)

    gen upc-12 code

    const code = upc.create({flagCode: '1', manufacturer: '23456'})
    // 123456545694

    createMultiple(prop)

    gen multiple upc-12 code, return array

    code

    const arr = upc.createMultiple({size: 3, flagCode: '1', manufacturer: '23456'})

    prop?

    size? Type: number Default: 1

    isValid(code)

    Check ean code whether it is legal

    Type:: string

    code

    const valid = upc.isValid('123456545694')
    // true
    
    const valid = upc.isValid('123456545695')
    // false

    License

    MIT License

    Copyright (c) 2020 王珏

    Install

    npm i upc-generator

    DownloadsWeekly Downloads

    13

    Version

    0.0.6

    License

    MIT

    Unpacked Size

    32.1 kB

    Total Files

    10

    Last publish

    Collaborators

    • wangjue666