Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Generator based utility belt
$ npm install genit
'use strict'
let genit = require('genit');
let fooFunc = function *(someSet) {
return yield genit.map(someSet, function *(value, index) {
return yield someGeneratorFunction('foo', 'bar', value);
});
}
'use strict'
let _ = require('lodash');
let genit = require('genit');
genit.inject(_);
_.each(someSet, function () { }); //existing
_.isGenerator(mightBeAGenerator) // injected
function *() {
return yield _.genit.map(someSet, function *(value, index) { }); // injected to .genit property (name collision)
}
each
yield genit.each([one, two, three], function *(value, index) {
console.log(index + ' = ' + this + ' ~ ' + value);
});
// console:
// 1 = one ~ one
// 2 = two ~ two
// 3 = three ~ three
yield genit.each({ one:'foo', two:'bar', three:'biz' }, function *(value, key) {
console.log(key + ' = ' + this + ' ~ ' + value);
});
// console:
// one = foo ~ foo
// two = bar ~ bar
// three = biz ~ biz
map
let result = yield genit.each(['one', 'two', 'three'], function *(value, index) {
console.log(index + ' = ' + this + ' ~ ' + value);
return index * 2;
});
// console:
// 1 = one ~ one
// 2 = two ~ two
// 3 = three ~ three
console.log(result);
// console:
// [0, 1, 2]
let result = yield genit.each({ one:'foo', two:'bar', three:'biz' }, function *(value, key) {
console.log(key + ' = ' + this + ' ~ ' + value);
return value;
});
// console:
// one = foo ~ foo
// two = bar ~ bar
// three = biz ~ biz
console.log(result);
// console:
// ['foo', 'bar', 'biz']
filter
let result = yield genit.filter([-1, -2, -3, 4, 5], function *(value) {
return value > 0;
});
console.log(result);
// console:
// [4,5]
let result = yield genit.filter({ one:'foo', two:'bar', three:'biz' }, function *(value, key) {
return value == "biz" || value == "bar";
});
console.log(result);
// console:
// {two : 'bar', three: 'biz'}
Coming Soon
isGenerator
let result = yield genit.isGenerator(function () {});
console.log(result); // => false
let result = yield genit.isGenerator(function *() {});
console.log(result); // => true
inject
.genit
property'use strict'
let test = { each : function () { return 'Original Each'; } };
let genit = require('genit');
genit.inject(test);
console.log(test.each()); // => "Original Each"
console.log(test.isGenerator(function () {})) // => "false"
console.log(test.isGenerator(test.genit.each)) // => "true"
FAQs
Generator based utility belt
The npm package genit receives a total of 0 weekly downloads. As such, genit popularity was classified as not popular.
We found that genit demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.