strid
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

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

Package Sidebar

Install

npm i strid

Weekly Downloads

5

Version

1.1.1

License

none

Unpacked Size

6.61 kB

Total Files

9

Last publish

Collaborators

  • fabiospampinato