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.
- Host: GitHub
- URL: https://github.com/writetome51/to-str
- Owner: writetome51
- License: mit
- Created: 2020-09-02T03:33:55.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-09-02T03:42:37.000Z (over 5 years ago)
- Last Synced: 2025-08-09T00:35:47.493Z (5 months ago)
- Language: JavaScript
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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';
```