Update size.md

This commit is contained in:
Angelos Chalaris
2017-12-31 12:42:08 +02:00
committed by GitHub
parent 7f58d7d27f
commit 0d35a2e680

View File

@ -2,7 +2,12 @@
Get size of arrays, objects or strings.
Get type of value array, object and string. Use `length` property for arrays. Return `length` or `size` value if available or number of object keys. Split strings into array of characters with `split('')` and return its length.
Get type of `value` (`array`, `object` or `string`).
Use `length` property for arrays.
Use `length` or `size` value if available or number of keys for objects.
Use `size` of a [`Blob` object](https://developer.mozilla.org/en-US/docs/Web/API/Blob) created from `value` for strings.
Split strings into array of characters with `split('')` and return its length.
```js
const size = value =>
@ -11,7 +16,7 @@ const size = value =>
: value && typeof value === 'object'
? value.size || value.length || Object.keys(value).length
: typeof value === 'string'
? value.split('').length
? new Blob([value]).size
: 0;
```