Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stubs

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stubs - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

7

index.js
'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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc