Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
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 3 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.