Neighborly Package Megalodon

    ticket-code

    0.1.0 • Public • Published

    ticket-code

    version download status status Standard - JavaScript Style Guide

    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

    1. Fork it
    2. Create your feature branch.
    3. Commit your changes.
    4. Push to the branch.
    5. Create a new Pull Request.

    License

    ticket-code is licensed under the MIT license.

    Install

    npm i ticket-code

    DownloadsWeekly Downloads

    1

    Version

    0.1.0

    License

    MIT

    Last publish

    Collaborators

    • egg-