1.1.7 • Published 6 years ago

@wnprc/primate-id v1.1.7

Weekly downloads
205
License
Apache-2.0
Repository
-
Last release
6 years ago

npm version

PrimateID

This Typescript library provides a reference implementation for generating and validating random-yet-prefixed "universal" ids for animals housed at various primate research facilities around the country.

Specification

The current form is defined as follows:

primate-id    = prefix-part random-part check-digit

prefix-part   = 2UPALPHA
random-part   = 7(DIGIT | "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "J" | "K" | "M" 
                        | "N" | "P" | "Q" | "R" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z")
check-digit   = 1(DIGIT | UPALPHA)

The current implementation uses the Luhn mod N algorithm to generate the check digit with respect to the other nine characters of the PrimateID.

For Users

There are two implementations included in this library--a synchronous implementation and an asynchronous, Promise-based implementation. To use each one, import the corresponding class from the library as shown in the following example:

import * as PrimateID from '@wnprc/primate-id';

// using the asynchronous version (Generate returns a Promise<string>)
const async = new PrimateID.Async();
async.Generate('XX').then(x => console.log(x));

// using the synchronous version (Generate returns a string)
const sync = new PrimateID.Sync();
console.log(sync.Generate('XX'));

For Developers

To build, execute, and test the package, use the npm scripts defined in package.json:

# to install the dependencies
npm install

# to compile the TypeScript
npm run build

# to print an 'XX' id to the console
npm run generate

# to run the tests in the ./test folder
npm test
1.1.7

6 years ago

1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago