Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Readme
Set of runnable interdependent operations
var OpSet = require('opset');
var UserModel = require('./models/user.js');
var BlogModel = require('./models/blog.js');
// declare set of interdependent operations
var blog = new OpSet('blog');
blog.set('username', 'edinella'); // already resolved values can be setted
blog.op('user', function() {
return UserModel.findOne({username: 'edinella'}).exec(); // returns a promise
});
blog.op('userPosts', function(user) {
return BlogModel.find({author: user.id}).exec();
});
// run userPosts operation, returns a promise
blog.run('userPosts').then(yep).fail(nope);
// handle results
function yep(result) {
console.log(result);
}
// handle errors
function nope(err) {
console.error(err);
}
Install with NPM:
npm install --save opset
Then require it:
var OpSet = require('opset');
OpSet(alias): constructor, create a new OpSet with an alias
To produce the instance, OpSet
should be called with new
operator.
var report = new OpSet('report');
set(token, value): alias for setCache() setCache(token, value): defines a resolved value for injection
Register the final value.
report.set('dateFormat', 'DD/MM/YYYY HH:mm:ss');
op(token, factoryFn): alias for operation() operation(token, factoryFn): defines a operation that generates a value for injection
To produce the instance, factoryFn
will be called once (with instance context) and its result will be used.
The factoryFn
function arguments should be the tokens of the operations that we need resolved here.
report.op('data', function(filters){
return MyModel.find(filters).exec();
});
run(token): runs an operation, returns a promise
If any operation throws an error or gets rejected, and you omit the rejection handler, the execution will be stopped and error would be forwarded to this resultant promise.
// result is a promise
var myStats = report.run('stats');
// handle results
myStats.then(function(result) {
console.log(result);
});
// handle errors, including those unhandled from inside operations
myStats.fail(function(err) {
console.error(err);
});
FAQs
Set of runnable interdependent operations
The npm package opset receives a total of 1 weekly downloads. As such, opset popularity was classified as not popular.
We found that opset 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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.