Comparing version 0.0.1-alpha to 0.0.2-alpha
/* | ||
Array shell | ||
array | ||
- es5 array shell | ||
*/"use strict" | ||
var shell = require("../util/shell") | ||
var proto = Array.prototype | ||
var array = require("../util/shell")().implement({ | ||
var array = shell({ | ||
filter: proto.filter/*(es5 && array.filter)?*/ || function(fn, context){ | ||
var results = [] | ||
for (var i = 0, l = this.length >>> 0; i < l; i++){ | ||
if ((i in this) && fn.call(context, this[i], i, this)) results.push(this[i]) | ||
for (var i = 0, l = this.length >>> 0; i < l; i++) if (i in this){ | ||
var value = this[i] | ||
if (fn.call(context, value, i, this)) results.push(value) | ||
} | ||
@@ -19,3 +23,3 @@ return results | ||
for (var l = this.length >>> 0, i = (from < 0) ? Math.max(0, l + from) : from || 0; i < l; i++){ | ||
if (this[i] === item) return i | ||
if ((i in this) && this[i] === item) return i | ||
} | ||
@@ -55,3 +59,2 @@ return -1 | ||
array.isArray = Array.isArray/*(es5 && array.isArray)?*/ || function(self){ | ||
@@ -62,7 +65,7 @@ return Object.prototype.toString.call(self) === "[object Array]" | ||
var methods = {} | ||
array.forEach("pop,push,reverse,shift,sort,splice,unshift,concat,join,slice,lastIndexOf,reduce,reduceRight".split(","), function(name){ | ||
var method = proto[name] | ||
if (method) methods[name] = method | ||
}) | ||
var names = "pop,push,reverse,shift,sort,splice,unshift,concat,join,slice,lastIndexOf,reduce,reduceRight".split(",") | ||
for (var i = 0, name, method; name = names[i++];) if ((method = proto[name])) methods[name] = method | ||
module.exports = array.implement(methods) | ||
array.implement(methods) | ||
module.exports = array |
/* | ||
Number | ||
number | ||
- es5 number shell | ||
*/"use strict" | ||
module.exports = require("../util/shell")() | ||
var shell = require("../util/shell") | ||
var proto = Number.prototype | ||
var number = shell({ | ||
toExponential: proto.toExponential, | ||
toFixed: proto.toFixed, | ||
toPrecision: proto.toPrecision | ||
}) | ||
module.exports = number |
/* | ||
RegExp | ||
regexp | ||
- es5 regexp shell | ||
*/"use strict" | ||
var shell = require("../util/shell") | ||
var proto = RegExp.prototype | ||
module.exports = require("../util/shell")().implement({test: proto.test, exec: proto.exec}) | ||
var regexp = shell({test: proto.test, exec: proto.exec}) | ||
module.exports = regexp |
/* | ||
String shell | ||
string | ||
- es5 string shell | ||
*/"use strict" | ||
var shell = require("../util/shell") | ||
var proto = String.prototype | ||
var string = require("../util/shell")().implement({ | ||
var string = shell({ | ||
@@ -18,4 +21,5 @@ trim: proto.trim/*(es5 && string.trim)?*/ || function(){ | ||
for (var i = 0, name, method; name = names[i++];) if ((method = proto[name])) methods[name] = method | ||
string.implement(methods) | ||
module.exports = string |
{ | ||
"name": "prime", | ||
"homepage": "https://github.com/mootools/prime", | ||
"version": "0.0.1-alpha", | ||
"version": "0.0.2-alpha", | ||
"main": "./main.js", | ||
"description": "prime, an OOP javascript library for node and the web.", | ||
@@ -6,0 +7,0 @@ "keywords": ["library", "framework", "es5", "class", "array", "object"], |
/* | ||
Number methods | ||
number methods | ||
- inherits from es5/number | ||
*/"use strict" | ||
var number = require("../util/shell")(require("../es5/number")).implement({ | ||
var shell = require("../util/shell") | ||
var number = shell({ | ||
inherits: require("../es5/number"), | ||
/*(number.limit)?*/ | ||
@@ -14,9 +19,9 @@ limit: function(min, max){ | ||
round: function(precision){ | ||
precision = Math.pow(10, precision || 0) | ||
return Math.round(this * precision) / precision | ||
return parseFloat(number.toPrecision(this, precision)) | ||
},/*:*/ | ||
/*(number.times)?*/ | ||
times: function(fn, bind){ | ||
for (var i = 0; i < this; i++) fn.call(bind, i, null, this) | ||
times: function(fn, context){ | ||
for (var i = 0; i < this; i++) fn.call(context, i, null, this) | ||
return this | ||
},/*:*/ | ||
@@ -23,0 +28,0 @@ |
/* | ||
String methods | ||
string methods | ||
- inherits from es5/string | ||
*/"use strict" | ||
var string = require("../util/shell")(require("../es5/string")).implement({ | ||
var shell = require("../util/shell") | ||
var string = shell({ | ||
inherits: require("../es5/string"), | ||
/*(string.contains)?*/ | ||
@@ -38,2 +43,8 @@ contains: function(string, separator){ | ||
/*(string.escape)?*/ | ||
// « https://github.com/slevithan/XRegExp/blob/master/src/xregexp.js | ||
escape: function(){ | ||
return (this + "").replace(/([-.*+?^${}()|[\]\/\\])/g, '\\$1') | ||
},/*:*/ | ||
/*(string.number)?*/ | ||
@@ -47,7 +58,6 @@ number: function(){ | ||
/*(string.decode)?*/ | ||
var json = require("../es5/json") | ||
string.implement("decode", function(){ | ||
return json.parse(this) | ||
})/*:*/ | ||
if (typeof JSON !== 'undefined') string.implement({decode: function(){ | ||
return JSON.parse(this) | ||
}})/*:*/ | ||
module.exports = string |
@@ -5,73 +5,75 @@ /* | ||
var array = require("../es5/array") | ||
var prime = require("../prime"), | ||
map = require("../collection/map"), | ||
list = require("../es5/array") | ||
module.exports = function(){ | ||
var responders = [], map = [] | ||
var ghosts = map() | ||
var _ = function(self){ | ||
var ghost | ||
var ghost = function(self){ | ||
var responders = ghosts._keys, | ||
hashes = ghosts._values | ||
var Ghost | ||
for (var i = responders.length, responder; responder = responders[--i];) if (responder(self)){ | ||
ghost = map[i].ghost | ||
Ghost = hashes[i].ghost | ||
break | ||
} | ||
return ghost ? new ghost(self) : self | ||
return Ghost ? new Ghost(self) : self | ||
} | ||
_.register = function(responder, base){ | ||
var index = array.indexOf(responders, responder) | ||
if (index === -1) responders.push(responder) | ||
else return _ | ||
ghost.register = function(responder, base){ | ||
var m = {} | ||
map.push(m) | ||
if (ghosts.get(responder)) return ghost | ||
var ghost = function(self){ | ||
this.valueOf = function(){ | ||
return self | ||
} | ||
this.toString = function(){ | ||
return self + "" | ||
} | ||
this.eq = function(object){ | ||
return self === object | ||
} | ||
} | ||
var Ghost = prime({ // yes, a prime in a prime | ||
var _implement = function(props){ | ||
for (var key in props) (function(key, method){ | ||
ghost.prototype[key] = function(){ | ||
return _(method.apply(this.valueOf(), arguments)) | ||
mutator: function(key, method){ | ||
this.prototype[key] = function(){ | ||
return ghost(method.apply(this.valueOf(), arguments)) | ||
} | ||
})(key, props[key]) | ||
} | ||
}, | ||
var __implement = base.implement | ||
constructor: function(self){ | ||
this.valueOf = function(){ | ||
return self | ||
} | ||
this.toString = function(){ | ||
return self + "" | ||
} | ||
this.is = function(object){ | ||
return self === object | ||
} | ||
} | ||
base.implement = function(props){ | ||
_implement(props) | ||
__implement.call(this, props) | ||
}) | ||
var mutator = base.mutator | ||
// override base mutator, so it automagically implements stuff in the ghost | ||
// when base changes | ||
base.mutator = function(key, method){ | ||
mutator.call(this, key, method) | ||
Ghost.mutator(key, method) | ||
} | ||
_implement.call(ghost, base.prototype) | ||
Ghost.implement(base.prototype) | ||
m.implement = __implement | ||
m.base = base | ||
ghosts.set(responder, {base: base, ghost: Ghost, mutator: mutator}) | ||
return _ | ||
return ghost | ||
} | ||
_.unregister = function(responder){ | ||
var index = array.indexOf(responders, responder) | ||
if (index > -1){ | ||
responders.splice(index, 1) | ||
var m = map.splice(index, 1) | ||
m.base.implement = m.implement //reset implement to original value | ||
} | ||
return _ | ||
ghost.unregister = function(responder){ | ||
var hash = ghosts.remove(responder) | ||
if (hash) hash.base.mutator = hash.mutator | ||
return ghost | ||
} | ||
return _ | ||
return ghost | ||
} |
@@ -5,10 +5,8 @@ /* | ||
var create = require("../util/create"), | ||
var prime = require("../prime"), | ||
slice = Array.prototype.slice | ||
var shell = function(){} | ||
var shell = prime({ | ||
var implement = shell.implement = function(props){ | ||
for (var key in props) (function(key, method){ | ||
this.prototype[key] = method | ||
mutator: function(key, method){ | ||
this[key] = function(self){ | ||
@@ -18,10 +16,14 @@ var args = (arguments.length > 1) ? slice.call(arguments, 1) : [] | ||
} | ||
}).call(this, key, props[key]) | ||
return this | ||
} | ||
module.exports = function(base){ | ||
var shl = create(base || (base = shell)) | ||
shl.prototype = create(base.prototype) | ||
return shl | ||
this.prototype[key] = method | ||
}, | ||
constructor: {prototype: {}} | ||
}) | ||
module.exports = function(proto){ | ||
var inherits = proto.inherits || (proto.inherits = shell) | ||
proto.constructor = prime.create(inherits) | ||
return prime(proto) | ||
} |
@@ -9,10 +9,9 @@ /* | ||
var type = function(object){ | ||
if (object == null) return "none" | ||
if (object == null) return "null" | ||
var string = toString.call(object).slice(8, -1).toLowerCase() | ||
if (string === "number" && isNaN(object)) return "none" | ||
if (string === "function") return "method" | ||
if (!types.test(string)) string = "object" | ||
return ((string === "object") && (object.length != null) && (type(object.length) === "number")) ? "list" : string | ||
if (string === "number" && isNaN(object)) return "null" | ||
if (types.test(string)) return string | ||
return "object" | ||
} | ||
module.exports = type |
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
18147
18
626