Gathering detailed insights and metrics for p-suite
Gathering detailed insights and metrics for p-suite
Gathering detailed insights and metrics for p-suite
Gathering detailed insights and metrics for p-suite
npm install p-suite
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
44 Commits
2 Branches
1 Contributors
Updated on 07 Oct 2024
JavaScript (91.05%)
TypeScript (8.95%)
Cumulative downloads
Total Downloads
Last day
0%
2
Compared to previous day
Last week
0%
2
Compared to previous week
Last month
-99.1%
5
Compared to previous month
Last year
0%
568
Compared to previous year
49
5
A collection of all of sindresorhus promise modules. This is a fork of promise-fun. It will be periodically updated with the latest upstream changes (any package additions/removals etc.).
npm install p-suite
1import pMemoize from 'p-suite/p-memoize' 2 3const memoized = pMemoize(myFunction)
Or you can use the barrel file if you are confident in your tree-shaker:
1import {pMemoize} from 'p-suite' 2 3const memoized = pMemoize.default(myFunction)
Note that that you need to use .default
explicitly - there's no mapping of default to named exports.
If you're not sure which promise module you want to use yet, or you want to use a combination of them, you can get them all from a single install. However, it's very unlikely that you'll need them all, so if you are concerned about the size of your node_modules, you should install the individual packages.
For browser usage, or if bundle size is a concern for any other reason, you should be able to use the individual exports (for example import pMemoize from 'p-suite/p-memoize'
) without negatively impacting your bundle size. But make sure to test this using a bundle analyzer if you're concerned.
Not accepting additions, but happy to take requests.
Promise.all()
but for Map
and Object
.then()
or .catch()
is calledPromise.try()
ponyfill - Starts a promise chainPromise.race()
setImmediate()
.then
/.catch
-based packagesYou should generally avoid using .then
except in edge cases.
This is a good use-case for p-map
. You might ask why you can't just specify an array of promises. Promises represent values of a computation and not the computation itself - they are eager. So by the time p-map
starts reading the array, all the actions creating those promises have already started running. p-map
works by executing a promise-returning function in a mapper function. This way the promises are created lazily and can be concurrency limited. Check out p-all
instead if you're using different functions to get each promise.
1import pMap from 'p-suite/p-map'; 2 3const urls = [ 4 'https://sindresorhus.com', 5 'https://avajs.dev', 6 'https://github.com', 7 … 8]; 9 10console.log(urls.length); 11//=> 100 12 13const mapper = url => fetchStats(url); //=> Promise 14 15const result = await pMap(urls, mapper, {concurrency: 5}); 16 17console.log(result); 18//=> [{url: 'https://sindresorhus.com', stats: {…}}, …]
No. It's a fork of the promise-fun repo, but that only consists of a hand-written readme file pointing to the various other packages. Sindre very reasonably did not want to maintain a generated monopackage. It's also worth noting that as JavaScript develops some of the packages are less necessary - a handful of them existed before async/await, so only use as needed.
There is a scheduled GitHub Actions workflow that will update p-suite with the latest versions of all its dependencies, once per day. Publishing is not automated, however, so major version updates will be made ad-hoc. In general, there will likely be a major version update whenever at least one of the dependency packages is updated.
pkg.pr.new is enabled on the repository, so you can try a prerelease version even without an npm publish of p-suite by looking at the checks for the default branch.
The package.json dependencies and exports are generated from this readme. So, to add a new package, it should be added to the readme with the same format as the others. There is an automated GitHub Actions workflow that will automatically update the package.json exports and dependencies, as well as the javascript and typescript files.
If you need to change the code in the source/
folder, don't modify it directly. Instead, make the change in generate.js
which generates it.
Implementation (what this fork adds to sindresorhus's original repo):
p-suite
rather than promise-fun
since that npm package name is taken on npm)generate.js
script which:
.js
and .d.ts
files for each package (e.g. export * from 'p-memoize'
)export * as pMemoize from 'p-memoize'
)exports
definition pointing to each re-export fileengines.node
range that satisfies all the sub-packages*npm install https://pkg.pr.new/mmkal/p-suite@8c181db
- link)The idea is that everything should be fully automated, so maintenance should be as simple as git pull && pnpm install && pnpm generate
.
Personally I would be open to adding some other useful tools that fit well with p-* packages like expiry-map
, but I'll hold off on that until there's an indication one way or another whether @sindresorhus would like to co-maintain this!
I'm creating it as a draft since it'd be a reasonably big ask for you to accept this. I'm happy to leave it for a few days and rely on the pkg.pr.new link before publishing to npm.
*note: the algorithm to detect the minimum required node version depends on the semver
package's various helpers. It isn't bullet-proof, but from debugging manually it seems good enough. This unfortunately isn't part of semver: https://github.com/npm/node-semver/issues/527. If it breaks down in future it will show up in the generated package.json though.
No vulnerabilities found.
No security vulnerabilities found.