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.
var asyngleton = require('../'),
fs = require('fs');
//called ONCE
var readDir = asyngleton(function(callback) {
fs.readdir(__dirname, callback);
})
//initializes the singleton method above
readDir(function(err, files) {
//do stuff
})
//called after there's a result
readDir(function(err, files) {
//do stuff
});
Creates a new asyngleton function.
factory
- the factory method for creating the singleton. This is called ONCE.Resets the target asyngleton so the factory can be called again.
var fs = require('fs'),
asyngleton = require('asyngleton');
var readDir = asyngleton(function(callback) {
fs.readdir(__dirname, callback);
});
readDir(function(err, files) {
//make the readDir factory callable again
readDir.reset();
//do stuff...
});
creates a dictionary of singletons
var dict = require('asyngleton').dictionary(),
fs = require('fs');
var readThisDir = dict.get("readThisDir", function(onSingleton) {
fs.read(__dirname, onSingleton);
});
var readLibDir = dict.get("readLibDir", function(onSingleton) {
fs.read(__dirname + "/lib", onSingleton);
})
readThisDir(function(err, files) {
//do stuff
});
readLibDir(function(err, files) {
//do stuff
});
name
- the name of the singleton in the dictionaryfactory
- the factory method incase the singleton doesn't exist
var structr = require("structr");
structr.mixin(require("asyngleton"));
var TestClass = structr({
/**
*/
"singleton load": function(onLoad) {
fs.readFile(__dirname + "/config.json", onLoad);
}
});
var test = new TestClass();
test.load(function(config) {
});
//fs.readFile is NOT called again at this point
test.load(function(config) {
});
FAQs
asynchronously generate singletons
The npm package asyngleton receives a total of 0 weekly downloads. As such, asyngleton popularity was classified as not popular.
We found that asyngleton 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
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.