@writetome51/to-str
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

toStr(arg): string

Returns arg as string (I know, durr).
81% faster than String(arg).
62% faster than `${arg}`.
(Tested at https://jsbench.me/)

Examples

import {toStr} from '@writetome51/to-str';

toStr(1);
// --> '1'

toStr(0.001);
// --> '0.001'

toStr(-0.001);
// --> '-0.001'

toStr(-0);
// --> '0'

toStr(false);
// --> 'false'

toStr([]);
// --> ''

toStr([1, 2, 3, [4]]);
// --> '1,2,3,4'

toStr();
// --> 'undefined'

typeof toStr();
// --> 'string'

Installation

npm i @writetome51/to-str

Loading

import {toStr} from '@writetome51/to-str';

Package Sidebar

Install

npm i @writetome51/to-str

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

2.54 kB

Total Files

5

Last publish

Collaborators

  • writetome51