Comparing version 0.1.6 to 0.2.0
{ | ||
"name": "rubyisms", | ||
"version": "0.1.6", | ||
"version": "0.2.0", | ||
"description": "Prototype extensions.", | ||
@@ -11,6 +11,14 @@ "main": "rubyisms.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "npm run test-arrays && npm run test-numbers && npm run test-objects && npm run test-strings", | ||
"test-arrays": "mocha test/arrays.js", | ||
"test-numbers": "mocha test/numbers.js", | ||
"test-objects": "mocha test/objects.js", | ||
"test-strings": "mocha test/strings.js" | ||
}, | ||
"author": "Colin Hall-Coates <yo@oka.io> (http://oka.io)", | ||
"license": "MIT" | ||
"license": "MIT", | ||
"devDependencies": { | ||
"chai": "^3.0.0", | ||
"mocha": "^2.2.5" | ||
} | ||
} |
# Rubyisms | ||
Prototype extensions. |
@@ -15,3 +15,3 @@ // Colin 'Oka' Hall-Coates | ||
function $(g, s) {return {get: g, set: s};} | ||
def(SP, { | ||
@@ -67,2 +67,5 @@ capitalize: $(function () { | ||
}), | ||
func: $(function () { | ||
return typeof this === 'function'; | ||
}), | ||
numeric: $(function () { | ||
@@ -75,7 +78,10 @@ return typeof this === 'number' && this === this; | ||
size: $(function () { | ||
if (Array.isArray(this) || typeof this === 'string') return this.length; | ||
if (Array.isArray(this) || | ||
typeof this === 'string' || | ||
typeof this === 'function') return this.length; | ||
else if (typeof this === 'object') return Object.keys(this).length; | ||
else if (typeof this === 'number' && this === this) return this; | ||
}), | ||
string: $(function () { | ||
return typeof this === 'string'; | ||
return typeof this === 'string' || this instanceof String; | ||
}) | ||
@@ -95,6 +101,11 @@ }); | ||
integer: $(function () { | ||
return this.toFixed() == this; | ||
return this.toFixed() == this && this !== Infinity; | ||
}), | ||
polar: $(function () { | ||
return [Math.abs(this), (this > 0 ? 0 : Math.PI)]; | ||
return (isFinite(this) && | ||
[Math.abs(this), (this < 0 ? Math.PI : 0)]) || | ||
undefined; | ||
}), | ||
round: $(function () { | ||
return Math.round(this); | ||
}) | ||
@@ -105,5 +116,2 @@ }); | ||
_p: SP, | ||
eql: function (o) { | ||
return this === o; | ||
}, | ||
prepend: function (o) { | ||
@@ -159,7 +167,3 @@ return o + this; | ||
var _Object = { | ||
_p: OP | ||
}; | ||
var _Number = { | ||
_p: NP, | ||
_p: OP, | ||
eql: function (o) { | ||
@@ -170,2 +174,6 @@ return this === o; | ||
var _Number = { | ||
_p: NP | ||
}; | ||
function buildPrototypes(e) { | ||
@@ -172,0 +180,0 @@ for (var k in e) { |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
18723
8
530
2
2
1