An open API service indexing awesome lists of open source software.

https://github.com/writetome51/to-str

Javascript function returns arg as string. Created purely for speed.
https://github.com/writetome51/to-str

Last synced: 5 months ago
JSON representation

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

Awesome Lists containing this project

README

          

# 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
```js
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
```js
import {toStr} from '@writetome51/to-str';
```