Skip to content

writetome51/to-str

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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';

About

Javascript function returns arg as string. Created purely for speed.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published