
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.
promiscuous
Advanced tools
promiscuous is a tiny implementation of the Promises/A+ spec.
It is promise library in JavaScript, small (< 1kb minified / < 0.6kb gzipped) and fast.
First, install promiscuous with npm.
$ npm install promiscuous
Then, include promiscuous in your code file.
var Promise = require('promiscuous');
Include promiscuous in your HTML file.
<script src="promiscuous-browser.js"></script>
This version (and a minified one) can be built with:
$ build/build.js
var promise = Promise.resolve("one");
promise.then(function (value) { console.log(value); });
/* one */
var brokenPromise = Promise.reject(new Error("Could not keep promise."));
brokenPromise.then(null, function (error) { console.error(error.message); });
/* "Could not keep promise." */
You can also use the catch
method if there is no success callback:
brokenPromise.catch(function (error) { console.error(error.message); });
/* "Could not keep promise." */
function promiseLater(something) {
return new Promise(function (resolve, reject) {
setTimeout(function () {
if (something)
resolve(something);
else
reject(new Error("nothing"));
}, 1000);
});
}
promiseLater("something").then(
function (value) { console.log(value); },
function (error) { console.error(error.message); });
/* something */
promiseLater(null).then(
function (value) { console.log(value); },
function (error) { console.error(error.message); });
/* nothing */
var promises = [promiseLater(1), promiseLater(2), promiseLater(3)];
Promise.all(promises).then(function (values) { console.log(values); });
/* [1, 2, 3] */
FAQs
A minimal and fast promise implementation
The npm package promiscuous receives a total of 2,689 weekly downloads. As such, promiscuous popularity was classified as popular.
We found that promiscuous 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.