Guest User

Untitled

a guest
May 27th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. /**
  2. * Converts an array-like object into an array.
  3. * Array.from doesn't work if an object doesn't have a "length" property.
  4. * e.g., Array.from({ 0: 1 }) doesn't work; Array.from({ 0: 1, length: 1 }) does.
  5. */
  6. function arrayFrom (obj: {}): Array<*> {
  7. return Object.keys(obj).reduce((set: Array, key: string) => {
  8. return [...set, obj[key]]
  9. }, [])
  10. }
Add Comment
Please, Sign In to add comment