Comparing version 0.1.4 to 0.1.5
{ | ||
"name": "rubyisms", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "Prototype extensions.", | ||
@@ -5,0 +5,0 @@ "main": "rubyisms.js", |
@@ -82,2 +82,75 @@ // Colin 'Oka' Hall-Coates | ||
// Methods | ||
var _String = { | ||
_p: SP, | ||
eql: function (o) { | ||
return this === o; | ||
}, | ||
prepend: function (o) { | ||
return o + this; | ||
} | ||
}; | ||
var _Array = { | ||
_p: AP, | ||
drop: AP.slice, | ||
fetch: function(n, d) { | ||
if (typeof n !== 'number' || !isFinite(n)) throw new TypeError('Expected number'); | ||
if (Math.abs(n) > this.length - 1 && typeof d === 'undefined') throw new RangeError('Index out of bounds'); | ||
if (n < 0) n = this.length + n; | ||
return (typeof this[n] !== 'undefined' ? this[n] : d); | ||
}, | ||
take: function (n) { | ||
return this.slice().splice(0, n); | ||
}, | ||
valuesAt: function () { | ||
var a = Array.prototype.slice.call(arguments), | ||
s = this, | ||
o = []; | ||
a.forEach(function (e) { | ||
if (typeof e !== 'number' || !isFinite(e)) throw new TypeError('Expected index'); | ||
if (e < 0) e = s.length + e; | ||
o.push(s[e]); | ||
}); | ||
return o; | ||
}, | ||
zip: function() { | ||
var a = Array.prototype.slice.call(arguments), | ||
o = []; | ||
this.forEach(function(e, i) { | ||
var q = [e]; | ||
a.forEach(function(e) { | ||
if (!Array.isArray(e)) throw new TypeError('Expected type array'); | ||
q.push(e[i]); | ||
}); | ||
o.push(q); | ||
}); | ||
return o; | ||
} | ||
}; | ||
var _Object = { | ||
_p: OP | ||
}; | ||
var _Number = { | ||
_p: NP | ||
}; | ||
function buildPrototypes(e) { | ||
for (var k in e) { | ||
if (k === '_p') continue; | ||
if (e.hasOwnProperty(k)) e._p[k] = (e._p[k] || e[k]); | ||
} | ||
} | ||
[_String, _Array, _Object, _Number].forEach(buildPrototypes); | ||
}()); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4355
135