
Product
Introducing Pull Request Stories to Help Security Teams Track Supply Chain Risks
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
Wrap each function in object with a thunk. Useful for generator-based flow control such as co.
Wrap each function in object with a thunk. Useful for generator-based flow control such as co.
var EventEmitter = require('events').EventEmitter,
inherits = require('util').inherits;
var TestClass = module.exports = function() {
EventEmitter.apply(this, arguments);
// define some properties
this._foo = 'foo';
this._bar = 'bar';
Object.defineProperty(this, 'foo', {
get: function() {
return this._foo;
},
set: function(val) {
this._foo = val;
}
});
Object.defineProperty(this, 'bar', {
get: function() {
return this._bar;
},
set: function(val) {
this._bar = val;
}
});
};
inherits(TestClass, EventEmitter);
// define async function
TestClass.prototype.getFooBar = function(callback) {
callback(null, this.foo + this.bar);
};
// define sync function
TestClass.prototype.getFooBarSync = function() {
return this.foo + this.bar;
};
// wrap oroginal object with co-wrapper
var wrap = require('co-wrapper');
var wrapper = wrapper = wrap(testObj, {
exclude: ['getFooBarSync'],
isEventEmitter: true,
properties: {
foo: {
get: '_foo',
set: function(val) {
testObj._foo = val;
}
},
bar: {
get: function() {
return testObj._bar;
},
set: '_bar'
}
}
});
(function *() {
console.log(yield wrapper.getFooBar());
})();
{
exclude: [], // object functions, that should be excluded
methods: [], // list of methods to wrap
isEventEmitter: true, // set to true, if object has event emitter functionality
properties: {
name: {
get: function () {return this._foo}, // getters and setters can be String,
// that defines source object property, or function
set: '_foo' // function would be run in source object scope
// other Object.defineProperty parameters
}
}
}
License: MIT
FAQs
Wrap each function in object with a thunk. Useful for generator-based flow control such as co.
We found that co-wrapper demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.