Skip to content

Instantly share code, notes, and snippets.

@itacirgabral
Created April 6, 2018 01:21
Show Gist options
  • Save itacirgabral/ff4cb80def8f5bab33de8669e7131459 to your computer and use it in GitHub Desktop.
Save itacirgabral/ff4cb80def8f5bab33de8669e7131459 to your computer and use it in GitHub Desktop.
const cavaleiro = [1.5, 1.4, 1.3, 1.2, 1.1]
const casas = [
[cavaleiro[0]],
[cavaleiro[1]],
[cavaleiro[2]],
[cavaleiro[3]],
[cavaleiro[4]],
[cavaleiro[0]],
[cavaleiro[1]],
[cavaleiro[2]],
[cavaleiro[3]],
[cavaleiro[4]],
[cavaleiro[0]],
[cavaleiro[1]],
[
cavaleiro[2], cavaleiro[3], cavaleiro[4], cavaleiro[0], cavaleiro[1],
cavaleiro[2], cavaleiro[3], cavaleiro[4], cavaleiro[0], cavaleiro[1],
cavaleiro[2], cavaleiro[3], cavaleiro[4]
]
]
const extendArray = (() => {
const proto = Object.create(Array.prototype)
Object.defineProperty(proto, 'sew', {
value: function sew (a) {
(a || a === 0) && this.push(a)
return this
}
})
return function extendArray (a) {
const ae = Object.assign(Object.create(proto), a)
Object.defineProperty(ae, 'length', {
value: a.length,
writable: true
})
return ae
}
})()
const casas2 = moveCavaleiro(casas, 12, 12, 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment