JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 15
  • Score
    100M100P100Q54318F
  • License MIT

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

Package Exports

  • upc-generator

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (upc-generator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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