Comparing version 1.1.1 to 1.1.2
@@ -6,3 +6,5 @@ 'use strict'; | ||
}); | ||
exports.SpyRegistry = undefined; | ||
var _utils = require('./utils'); | ||
@@ -22,3 +24,3 @@ /** | ||
*/ | ||
var SpyRegistry = exports.SpyRegistry = function () { | ||
var SpyRegistry = function () { | ||
/** | ||
@@ -43,14 +45,11 @@ * @constructor | ||
SpyRegistry.prototype.restoreAll = function () { | ||
for (var key in this.register) { | ||
if (this.register.hasOwnProperty(key)) { | ||
var _register$key = this.register[key], | ||
obj = _register$key.obj, | ||
method = _register$key.method, | ||
methodName = _register$key.methodName; | ||
(0, _utils.forEach)(this.register, function (ignored, value) { | ||
var obj = value.obj, | ||
method = value.method, | ||
methodName = value.methodName; | ||
if (obj) { | ||
obj[methodName] = method; | ||
} | ||
if (obj) { | ||
obj[methodName] = method; | ||
} | ||
} | ||
}); | ||
this.register = {}; | ||
@@ -134,2 +133,4 @@ }; | ||
return SpyRegistry; | ||
}(); | ||
}(); | ||
exports.SpyRegistry = SpyRegistry; |
@@ -101,7 +101,5 @@ 'use strict'; | ||
spy[Symbols.config] = { useOwnEquals: DefaultSettings.useOwnEquals }; | ||
for (var key in Spy.prototype) { | ||
if (Spy.prototype instanceof Object && Spy.prototype.hasOwnProperty(key)) { | ||
spy[key] = Spy.prototype[key]; | ||
} | ||
} | ||
(0, _utils.forEach)(Spy.prototype, function (key, value) { | ||
spy[key] = value; | ||
}); | ||
return spy; | ||
@@ -108,0 +106,0 @@ } |
@@ -9,2 +9,27 @@ 'use strict'; | ||
/** | ||
* This function takes a handler as second argument to process | ||
* all key-value-pairs of the given object through this handler. | ||
* | ||
* For example: | ||
* | ||
* forEach({attr1: 'str1', attr2: 123}, (k, v) => { | ||
* console.log(k + 'has value: ' + v); | ||
* }); | ||
* | ||
* @param {Array<any>|Object} arrOrObj <- Array or Object to iterate. | ||
* (Flow does not want to iterate | ||
* over arrays with for-in, so we | ||
* have to write here any.) | ||
* @param {Function} handler <- Handler function to process all values. | ||
* | ||
*/ | ||
var forEach = function forEach(arrOrObj, handler) { | ||
for (var key in arrOrObj) { | ||
if (arrOrObj.hasOwnProperty(key)) { | ||
handler(key, arrOrObj[key]); | ||
} | ||
} | ||
}; | ||
/** | ||
* This function returns all own keys for the given | ||
@@ -28,7 +53,5 @@ * object or array as array. | ||
var keys = []; | ||
for (var key in arrOrObj) { | ||
if (arrOrObj.hasOwnProperty(key)) { | ||
keys.push(key); | ||
} | ||
} | ||
forEach(arrOrObj, function (key) { | ||
return keys.push(key); | ||
}); | ||
return keys; | ||
@@ -160,2 +183,3 @@ }; | ||
exports.differenceOf = differenceOf; | ||
exports.forEach = forEach; | ||
exports.objectKeys = objectKeys; |
{ | ||
"name": "spy4js", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Use new Spy() to optimize your tests with helpful debug messages.", | ||
@@ -5,0 +5,0 @@ "main": "dist/spy.js", |
# spy4js [![npm package][npm-badge]][npm] | ||
# spy4js [![npm package][npm-badge]][npm] [![Travis][build-badge]][build] | ||
[build-badge]: https://img.shields.io/travis/fdc-viktor-luft/spy4js/master.svg?style=flat-square | ||
[build]: https://travis-ci.org/fdc-viktor-luft/spy4js | ||
[npm-badge]: https://img.shields.io/npm/v/spy4js.svg?style=flat-square | ||
@@ -424,2 +427,6 @@ [npm]: https://www.npmjs.org/package/spy4js | ||
* **1.1.2** | ||
* Connected travis.ci and improved code coverage slightly. | ||
* **1.1.1** | ||
* Connected Coverage-Reporter and restructured files. | ||
* **1.1.0:** | ||
@@ -426,0 +433,0 @@ * Implemented `getCallArgument` as extension of `getFirstCallArgument`. |
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
90832
885
451