Get a unique string identifier for any input value.
- 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.
npm install --save strid
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'
MIT © Fabio Spampinato