Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
jQuery Deferred solves the following problems:
Usage :
var Deferred = require('Deferred');
var when = Deferred.when;
var dfd = new Deferred() // || Deferred()
dfd.done( function () {
alert("Deferred resolved!");
} ).fail( function () {
alert("Deferred rejected!");
} );
setTimeout( function(){
dfd.resolve();
}, 1500 );
Slightly more meaningful Usage Case :
var fs = require('fs');
function readFile(fileName){
var hasReadFile = new Deferred();
fs.readFile(fileName, 'utf8',function(err, contents){
if ( err !== null ) {
return hasReadFile.reject(err);
}
return hasReadFile.resolve(contents);
});
return hasReadFile.promise();
}
function parseFile(fileName, parser){
// parser implemented elsewhere
readFile(fileName)
.done(parser.parse)
.fail(function(err){
console.error('readFile :: ', err);
});
}
What are Deferreds?
I am putting together a small list of articles worth reading about the concept of deferreds, futures and promises. In it's simplest form a deferred object is a way to introduce a callback stack to a function.
FAQs
A port of the jQuery Deferred library to node js.
The npm package Deferred receives a total of 27 weekly downloads. As such, Deferred popularity was classified as not popular.
We found that Deferred 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
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.