Skip to content

Instantly share code, notes, and snippets.

@itacirgabral
Last active April 6, 2018 01:50
Show Gist options
  • Save itacirgabral/3651d76dcf9b4e699e6e16bc8fd544a7 to your computer and use it in GitHub Desktop.
Save itacirgabral/3651d76dcf9b4e699e6e16bc8fd544a7 to your computer and use it in GitHub Desktop.
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