Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Converts an array-like object into an array.
- * Array.from doesn't work if an object doesn't have a "length" property.
- * e.g., Array.from({ 0: 1 }) doesn't work; Array.from({ 0: 1, length: 1 }) does.
- */
- function arrayFrom (obj: {}): Array<*> {
- return Object.keys(obj).reduce((set: Array, key: string) => {
- return [...set, obj[key]]
- }, [])
- }
Add Comment
Please, Sign In to add comment