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

shimmer

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shimmer - npm Package Compare versions

Comparing version 0.6.1 to 0.7.1

test/massWrap.tap.js

28

index.js

@@ -20,3 +20,3 @@ 'use strict';

if (!nodule || !nodule[name]) {
logger("no original function to wrap");
logger("no original function " + name + " to wrap");
return;

@@ -27,2 +27,3 @@ }

logger("no wrapper function");
logger((new Error()).stack);
return;

@@ -50,5 +51,27 @@ }

function massWrap(nodules, names, wrapper) {
if (!nodules) {
logger("must provide one or more modules to patch");
logger((new Error()).stack);
return;
} else if (!Array.isArray(nodules)) {
nodules = [nodules];
}
if (!(names && Array.isArray(names))) {
logger("must provide one or more functions to wrap on modules");
return;
}
nodules.forEach(function (nodule) {
names.forEach(function (name) {
wrap(nodule, name, wrapper);
});
});
}
function unwrap(nodule, name) {
if (!nodule || !nodule[name]) {
logger("no function to unwrap.");
logger((new Error()).stack);
return;

@@ -58,3 +81,3 @@ }

if (!nodule[name].__unwrap) {
logger("no original to unwrap to -- has this already been unwrapped?");
logger("no original to unwrap to -- has " + name + " already been unwrapped?");
}

@@ -67,4 +90,5 @@ else {

shimmer.wrap = wrap;
shimmer.massWrap = massWrap;
shimmer.unwrap = unwrap;
module.exports = shimmer;

2

package.json
{
"name": "shimmer",
"version": "0.6.1",
"version": "0.7.1",
"description": "Safe(r) monkeypatching for JavaScript.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -60,2 +60,8 @@ ## Safer monkeypatching for Node.js

#### shimmer.massWrap(nodules, names, wrapper)
Just like `wrap`, with the addition that you can wrap multiple methods on
multiple modules. Note that this function expects the list of functions to be
monkeypatched on all of the modules to be the same.
#### shimmer.unwrap(nodule, name)

@@ -62,0 +68,0 @@

@@ -16,3 +16,3 @@ 'use strict';

.create('logger')
.withArgs("no original function to wrap")
.withArgs("no original function undefined to wrap")
.once();

@@ -19,0 +19,0 @@

@@ -49,3 +49,3 @@ 'use strict';

.withArgs("no original to unwrap to -- " +
"has this already been unwrapped?")
"has inc already been unwrapped?")
.once();

@@ -80,4 +80,3 @@ shimmer({logger : mock});

.create('logger')
.withArgs("no function to unwrap.")
.once();
.twice();
shimmer({logger : mock});

@@ -97,4 +96,3 @@

.create('logger')
.withArgs("no function to unwrap.")
.once();
.twice();
shimmer({logger : mock});

@@ -101,0 +99,0 @@

@@ -44,3 +44,3 @@ 'use strict';

.create('logger')
.withArgs("no original function to wrap")
.withExactArgs("no original function undefined to wrap")
.once();

@@ -63,3 +63,3 @@ shimmer({logger : mock});

.create('logger')
.withArgs("no original function to wrap")
.withExactArgs("no original function undefined to wrap")
.once();

@@ -82,4 +82,3 @@ shimmer({logger : mock});

.create('logger')
.withArgs("no wrapper function")
.once();
.twice();
shimmer({logger : mock});

@@ -101,3 +100,3 @@

.create('logger')
.withArgs("original object and wrapper must be functions")
.withExactArgs("original object and wrapper must be functions")
.once();

@@ -104,0 +103,0 @@ shimmer({logger : mock});

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