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.
The promise / subscribe / deferred module of FuturesJS (Ender.JS and Node.JS)
Creates a Future (aka Promise, Deferred, Subscription, Callback) object.
Node.JS (Server):
npm install future
Ender.JS (Browser):
ender build future
var context = { "foo": "bar" }
, Future = require('future')
, future = Future.create(context)
, err
, message = "Hello World!"
;
future.whenever(function (error, data) {
if (error) {
throw err;
}
console.log(this.foo + " says: " + data);
});
future.setTimeout(100);
future.deliver(err, message);
Output:
"bar says: Hello World"
FutureTimeout: timeout 100ms
at [object SomeObject]:x:y
...
Creates a Future (aka Promise, Deferred, Subscription, Callback) object.
Core
Futures.future(globalContext=null)
- creates a Future
object and uses globalContext
as the default this
for callbacks
deliver(err, data, ...)
- Send a message (data) to all listeners (callbacks)
fulfill([err, data, ...])
- Prevent the sending of any future messages. If arguments are passed they will be deliver
ed.
whenever(callback, [context])
- Listen to all messages, applying context
if provided (passing null
cancels globalContext
)
when(callback, [context])
- Listen one-time only, then removeCallback
automatically
setTimeout(ms)
- will sends a FutureTimeout
error if no activity occurs within ms
Accessory
errback(err)
- Useful for a peer-library requiring a method specifically for errbacks
jQuery
's $.ajax
callback(data [, ...])
- Useful for a peer-library requiring a method which does not pass err
as the first parameter
jQuery
's $.ajax
removeCallback(callback, context=null)
- This callback and associated context will no longer receive messages
setAsap(on=true)
- New listeners get existing data (if available) rather than waiting until the next delivery (default on)
isFuture(obj)
- a best-effort guess as to whether or not an object is a Future
callbackCount(callback, context)
- The number of listening callbacks
deliveryCount(callback, context)
- The number of deliveries made
hasCallback(callback, context=null)
- Returns true
if the callback is listening
var context = { "foo": "bar" },
future = Futures.future(context),
err,
message = "Hello World!";
future.whenever(function (error, data) {
if (error) {
throw err;
}
console.log(this.foo + " says: " + data);
});
future.setTimeout(100);
future.deliver(err, message);
Output:
"bar says: Hello World"
FutureTimeout: timeout 100ms
at [object SomeObject]:x:y
...
FAQs
The promise / subscribe / deferred module of FuturesJS (Ender.JS and Node.JS)
The npm package future receives a total of 3,093 weekly downloads. As such, future popularity was classified as popular.
We found that future 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.