Last active
April 6, 2018 01:50
-
-
Save itacirgabral/3651d76dcf9b4e699e6e16bc8fd544a7 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 proto = Object.create(Array.prototype) | |
Object.defineProperty(proto, 'sew', { | |
value: function sew (a) { | |
(a || a === 0) && this.push(a) | |
return this | |
} | |
}) | |
function extendArray (a) { | |
const ae = Object.assign(Object.create(proto), a) | |
Object.defineProperty(ae, 'length', { | |
value: a.length, | |
writable: true | |
}) | |
return ae | |
} | |
export default extendArray | |
/** | |
* | |
*<script type="module"> | |
* import eArr from 'https://gist.githubusercontent.com/itacirgabral/3651d76dcf9b4e699e6e16bc8fd544a7/raw/1c988919ed312c56b690a3f1b53b4d96f1667ba3/extendArray.mjs' | |
* window.eArr = eArr | |
*</script> | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment