selection-key

0.0.1 • Public • Published

selection-key

NPM version Build status Downloads

Convert an array of integers into a short (ish), unique, URL-friendly key, and back again.

Useful if you need a key to represent a unique selection from a set of items – make an array containing only the integer IDs of the selected items, and then get a unique reversable string representing that set.

Usage

var selectionKey = require('selection-key');
 
var maxId = 100;
var selectedItems = [5, 6, 20, 24, 25, 47, 48, 51, 55, 60, 61, 77, 88, 90, 91, 92, 96];
 
var key = selectionKey(selectedItems, maxId); // 'O02C000P40.40BY00000'
 
var parsed = selectionKey.parse(key, maxId); // array of original items (sorted)

Licence

MIT

Package Sidebar

Install

npm i selection-key

Weekly Downloads

1

Version

0.0.1

License

MIT

Last publish

Collaborators

  • callumlocke