Comparing version 0.2.1 to 0.3.0
@@ -5,7 +5,7 @@ // Returns a function that, applied to an argument list arg2, applies the | ||
// | ||
// inspired by: http://osteele.com/sources/javascript/functional/ | ||
// Inspired by: http://osteele.com/sources/javascript/functional/ | ||
'use strict'; | ||
var toArray = require('../List/toArray').call | ||
var toArray = require('../List/to-array').call | ||
, slice = require('../List/slice').call; | ||
@@ -12,0 +12,0 @@ |
// Dynamic scope for given function | ||
// Pollutes global scope for time of function call | ||
@@ -3,0 +4,0 @@ 'use strict'; |
@@ -5,3 +5,3 @@ // Returns a function that swaps its first two arguments before passing them to | ||
// | ||
// inspired by: http://osteele.com/sources/javascript/functional/ | ||
// Inspired by: http://osteele.com/sources/javascript/functional/ | ||
@@ -8,0 +8,0 @@ 'use strict'; |
@@ -1,11 +0,12 @@ | ||
// Bind f's bind and call methods to f | ||
// Bind function's bind, call and apply methods to itself | ||
'use strict'; | ||
var bind = require('./bind') | ||
, call = require('./call'); | ||
var bindBind = require('./bind-bind') | ||
, bindCall = require('./bind-call') | ||
, bindApply = require('./bind-apply'); | ||
module.exports = function (f) { | ||
f.bind = bind(f); f.call = call(f); | ||
f.bind = bindBind(f); f.call = bindCall(f); f.apply = bindApply(f); | ||
return f; | ||
}; |
@@ -0,14 +1,24 @@ | ||
// Export all modules. | ||
// We could as well scan file system but it won't work in browser environment. | ||
'use strict'; | ||
exports.bind = require('./bind'); | ||
exports.call = require('./call'); | ||
exports.curry = require('./curry'); | ||
exports.dscope = require('./dscope'); | ||
exports.flip = require('./flip'); | ||
exports.functionalize = require('./functionalize'); | ||
exports.inherit = require('./inherit'); | ||
exports.invoke = require('./invoke'); | ||
exports.isFunction = require('./isFunction'); | ||
exports.k = require('./k'); | ||
exports.s = require('./s'); | ||
exports.sequence = require('./sequence'); | ||
module.exports = { | ||
aritize: require('./aritize'), | ||
bindApply: require('./bind-apply'), | ||
bindBind: require('./bind-bind'), | ||
bindCall: require('./bind-call'), | ||
curry: require('./curry'), | ||
dscope: require('./dscope'), | ||
flip: require('./flip'), | ||
functionalize: require('./functionalize'), | ||
inherit: require('./inherit'), | ||
invoke: require('./invoke'), | ||
isFunction: require('./is-function'), | ||
k: require('./k'), | ||
noop: require('./noop'), | ||
pluck: require('./pluck'), | ||
s: require('./s'), | ||
saturate: require('./saturate'), | ||
sequence: require('./sequence') | ||
}; |
// Curries function 'a' with 'b'.call function | ||
// One of the ways to implement functionality of 'super' | ||
// One of the methods to implement functionality of 'super' | ||
// | ||
@@ -10,7 +10,7 @@ // e.g. | ||
var call = require('./call') | ||
, curry = require('./curry'); | ||
var bindCall = require('./bind-call') | ||
, curry = require('./curry'); | ||
module.exports = function (a, b) { | ||
return curry(a, call(b)); | ||
return curry(a, bindCall(b)); | ||
}; |
@@ -5,3 +5,3 @@ // Returns a function that takes an object as an argument, and applies object's | ||
// | ||
// inspired by: http://osteele.com/sources/javascript/functional/ | ||
// Inspired by: http://osteele.com/sources/javascript/functional/ | ||
@@ -8,0 +8,0 @@ 'use strict'; |
// Returns a constant function that returns x | ||
// k(x)(y) =def x | ||
// | ||
// inspired by: http://osteele.com/sources/javascript/functional/ | ||
// Inspired by: http://osteele.com/sources/javascript/functional/ | ||
'use strict'; | ||
var bind = require('./bind'); | ||
var bindBind = require('./bind-bind'); | ||
module.exports = bind(function () { | ||
module.exports = bindBind(function () { | ||
return this; | ||
}); |
@@ -5,7 +5,7 @@ // Returns a function that applies the first function to the result of the | ||
// | ||
// inspired by: http://osteele.com/sources/javascript/functional/ | ||
// Inspired by: http://osteele.com/sources/javascript/functional/ | ||
'use strict'; | ||
var toArray = require('../List/toArray').call; | ||
var toArray = require('../List/to-array').call; | ||
@@ -12,0 +12,0 @@ module.exports = function (f, g) { |
@@ -1,14 +0,14 @@ | ||
// Same as compose, except applies the functions in argument-list order. | ||
// Applies the functions in argument-list order. | ||
// sequence(f1, f2, f3…, fn)(args…) =def fn(…(f3(f2(f1(args…))))) | ||
// | ||
// inspired by: http://osteele.com/sources/javascript/functional/ | ||
// Inspired by: http://osteele.com/sources/javascript/functional/ | ||
'use strict'; | ||
var bind = require('./bind') | ||
, toArray = require('../List/toArray').call | ||
var bindBind = require('./bind-bind') | ||
, toArray = require('../List/to-array').call | ||
, f; | ||
f = bind(function (result, method) { | ||
f = bindBind(function (result, method) { | ||
return [method.apply(this, result)]; | ||
@@ -15,0 +15,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
// Global object | ||
// Get global object | ||
@@ -3,0 +3,0 @@ 'use strict'; |
@@ -0,8 +1,14 @@ | ||
// Export all modules. | ||
// We could as well scan file system but it won't work in browser environment. | ||
'use strict'; | ||
exports.global = require('./global'); | ||
exports.reserved = require('./reserved'); | ||
module.exports = { | ||
global: require('./global'), | ||
reserved: require('./reserved'), | ||
exports.Function = require('./Function'); | ||
exports.Array = require('./List'); | ||
exports.Object = require('./Object'); | ||
Function: require('./Function'), | ||
List: require('./List'), | ||
Object: require('./Object'), | ||
String: require('./String') | ||
}; |
@@ -0,4 +1,19 @@ | ||
// Export all modules. | ||
// We could as well scan file system but it won't work in browser environment. | ||
'use strict'; | ||
exports.slice = require('./slice'); | ||
exports.toArray = require('./toArray'); | ||
module.exports = { | ||
compact: require('./compact'), | ||
concat: require('./concat'), | ||
every: require('./every'), | ||
filter: require('./filter'), | ||
flatten: require('./flatten'), | ||
forEach: require('./for-each'), | ||
isList: require('./is-list'), | ||
map: require('./map'), | ||
reduce: require('./reduce'), | ||
slice: require('./slice'), | ||
some: require('./some'), | ||
toArray: require('./to-array') | ||
}; |
@@ -1,2 +0,2 @@ | ||
// slice for array like objects | ||
// Array.prototype.slice for array-like objects | ||
@@ -3,0 +3,0 @@ 'use strict'; |
// Merge object properties of given object into one object | ||
// | ||
// elevate.call({ a: { b: 1, c: 1 }, d: { e: 1, f: 1 } }) | ||
@@ -3,0 +4,0 @@ // =def { b: 1, c: 1, e: 1, f: 1 } |
@@ -1,10 +0,11 @@ | ||
// Extend object. Function properties found in both objects will be extended | ||
// such as child method will receive descendand method as first argument. | ||
// This configuraton allows super calls. More details under ../Function/inherit | ||
// Extend object. | ||
// Function properties found in both objects will be extended such as child | ||
// method will receive descendand method as first argument. | ||
// This configuraton allows super calls. More details at ../Function/inherit | ||
'use strict'; | ||
var bind = require('../Function/bind') | ||
var bindBind = require('../Function/bind-bind') | ||
, f = require('../Function/functionalize') | ||
, isFunction = require('../Function/isFunction') | ||
, isFunction = require('../Function/is-function') | ||
, inherit = require('../Function/inherit') | ||
@@ -14,3 +15,3 @@ | ||
fn = bind(function (b, k) { | ||
fn = bindBind(function (b, k) { | ||
this[k] = isFunction(this[k]) ? inherit(b[k], this[k]) : b[k]; | ||
@@ -17,0 +18,0 @@ }); |
@@ -0,14 +1,27 @@ | ||
// Export all modules. | ||
// We could as well scan file system but it won't work in browser environment. | ||
'use strict'; | ||
exports.bindMethods = require('./bindMethods'); | ||
exports.elevate = require('./elevate'); | ||
exports.extend = require('./extend'); | ||
exports.isObject = require('./isObject'); | ||
exports.isPlainObject = require('./isPlainObject'); | ||
exports.link = require('./link'); | ||
exports.merge = require('./merge'); | ||
exports.pluck = require('./pluck'); | ||
exports.set = require('./set'); | ||
exports.setTrue = require('./setTrue'); | ||
exports.setValue = require('./setValue'); | ||
exports.values = require('./values'); | ||
module.exports = { | ||
bindMethods: require('./bind-methods'), | ||
clone: require('./clone'), | ||
compare: require('./compare'), | ||
elevate: require('./elevate'), | ||
every: require('./every'), | ||
extend: require('./extend'), | ||
filter: require('./filter'), | ||
forEach: require('./for-each'), | ||
isEmpty: require('./is-empty'), | ||
isObject: require('./is-object'), | ||
isPlainObject: require('./is-plain-object'), | ||
link: require('./link'), | ||
map: require('./map'), | ||
merge: require('./merge'), | ||
pluck: require('./pluck'), | ||
same: require('./same'), | ||
set: require('./set'), | ||
setTrue: require('./set-true'), | ||
setValue: require('./set-value'), | ||
values: require('./values') | ||
}; |
@@ -1,3 +0,4 @@ | ||
// Returns a function that for given key assings chosen object property value to | ||
// Returns a function that for given key assigns chosen object property value to | ||
// same property of other object | ||
// | ||
// link.call(a, b)(k) =def a[k]=b[k] | ||
@@ -4,0 +5,0 @@ |
@@ -1,2 +0,3 @@ | ||
// Merge properties of one object into other | ||
// Merge properties of one object into other. | ||
// Property keys found in both objects will be overwritten. | ||
@@ -3,0 +4,0 @@ 'use strict'; |
// Returns a function that for given key returns object[key] value | ||
// pluck.call(o)(k) =def o[k] | ||
// | ||
// pluck.bind(o)(k) =def o[k] | ||
@@ -4,0 +5,0 @@ 'use strict'; |
// Return function that sets value to key property for given object | ||
// | ||
// set.call(o)(k, v) =def o[k]=v | ||
@@ -3,0 +4,0 @@ |
@@ -5,3 +5,3 @@ // List of EcmaScript 5th edition reserved keywords | ||
var setTrue = require('./Object/setTrue').bind | ||
var setTrue = require('./Object/set-true').bind | ||
, elevate = require('./Object/elevate').call; | ||
@@ -8,0 +8,0 @@ |
{ | ||
"name": "es5-ext", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"description": "ECMAScript5 extensions", | ||
@@ -15,9 +15,3 @@ "keywords": ["ecmascript", "ecmascript5", "es5", "extensions", "addons", "extras", "javascript"], | ||
"web": "https://github.com/medikoo/es5-ext/issues" | ||
}, | ||
"scripts": { "test": "node test/run" }, | ||
"devDependencies": { | ||
"test": "0.1.x", | ||
"expresso": "0.7.x", | ||
"jslint": "0.1.x" | ||
} | ||
} |
@@ -42,3 +42,3 @@ # es5-ext - ECMAScript5 extensions | ||
_For documentation look into source files._ | ||
_Each extension is documented at begin of its source file._ | ||
@@ -53,4 +53,6 @@ * `global` | ||
* `Function.bind(f)` | ||
* `Function.call(f)` | ||
* `Function.aritize(f, n)` | ||
* `Function.bindApply(f)` | ||
* `Function.bindBind(f)` | ||
* `Function.bindCall(f)` | ||
* `Function.curry(f[, ...])` | ||
@@ -64,3 +66,6 @@ * `Function.dscope(f, scope)` | ||
* `Function.k(x)` | ||
* `Function.noop()` | ||
* `Function.pluck(name)` | ||
* `Function.s(f, g)` | ||
* `Function.saturate(f)` | ||
* `Function.sequence(f[, ...])` | ||
@@ -70,5 +75,15 @@ | ||
Extensions for Array-like objects | ||
Extensions for Array-like objects. | ||
* `List.slice([begin[, end]])` | ||
* `List.compact()` | ||
* `List.concat([...])` | ||
* `List.every(f[, o])` | ||
* `List.filter(f[, o])` | ||
* `List.flatten()` | ||
* `List.forEach(f[, o])` | ||
* `List.isList(x)` | ||
* `List.map(f[, o])` | ||
* `List.reduce(f[, x])` | ||
* `List.slice([start[, end]])` | ||
* `List.some(f[, o])` | ||
* `List.toArray()` | ||
@@ -78,23 +93,38 @@ | ||
* `Object.bindMethods([p])` | ||
* `Object.bindMethods([p[, q]])` | ||
* `Object.clone()` | ||
* `Object.compare(p)` | ||
* `Object.elevate([p])` | ||
* `Object.every(f[, p])` | ||
* `Object.extend(o)` | ||
* `Object.filter(f[, p])` | ||
* `Object.forEach(f[, p])` | ||
* `Object.isEmpty()` | ||
* `Object.isObject(x)` | ||
* `Object.isPlainObject()` | ||
* `Object.link(p)` | ||
* `Object.map(f[, p])` | ||
* `Object.merge(p)` | ||
* `Object.pluck(name)` | ||
* `Object.set()` | ||
* `Object.same()` | ||
* `Object.setTrue()` | ||
* `Object.setValue(value)` | ||
* `Object.set()` | ||
* `Object.values()` | ||
## Tests | ||
#### String | ||
When using node & npm | ||
##### Convertion methods | ||
$ make test | ||
* `String.convert.dashToCamelCase(str)` | ||
Tests with coverage report: | ||
<!-- ## Tests --> | ||
$ make test-cov | ||
<!-- Before running tests make sure you have node and npm installed and you've run --> | ||
<!-- _make install_ first. --> | ||
<!-- $ make test --> | ||
<!-- Tests with coverage report: --> | ||
<!-- $ make test-cov --> |
'use strict'; | ||
var fn = require('Function/curry') | ||
, toArray = require('List/toArray').call | ||
var toArray = require('../../lib/List/to-array').call | ||
, a, t; | ||
, f; | ||
a = function (a, b, c) { | ||
f = function (a, b, c) { | ||
return toArray(arguments); | ||
}; | ||
Object.keys(t = { | ||
"Function.curry": function () { | ||
assert.equal(fn(a, 1)(2, 3).toString(), [1, 2, 3].toString(), this); | ||
} | ||
}).forEach(function (m) { | ||
exports['test ' + m] = t[m].bind(m); | ||
}); | ||
module.exports = function (t, a) { | ||
a.equal(t(f, 1)(2, 3).toString(), [1, 2, 3].toString()); | ||
}; |
'use strict'; | ||
var fn = require('Function/dscope') | ||
var f, o, org; | ||
, a, b, o, t, org; | ||
org = decodeURI; | ||
a = function () { | ||
f = function () { | ||
return c; | ||
@@ -13,12 +11,10 @@ }; | ||
Object.keys(t = { | ||
"Function.dscope: dynamic scope": function () { | ||
assert.equal(fn(a, o), o.c, this); | ||
module.exports = { | ||
"Dynamic scope": function (t, a) { | ||
a.equal(t(f, o), o.c); | ||
}, | ||
"Function.scope: reverts global properties": function () { | ||
fn(a, o); | ||
assert.equal(decodeURI, org, this); | ||
"Reverts global properties": function (t, a) { | ||
t(f, o); | ||
a.equal(decodeURI, org); | ||
} | ||
}).forEach(function (m) { | ||
exports['test ' + m] = t[m].bind(m); | ||
}); | ||
}; |
'use strict'; | ||
var fn = require('Function/flip') | ||
, toArray = require('List/toArray').call | ||
var toArray = require('../../lib/List/to-array').call | ||
, a, t; | ||
, f; | ||
a = function (a, b) { | ||
f = function (a, b) { | ||
return toArray(arguments); | ||
}; | ||
Object.keys(t = { | ||
"Function.flip": function () { | ||
assert.equal(fn(a)(1, 2, 3).toString(), [2, 1, 3].toString(), this); | ||
} | ||
}).forEach(function (m) { | ||
exports['test ' + m] = t[m].bind(m); | ||
}); | ||
module.exports = function (t, a) { | ||
a.equal(t(f)(1, 2, 3).toString(), [2, 1, 3].toString()); | ||
}; |
'use strict'; | ||
var fn = require('Function/functionalize') | ||
var o = {}; | ||
, f, a, t; | ||
f = fn(function () { | ||
return this; | ||
}); | ||
a = {}; | ||
Object.keys(t = { | ||
"Function.functionalize: bind": function () { | ||
var bind = f.bind; | ||
assert.equal(bind(a)(), a, this); | ||
module.exports = { | ||
"Bind": function (t, a) { | ||
var bind = t(function () { return this; }).bind; | ||
a.equal(bind(o)(), o); | ||
}, | ||
"Function.functionalize: call": function () { | ||
var call = f.call; | ||
assert.equal(call(a), a, this); | ||
"Call": function (t, a) { | ||
var call = t(function () { return this; }).call; | ||
a.equal(call(a), a); | ||
}, | ||
"Apply": function (t, a) { | ||
var apply = t(function () { return this; }).apply; | ||
a.equal(apply(a), a); | ||
} | ||
}).forEach(function (m) { | ||
exports['test ' + m] = t[m].bind(m); | ||
}); | ||
}; |
'use strict'; | ||
var fn = require('Function/inherit') | ||
var f, g; | ||
, a, b, f, t; | ||
f = function (x) { return x + 1; }; | ||
g = function (parent, x) { return parent(this, x); }; | ||
a = function (x) { return x + 1; }; | ||
b = function (parent, x) { return parent(this, x); }; | ||
f = fn(b, a); | ||
Object.keys(t = { | ||
"Function.inherit": function () { | ||
assert.equal(f(2), 3, this); | ||
} | ||
}).forEach(function (m) { | ||
exports['test ' + m] = t[m].bind(m); | ||
}); | ||
module.exports = function (t, a) { | ||
a.equal(t(g, f)(2), 3); | ||
}; |
'use strict'; | ||
var fn = require('Function/invoke') | ||
, k = require('Function/k') | ||
var k = require('../../lib/Function/k') | ||
, a, b, t; | ||
, o; | ||
a = { b: k('c')}; | ||
o = { b: k('c')}; | ||
Object.keys(t = { | ||
"Function.invoke": function () { | ||
assert.equal(fn('b')(a), 'c', this); | ||
} | ||
}).forEach(function (m) { | ||
exports['test ' + m] = t[m].bind(m); | ||
}); | ||
module.exports = function (t, a) { | ||
a.equal(t('b')(o), 'c'); | ||
}; |
'use strict'; | ||
var fn = require('Function/k') | ||
var o = {}; | ||
, a, t; | ||
a = {}; | ||
Object.keys(t = { | ||
"Function.k": function () { | ||
assert.equal(fn(a)(), a, this); | ||
} | ||
}).forEach(function (m) { | ||
exports['test ' + m] = t[m].bind(m); | ||
}); | ||
module.exports = function (t, a) { | ||
a.equal(t(o)(), o); | ||
}; |
'use strict'; | ||
var fn = require('Function/s') | ||
, toArray = require('List/toArray').call | ||
, slice = require('List/slice').call | ||
var concat = require('../../lib/List/concat').call | ||
, slice = require('../../lib/List/slice').call | ||
, a, b, c, t; | ||
, f, g; | ||
a = function (b) { | ||
return ["A"].concat(b).concat(slice(arguments, 1)); | ||
f = function (b) { | ||
return ["A"].concat(b, slice(arguments, 1)); | ||
}; | ||
b = function () { | ||
return ["B"].concat(toArray(arguments)); | ||
g = function () { | ||
return concat(["B"], arguments); | ||
}; | ||
Object.keys(t = { | ||
"Function.S": function () { | ||
assert.equal(fn(a, b)(1,2).toString(), ["A", "B", 1, 2, 1, 2].toString(), | ||
this); | ||
} | ||
}).forEach(function (m) { | ||
exports['test ' + m] = t[m].bind(m); | ||
}); | ||
module.exports = function (t, a) { | ||
a.equal(t(f, g)(1,2).toString(), ["A", "B", 1, 2, 1, 2].toString()); | ||
}; |
'use strict'; | ||
var fn = require('Function/sequence') | ||
var f, g, h; | ||
, a, b, c, t; | ||
a = function (a, b) { | ||
f = function (a, b) { | ||
return ['a', arguments.length, a, b]; | ||
}; | ||
b = function (a) { | ||
g = function (a) { | ||
return ['b', arguments.length].concat(a); | ||
}; | ||
c = function (a) { | ||
h = function (a) { | ||
return ['c', arguments.length].concat(a); | ||
}; | ||
Object.keys(t = { | ||
"Function.sequence": function () { | ||
assert.equal(fn(a, b, c)(1, 2).toString(), | ||
['c', 1, 'b', 1, 'a', 2, 1, 2], this); | ||
} | ||
}).forEach(function (m) { | ||
exports['test ' + m] = t[m].bind(m); | ||
}); | ||
module.exports = function (t, a) { | ||
a.equal(t(f, g, h)(1, 2).toString(), ['c', 1, 'b', 1, 'a', 2, 1, 2]); | ||
}; |
'use strict'; | ||
var o = require('global') | ||
, t; | ||
Object.keys(t = { | ||
"Global is an object": function () { | ||
assert.ok(o && typeof o === 'object', this); | ||
} | ||
}).forEach(function (m) { | ||
exports['test ' + m] = t[m].bind(m); | ||
}); | ||
module.exports = function (t, a) { | ||
a.ok(t && typeof t === 'object'); | ||
}; |
'use strict'; | ||
var fn = require('List/slice').call | ||
, a, t; | ||
a = [1, 2, 3, 4, 5, 6]; | ||
Object.keys(t = { | ||
"List.slice": function () { | ||
assert.equal(fn(function () { | ||
return arguments; | ||
}.apply(this, a), 1, 4).toString(), a.slice(1, 4).toString(), this); | ||
} | ||
}).forEach(function (m) { | ||
exports['test ' + m] = t[m].bind(m); | ||
}); | ||
exports.__generic = function (t, a) { | ||
a.equal(t.call(this, 1, 3).length, 2); | ||
}; |
'use strict'; | ||
var fn = require('Object/elevate').call | ||
, o, t; | ||
o = fn({ a: { aa: 1, ab: 2 }, b: { ba: 3, bb: 4 } }); | ||
Object.keys(t = { | ||
"Object.elevate": function () { | ||
assert.equal([o.aa, o.ab, o.ba, o.bb].toString(), | ||
[1,2,3,4].toString(), this); | ||
} | ||
}).forEach(function (m) { | ||
exports['test ' + m] = t[m].bind(m); | ||
}); | ||
module.exports = function (t, a) { | ||
var o = t.call({ a: { aa: 1, ab: 2 }, b: { ba: 3, bb: 4 } }); | ||
a.equal([o.aa, o.ab, o.ba, o.bb].toString(), [1,2,3,4].toString()); | ||
}; |
'use strict'; | ||
var fn = require('Object/extend').call | ||
module.exports = function (t, a) { | ||
var o1 = { a: function (x) { return x + 1; }, b: function () { }, d: {} } | ||
, o2 = { a: function (parent, x) { return parent(this, x); } | ||
, c: function () { }, d: {} } | ||
, a, b, o, t; | ||
, r = t.call(o1, o2); | ||
a = { a: function (x) { return x + 1; }, b: function () { }, d: {} }; | ||
b = { a: function (parent, x) { return parent(this, x); }, c: function () { } | ||
, d: {} }; | ||
o = fn(a, b); | ||
Object.keys(t = { | ||
"Object.extend: inheritance": function () { | ||
assert.equal(o.a(2), 3, this); | ||
}, | ||
"Object.extend: ancestor methods": function () { | ||
assert.equal(o.b, a.b, this); | ||
}, | ||
"Object.extend: descendant methods": function () { | ||
assert.equal(o.c, b.c, this); | ||
}, | ||
"Object.extend: non function property override": function () { | ||
assert.equal(o.d, b.d, this); | ||
} | ||
}).forEach(function (m) { | ||
exports['test ' + m] = t[m].bind(m); | ||
}); | ||
return { | ||
"Inheritance": function (t, a) { | ||
a.equal(r.a(2), 3); | ||
}, | ||
"Ancestor methods": function (t, a) { | ||
a.equal(r.b, o1.b); | ||
}, | ||
"Descendant methods": function (t, a) { | ||
a.equal(r.c, o2.c); | ||
}, | ||
"Non function property override": function (t, a) { | ||
a.equal(r.d, o2.d); | ||
} | ||
}; | ||
}; |
'use strict'; | ||
var fn = require('Object/link').call | ||
, a, b, t; | ||
a = {}; | ||
b = { a: 2 }; | ||
fn(a, b, 'a'); | ||
Object.keys(t = { | ||
"Object.link": function () { | ||
assert.equal(a.a, 2, this); | ||
} | ||
}).forEach(function (m) { | ||
exports['test ' + m] = t[m].bind(m); | ||
}); | ||
module.exports = function (t, a) { | ||
var o = {}; | ||
t.call(o, {a: 2}, 'a'); | ||
a.equal(o.a, 2); | ||
}; |
'use strict'; | ||
var fn = require('Object/merge').call | ||
module.exports = function (t, a) { | ||
var o1 = { a: 1, b: 2 } | ||
, o2 = { b: 3, c: 4 }; | ||
, a, b, t; | ||
t.call(o1, o2); | ||
a = { b: 2 }; | ||
b = { a: 1, b: 4, c: 3 }; | ||
fn(a, b); | ||
Object.keys(t = { | ||
"Object.merge": function () { | ||
assert.equal([a.a, a.b, a.c].toString(), [1,4,3].toString(), this); | ||
} | ||
}).forEach(function (m) { | ||
exports['test ' + m] = t[m].bind(m); | ||
}); | ||
return { | ||
"Keep": function (t, a) { | ||
a.equal(o1.a, 1); | ||
}, | ||
"Overwrite": function (t, a) { | ||
a.equal(o1.b, 3); | ||
}, | ||
"Add": function (t, a) { | ||
a.equal(o1.c, 4); | ||
} | ||
}; | ||
}; |
'use strict'; | ||
var fn = require('Object/pluck').call | ||
, o, t; | ||
o = { a: 'b' }; | ||
Object.keys(t = { | ||
"Object.pluck": function () { | ||
assert.equal(fn(o, 'a'), 'b', this); | ||
} | ||
}).forEach(function (m) { | ||
exports['test ' + m] = t[m].bind(m); | ||
}); | ||
module.exports = function (t, a) { | ||
a.equal(t.call({ a: 'b' }, 'a'), 'b'); | ||
}; |
'use strict'; | ||
var fn = require('Object/set').call | ||
, a, t; | ||
a = {}; | ||
fn(a, 'b', 2); | ||
Object.keys(t = { | ||
"Object.set": function () { | ||
assert.equal(a.b, 2, this); | ||
} | ||
}).forEach(function (m) { | ||
exports['test ' + m] = t[m].bind(m); | ||
}); | ||
module.exports = function (t, a) { | ||
var o = {}; | ||
t.call(o, 'b', 2); | ||
a.equal(o.b, 2); | ||
}; |
'use strict'; | ||
var fn = require('Object/values').call | ||
, a, t; | ||
a = { a: 'd', b: 'e', c: 'f' }; | ||
Object.keys(t = { | ||
"Object.values": function () { | ||
assert.equal(fn(a).sort().toString(), ['d', 'e', 'f'].toString(), this); | ||
} | ||
}).forEach(function (m) { | ||
exports['test ' + m] = t[m].bind(m); | ||
}); | ||
module.exports = function (t, a) { | ||
a.equal(t.call({ a: 'd', b: 'e', c: 'f' }).sort().toString(), | ||
['d', 'e', 'f'].toString()); | ||
}; |
'use strict'; | ||
var o = require('reserved') | ||
, t; | ||
Object.keys(t = { | ||
"Reserved: keywords hash has reserved keyword": function () { | ||
assert.equal(o.keywords['break'], true, this); | ||
module.exports = { | ||
"Keywords hash has reserved keyword": function (t, a) { | ||
a.equal(t.keywords['break'], true); | ||
}, | ||
"Reserved: keywords hash has not future reserved word": function () { | ||
assert.equal(o.keywords['class'], undefined, this); | ||
"Keywords hash has not future reserved word": function (t, a) { | ||
a.equal(t.keywords['class'], undefined); | ||
}, | ||
"Reserved: keywords hash has not future strict reserved word": function () { | ||
assert.equal(o.keywords['let'], undefined, this); | ||
"Keywords hash has not future strict reserved word": function (t, a) { | ||
a.equal(t.keywords['let'], undefined); | ||
}, | ||
"Reserved: future reserved hash has not reserved keyword": function () { | ||
assert.equal(o.future['break'], undefined, this); | ||
"Future reserved hash has not reserved keyword": function (t, a) { | ||
a.equal(t.future['break'], undefined); | ||
}, | ||
"Reserved: future reserved hash has future reserved word": function () { | ||
assert.equal(o.future['class'], true, this); | ||
"Future reserved hash has future reserved word": function (t, a) { | ||
a.equal(t.future['class'], true); | ||
}, | ||
"Reserved: future reserved hash has not future strict reserved word": | ||
function () { | ||
assert.equal(o.future['let'], undefined, this); | ||
"Future reserved hash has not future strict reserved word": function (t, a) { | ||
a.equal(t.future['let'], undefined); | ||
}, | ||
"Reserved: future strict reserved hash has not reserved keyword": | ||
function () { | ||
assert.equal(o.futureStrict['break'], undefined, this); | ||
"Future strict reserved hash has not reserved keyword": function (t, a) { | ||
a.equal(t.futureStrict['break'], undefined); | ||
}, | ||
"Reserved: future strict reserved hash has not future reserved word": | ||
function () { | ||
assert.equal(o.futureStrict['class'], undefined, this); | ||
"Future strict reserved hash has not future reserved word": function (t, a) { | ||
a.equal(t.futureStrict['class'], undefined); | ||
}, | ||
"Reserved: future reserved hash has future strict reserved word": | ||
function () { | ||
assert.equal(o.futureStrict['let'], true, this); | ||
"Future reserved hash has future strict reserved word": function (t, a) { | ||
a.equal(t.futureStrict['let'], true); | ||
}, | ||
"Reserved: all reserved keywords hash has reserved keyword": function () { | ||
assert.equal(o.all['break'], true, this); | ||
"All reserved keywords hash has reserved keyword": function (t, a) { | ||
a.equal(t.all['break'], true); | ||
}, | ||
"Reserved: all reserved keywords hash has future reserved word": function () { | ||
assert.equal(o.all['class'], true, this); | ||
"All reserved keywords hash has future reserved word": function (t, a) { | ||
a.equal(t.all['class'], true); | ||
}, | ||
"Reserved: all reserved keywords hash has future strict reserved word": | ||
function () { | ||
assert.equal(o.all['let'], true, this); | ||
"All reserved keywords hash has future strict reserved word": function (t, a) { | ||
a.equal(t.all['let'], true); | ||
} | ||
}).forEach(function (m) { | ||
exports['test ' + m] = t[m].bind(m); | ||
}); | ||
}; |
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
Uses eval
Supply chain riskPackage uses eval() which is a dangerous function. This prevents 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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
38753
0
115
1235
126
0
1