Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
The 'lie' npm package is a lightweight, performant promise library implementing the Promises/A+ specification. It provides a simple way to work with asynchronous operations in JavaScript, allowing developers to create, manage, and compose promises for better asynchronous flow control.
Creating a new promise
This feature allows you to create a new promise. The constructor takes a function that contains the asynchronous operation. The function provides two arguments, resolve and reject, which are used to settle the promise.
var Promise = require('lie');
var myPromise = new Promise(function (resolve, reject) {
// Asynchronous operation here
if (/* operation successful */) {
resolve('Success!');
} else {
reject('Failure!');
}
});
Promise resolution
This feature is used to create a promise that is immediately resolved with a given value. It's useful for converting values to promises.
var Promise = require('lie');
Promise.resolve('Immediate resolve').then(function (value) {
console.log(value); // 'Immediate resolve'
});
Promise rejection
This feature is used to create a promise that is immediately rejected with a given reason. It's useful for representing asynchronous operations that have failed.
var Promise = require('lie');
Promise.reject(new Error('Immediate reject')).catch(function (error) {
console.error(error); // Error: 'Immediate reject'
});
Chaining promises
This feature allows you to chain multiple promises together and perform actions once all of them are settled. The Promise.all method returns a single promise that resolves when all of the promises in the iterable argument have resolved.
var Promise = require('lie');
var p1 = Promise.resolve(3);
var p2 = 1337;
var p3 = new Promise(function (resolve, reject) {
setTimeout(resolve, 100, 'foo');
});
Promise.all([p1, p2, p3]).then(function (values) {
console.log(values); // [3, 1337, 'foo']
});
Bluebird is a full-featured promise library with a focus on innovative features and performance. It is often considered one of the fastest promise libraries and includes additional utilities for concurrency, filtering, mapping, and more. Compared to 'lie', Bluebird is more feature-rich but also larger in size.
Q is one of the earliest promise libraries that implements the Promises/A+ specification. It provides a robust set of features for creating and managing promises. While 'lie' focuses on minimalism and performance, Q offers a wider API surface and additional features like progress notifications for long-running asynchronous operations.
The es6-promise library is a polyfill for the ES6 Promise specification. It aims to provide a lightweight and efficient implementation of promises for environments that do not natively support them. Compared to 'lie', es6-promise is more about compatibility with the ES6 standard, while 'lie' is a standalone implementation with a focus on being lightweight.
lie is a JavaScript promise/deferred implementation, implementing the Promises/A+ spec, with the goal of implementing the spec as closely as possible and nothing else, this means created promises only have a then method and promises may only be created by passing a resolver function to the constructor. Lie is not meant to compete with Q, When, or any of the other promise libraries that already exist, it is meant to be a library you could use to create a Q or When style tool belt, which I did over here.
A fork of Ruben Verborgh's library called promiscuous. Which takes advantage of my immediate library, uses object constructors, and with a name I can actually consistently spell. Plus if I learned anything from catiline (formally communist) it's that you don't want to pick an even mildly offensive name.
by defailt adds a function called 'Promise' to the global scope (or if you grab the noConflict version than one called lie)
function waitAwhile(){
return promise(function(resolve,reject){
doSomething(functin(err,result){
if(err){
reject(err);
}else{
resolve(result);
}
});
});
}
function denodify(func){
return function() {
var args = Array.prototype.concat.apply([], arguments);
return promise(function(resolve, reject) {
args.push(function(err, success) {
if (err) {
reject(err);
}
else {
resolve(success);
}
});
func.apply(undefined, args);
});
};
};
##node
install with npm install lie
, exactly the same as above but
var promise = require('lie');
FAQs
A basic but performant promise implementation
The npm package lie receives a total of 7,325,560 weekly downloads. As such, lie popularity was classified as popular.
We found that lie 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
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.