Sha256: deee7d0d363933792b63d64954529b385feb5e73cd2313a341d87d7b8dad2d77

Contents?: true

Size: 731 Bytes

Versions: 1

Compression:

Stored size: 731 Bytes

Contents

if (window.MooTools) {
  Array.implement({
    getFirst: function(n){
      return (n || n === 0) ? this.slice(0, n) : this[0]
    },

    getLast: function(n){
      if (n >= this.length) return this
      return (n || n === 0) ? this.slice(this.length - n, this.length) : this[this.length - 1]
    },

    deleteIf: function(fn){
      for (var i = 0, length = this.length; i < length; i++) {
        var el = this.shift()
        if (!fn.call(el)) this.push(el)
      }
      return this
    }
  })

  Array.alias('first', 'getFirst')
  Array.alias('last', 'getFirst')
  Array.alias('select', 'filter')
  Array.alias('compact', 'clean')
}
else {
  if (console && console.error) console.error('Mootools is not yet installed.')
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mootools-plus-0.1.3 vendor/assets/javascripts/mootools-plus/array.js