Comparing version 1.1.0 to 1.1.1
'use strict'; | ||
module.exports = function stubs(obj, method, cfg, stub) { | ||
if (!obj || !method) { | ||
throw new Error('To stub a method, you must provide an object and a key for a method') | ||
} | ||
if (!obj || !method || !obj[method]) | ||
throw new Error('You must provide an object and a key for an existing method') | ||
@@ -25,3 +24,3 @@ if (!stub) { | ||
if (cfg.callthrough && cached) | ||
if (cfg.callthrough) | ||
cached.apply(obj, arguments) | ||
@@ -28,0 +27,0 @@ |
{ | ||
"name": "stubs", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Easy method stubber.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -27,5 +27,10 @@ # stubs | ||
// stub it out, but call the original first | ||
stubs(mylib, 'create', true, function() { | ||
stubs(mylib, 'create', { callthrough: true }, function() { | ||
// call original method, then call this | ||
}) | ||
// use the stub for a while, then revert | ||
stubs(mylib, 'create', { calls: 3 }, function() { | ||
// call this 3 times, then use the original method | ||
}) | ||
``` | ||
@@ -32,0 +37,0 @@ |
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
5483
73
137