Skip to content

Latest commit

 

History

History
100 lines (66 loc) · 2.1 KB

README.md

File metadata and controls

100 lines (66 loc) · 2.1 KB

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 王珏