2.2.0 • Published 3 years ago

status-lookup v2.2.0

Weekly downloads
2
License
MIT
Repository
github
Last release
3 years ago

Status-lookup

Scenario: Compressing boolean status in disk storage / database

Status-lookup can convert your boolean status into bigint, and convert it back

example :

const StatusLookup = require("status-lookup");
let converter = new StatusLookup(["switch:on", "switch:off", "red", "green", "purple", "sweet", "sour", "bitter"]);

converter.compress("red", "sour"); // Integer { value: 68n }
converter.compress("red", "sour") == 68n; // true
converter.lookup(68n); // { red: true, sour: true }

api:

compress(...keys):

compress a list of status into a integer, skip when keys does not exist in the map;

lookup(bigint):

return a true status map

notice:

if you want to expand the dictionary, you need to initialize a new class and append new item to the end of the original lookup dictionary

2.0.0 :

dictionary size can now exceed 53

2.2.0

3 years ago

2.1.0

3 years ago

2.0.0

4 years ago

1.0.0

4 years ago