ticket-code
v0.1.0
Published
ticket-code is generate ticket codes library for Node.js
Downloads
36
Readme
ticket-code
ticket-code is generate ticket codes library for Node.js
Installation
$ npm install ticket-code
Usage
A simple checksum code is added to verify the generated code value. For this purpose, it is recommended to specify numerical seed value.
var ticketCode = require('ticket-code')
var codeLength = 15 // optional (default 10)
var checksumSeed = 5 // required
var checksumIdx = 7 // optional (default Math.floor(code length / 2))
var code = ticketCode.generate(checksumSeed, codeLength, checksumIdx) // NPP3YHPEQMCY75W
// ...
ticketCode.validate('NPP3YHPEQMCY75W', checksumSeed, checksumIdx) // true
ticketCode.validate('NPP3YHPEQMCY75A', checksumSeed, checksumIdx) // false
Test
Test with mocha
$ grunt
like watch
$ grunt watch
Contributing
Bug reports and pull requests are welcome on Github at https://github.com/egg-/ticket-code
- Fork it
- Create your feature branch.
- Commit your changes.
- Push to the branch.
- Create a new Pull Request.
License
ticket-code is licensed under the MIT license.