Merge pull request #421 from Chalarangelo/fix-lost-snippet

Recover the lost byteSize snippet
This commit is contained in:
Angelos Chalaris
2017-12-30 12:37:24 +02:00
committed by GitHub

14
snippets/byteSize.md Normal file
View File

@ -0,0 +1,14 @@
### byteSize
Returns the length of string.
Convert a given string to a [`Blob` Object](https://developer.mozilla.org/en-US/docs/Web/API/Blob) and find its `size`.
```js
const byteSize = str => new Blob([str]).size;
```
```js
byteSize("😀"); // 4
byteSize("Hello World"); // 11
```