![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
basic-promise
Advanced tools
Basic-promise is a module promise with a simple syntax
npm install basic-promise
Basic
var promise = require('basic-promise');
var p = promise(); // => Declare the promise
p.then(function(a){ // => The promise is resolved
console.log(a); // => Resolve param
console.log('DONE');
}, function(a){ // => The promise is rejected
console.log(a); // => Reject param
console.log('ERROR')
}, function(){ // => The promise is complete (after resolve or reject)
console.log('COMPLETE');
});
//or
p.on('resolve', function(a){ // => The promise is resolved
console.log(a); // => Resolve param
console.log('DONE');
})
.on('reject', function(a){ // => The promise is rejected
console.log(a); // => Reject param
console.log('ERROR')
})
.on('complete', function(){ // => The promise is complete (after resolve or reject)
console.log('COMPLETE');
});
p.resolve('a'); // => Execute the function for resolve with the param "a"
p.reject('a'); // => Execute the function for reject with the param "a"
Multiple
var ps = [promise(), promise()]; // => Array of promises
// or
var ps = [promise().then(function(){ // => Array of promises with listener events
console.log('resolve');
},function(){
console.log('reject');
}, function(){
console.log('complete');
}),
promise().then(function(){
console.log('resolve');
},function(){
console.log('reject');
}, function(){
console.log('complete');
})];
// or
var ps = 2; // => Number of promises
var p = promise(ps);
p.then(function(){
console.log('All the promises is resolve');
}, function(){
console.log('Minimum one was rejected');
}, function(){
console.log('All the promises were completed');
});
//Only with multiple promises
p.promises; //Return an array of promises
p.eq(2); //Returns the promise to fix the position 2 (the position is 0 to infinite)
//trigger all
p.promises.forEach(function(promise, position){
promise.resolve('This promise is: '+position);
});
//Here execute the resolve event in the multiple promise => console.log('All the promises is resolve');
FAQs
Module promise with a simple syntax
We found that basic-promise 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
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.