mol-proto
Advanced tools
Comparing version 0.1.9 to 0.1.10
{ | ||
"name": "proto", | ||
"version": "0.1.9", | ||
"version": "0.1.10", | ||
"homepage": "https://github.com/MailOnline/proto", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -85,3 +85,3 @@ 'use strict'; | ||
return func.apply(this, args.concat(slice.call(arguments))); | ||
} | ||
}; | ||
} | ||
@@ -102,3 +102,3 @@ | ||
return func.apply(this, slice.call(arguments).concat(args)); | ||
} | ||
}; | ||
} | ||
@@ -161,4 +161,4 @@ | ||
function _delay(func, wait, args) { | ||
return setTimeout(func.apply.bind(func, null, args), wait); | ||
function _delay(func, wait, args, context) { | ||
return setTimeout(func.apply.bind(func, context || null, args), wait); | ||
} | ||
@@ -236,4 +236,4 @@ | ||
return function() { | ||
return _delay(func, wait, args); | ||
} | ||
return _delay(func, wait, args, this); | ||
}; | ||
} | ||
@@ -254,4 +254,4 @@ | ||
return function() { | ||
return _delay(func, 1, args); | ||
} | ||
return _delay(func, 1, args, this); | ||
}; | ||
} | ||
@@ -258,0 +258,0 @@ |
@@ -9,2 +9,3 @@ 'use strict'; | ||
* - [identity](#identity) | ||
* - [property](#property) | ||
*/ | ||
@@ -16,3 +17,4 @@ var utilMethods = module.exports = { | ||
result: result, | ||
identity: identity | ||
identity: identity, | ||
property: property | ||
}; | ||
@@ -89,1 +91,15 @@ | ||
} | ||
/** | ||
* Returns function that picks the property from the object | ||
* | ||
* @param {String} self | ||
* @return {Function} | ||
*/ | ||
function property() { | ||
var key = this; | ||
return function(obj) { | ||
return obj[key]; | ||
}; | ||
} |
@@ -120,2 +120,3 @@ 'use strict'; | ||
* - [identity](proto_util.js.html#identity) | ||
* - [property](proto_util.js.html#property) | ||
*/ | ||
@@ -122,0 +123,0 @@ var utilMethods = require('./proto_util'); |
{ | ||
"name": "mol-proto", | ||
"version": "0.1.9", | ||
"version": "0.1.10", | ||
"description": "ES5 object manipulation library for node and modern browsers", | ||
@@ -5,0 +5,0 @@ "main": "lib/proto.js", |
@@ -137,1 +137,2 @@ proto | ||
* [identity](http://mailonline.github.io/proto/proto_util.js.html#identity) | ||
* [property](http://mailonline.github.io/proto/proto_util.js.html#property) |
@@ -178,3 +178,3 @@ 'use strict'; | ||
it('should define delayed function', function(done) { | ||
var called, args; | ||
var called, args, context = {}; | ||
@@ -184,2 +184,3 @@ function myFunc() { | ||
args = Array.prototype.slice.call(arguments); | ||
assert.equal(this, context); | ||
} | ||
@@ -189,3 +190,3 @@ | ||
delayedFunc(); | ||
delayedFunc.call(context); | ||
@@ -204,3 +205,3 @@ assert.equal(called, undefined); | ||
it('should define deferred function', function(done) { | ||
var called, args; | ||
var called, args, context = {}; | ||
@@ -210,2 +211,3 @@ function myFunc() { | ||
args = Array.prototype.slice.call(arguments); | ||
assert.equal(this, context); | ||
} | ||
@@ -215,3 +217,3 @@ | ||
deferredFunc(); | ||
deferredFunc.call(context); | ||
@@ -218,0 +220,0 @@ assert.equal(called, undefined); |
@@ -64,2 +64,11 @@ 'use strict'; | ||
}); | ||
it('should define property function', function() { | ||
var obj = { prop1: 1, prop2: 2 } | ||
, p1 = _.property('prop1') | ||
, p2 = _.property('prop2'); | ||
assert.equal(p1(obj), 1); | ||
assert.equal(p2(obj), 2); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
190813
4711
138