Last active
April 25, 2018 16:41
-
-
Save artalar/ea8512546a3675648615a25e846096a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const spreadAssignmentOperatorPolyfill = (assignable, extending) => { | |
if (assignable === null || assignable === undefined) { | |
throw new TypeError(`${assignable} is not iterable`); | |
} else if (typeof assignable === "object" && !Array.isArray(assignable)) { | |
return { ...assignable, ...extending }; | |
} | |
const assignableIterator = assignable[Symbol.iterator]; | |
if (!assignableIterator) { | |
throw new TypeError(`${assignable} is not iterable`); | |
} | |
return [...assignable, ...extending]; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment