Comparing version 1.2.1 to 1.2.2
// Generated by CoffeeScript 2.0.0-beta8 | ||
void function () { | ||
var allStubs, arrayEqual, bond, createAnonymousSpy, createReturnSpy, createThroughSpy, enhanceSpy, isFunction, nextTick, registerCleanupHook, registered; | ||
var _find, _registry, allStubs, arrayEqual, bond, createAnonymousSpy, createReturnSpy, createThroughSpy, enhanceSpy, isFunction, nextTick, registerCleanupHook, registered, registry; | ||
isFunction = function (obj) { | ||
@@ -90,2 +90,42 @@ return typeof obj === 'function'; | ||
}(); | ||
_registry = []; | ||
_find = function (obj) { | ||
var store; | ||
for (var i$ = 0, length$ = _registry.length; i$ < length$; ++i$) { | ||
store = _registry[i$]; | ||
if (store.obj === obj) | ||
return store; | ||
} | ||
store = { | ||
obj: obj, | ||
props: {} | ||
}; | ||
_registry.push(store); | ||
return store; | ||
}; | ||
registry = { | ||
set: function (obj, prop, value, newValue) { | ||
var store; | ||
store = _find(obj); | ||
if (!(null != store.props[prop])) | ||
return store.props[prop] = value; | ||
}, | ||
get: function (obj, prop) { | ||
return _find(obj).props[prop]; | ||
}, | ||
restore: function (obj, prop) { | ||
return obj[prop] = _find(obj).props[prop]; | ||
}, | ||
restoreAll: function () { | ||
var prop, store, value; | ||
for (var i$ = 0, length$ = _registry.length; i$ < length$; ++i$) { | ||
store = _registry[i$]; | ||
for (prop in store.props) { | ||
value = store.props[prop]; | ||
store.obj[prop] = value; | ||
} | ||
} | ||
return _registry = []; | ||
} | ||
}; | ||
allStubs = []; | ||
@@ -101,8 +141,3 @@ registered = false; | ||
after(function () { | ||
var stubRestore; | ||
for (var i$ = 0, length$ = allStubs.length; i$ < length$; ++i$) { | ||
stubRestore = allStubs[i$]; | ||
stubRestore(); | ||
} | ||
return allStubs = []; | ||
return registry.restoreAll(); | ||
}); | ||
@@ -118,6 +153,6 @@ return registered = true; | ||
registerRestore = function () { | ||
return allStubs.push(restore); | ||
return registry.set(obj, property, previous); | ||
}; | ||
restore = function () { | ||
return obj[property] = previous; | ||
return registry.restore(obj, property); | ||
}; | ||
@@ -159,2 +194,3 @@ to = function (newValue) { | ||
through = function () { | ||
registerRestore(); | ||
obj[property] = createThroughSpy(previous, this); | ||
@@ -161,0 +197,0 @@ return obj[property]; |
{ | ||
"name": "bondjs", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "simple js stub/spy library", | ||
@@ -14,3 +14,3 @@ "license": "MIT", | ||
"compile": "./node_modules/.bin/coffee --js <bond.coffee >lib/bond.js", | ||
"test": "./node_modules/.bin/mocha --compilers coffee:coffee-script-redux/register --reporter spec --colors test.coffee" | ||
"test": "npm run compile && ./node_modules/.bin/mocha --compilers coffee:coffee-script-redux/register --reporter spec --colors test.coffee" | ||
}, | ||
@@ -17,0 +17,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
21624
208