Skip to content

Get a unique string identifier for any input value.

License

Notifications You must be signed in to change notification settings

fabiospampinato/strid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Strid

Get a unique string identifier for any input value.

Details

  • All values that are the same according to Object.is will have the same string identifier.
  • All values that are different according to Object.is will have different string identifiers.
  • If your engine hasn't implemented this proposal then input symbols will be kept in memory indefinitely.
  • Records and Tuples are not supported yet, the function will throw for unknown types like that.

Install

npm install --save strid

Usage

import strid from 'strid';

strid ( null ); // => 'n';
strid ( undefined ); // => 'u';
strid ( true ); // => 't';
strid ( false ); // => 'f';
strid ( 0 ); // => '0';
strid ( -0 ); // => '-0';
strid ( 0n ); // => '0n';
strid ( 'foo' ); // => 'sfoo';
strid ( () => {} ); // => 'c1';
strid ( () => {} ); // => 'c2';
strid ( {} ); // => 'c3';
strid ( [] ); // => 'c4';
strid ( Symbol () ); // -> 'c5'

License

MIT © Fabio Spampinato