vendor/assets/javascripts/mootools-plus/array.js in mootools-plus-0.1.6 vs vendor/assets/javascripts/mootools-plus/array.js in mootools-plus-0.2.0
- old
+ new
@@ -1,42 +1,37 @@
-if (window.MooTools) {
- Array.implement({
- getFirst: function(n){
- return (n || n === 0) ? this.slice(0, n) : this[0]
- },
+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]
- },
+ 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
- },
+ 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
+ },
- filterOne: function(fn, bind){
- return this.filter(fn, bind).getFirst()
- },
+ filterOne: function(fn, bind){
+ return this.filter(fn, bind).getFirst()
+ },
- isBlank: function(){
- return this.length == 0
- },
+ isBlank: function(){
+ return this.length == 0
+ },
- hasAny: function(){
- return !this.isBlank()
- }
- })
+ hasAny: function(){
+ return !this.isBlank()
+ }
+})
- Array.alias('first', 'getFirst')
- Array.alias('last', 'getLast')
- Array.alias('select', 'filter')
- Array.alias('selectOne', 'filterOne')
- Array.alias('compact', 'clean')
- Array.alias('isEmpty', 'isBlank')
-}
-else {
- if (console && console.error) console.error('Mootools is not yet installed.')
-}
+Array.alias('first', 'getFirst')
+Array.alias('last', 'getLast')
+Array.alias('select', 'filter')
+Array.alias('selectOne', 'filterOne')
+Array.alias('compact', 'clean')
+Array.alias('isEmpty', 'isBlank')