A randomly generated UPC-12(UPC-A) code For Amazon
npm install --save upc-generator
import UPC from 'upc-generator';
let upc = new UPC({flagCode: '1'})
const code = upc.create()
// 132877019981
For commonJS
const UPC = require('upc-generator');
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
gen upc-12 code
const code = upc.create({flagCode: '1', manufacturer: '23456'})
// 123456545694
gen multiple upc-12 code, return array
code
const arr = upc.createMultiple({size: 3, flagCode: '1', manufacturer: '23456'})
size?
Type: number
Default: 1
Check ean code whether it is legal
Type:: string
code
const valid = upc.isValid('123456545694')
// true
const valid = upc.isValid('123456545695')
// false
MIT License
Copyright (c) 2020 王珏