https://github.com/es-shims/promise.withresolvers
ES Proposal spec-compliant shim for Promise.withResolvers
https://github.com/es-shims/promise.withresolvers
defer deferred ecmascript es-shims javascript polyfill promise shim withresolvers
Last synced: 7 days ago
JSON representation
ES Proposal spec-compliant shim for Promise.withResolvers
- Host: GitHub
- URL: https://github.com/es-shims/promise.withresolvers
- Owner: es-shims
- License: mit
- Created: 2023-07-11T14:07:08.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-22T21:59:22.000Z (over 1 year ago)
- Last Synced: 2025-09-16T16:13:30.849Z (20 days ago)
- Topics: defer, deferred, ecmascript, es-shims, javascript, polyfill, promise, shim, withresolvers
- Language: JavaScript
- Homepage: https://tc39.es/proposal-promise-with-resolvers/
- Size: 38.1 KB
- Stars: 8
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# promise.withresolvers [![Version Badge][npm-version-svg]][package-url]
[![github actions][actions-image]][actions-url]
[![coverage][codecov-image]][codecov-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url][![npm badge][npm-badge-png]][package-url]
ES proposal spec-compliant shim for Promise.withResolvers. Invoke its "shim" method to shim `Promise.withResolvers` if it is unavailable or noncompliant. **Note**: a global `Promise` must already exist: the [es6-shim](https://github.com/es-shims/es6-shim) is recommended.
This package implements the [es-shim API](https://github.com/es-shims/api) interface. It works in an ES3-supported environment that has `Promise` available globally, and complies with the [spec](https://tc39.es/proposal-promise-with-resolvers/).
Most common usage:
```js
var assert = require('assert');
var withResolvers = require('promise.withresolvers');var obj = withResolvers(Promise);
assert.equal(obj.promise instanceof Promise, true);
assert.equal(typeof obj.resolve, 'function');
assert.equal(typeof obj.reject, 'function');withResolvers.shim(); // will be a no-op if not needed
var obj2 = Promise.withResolvers();
assert.equal(obj2.promise instanceof Promise, true);
assert.equal(typeof obj2.resolve, 'function');
assert.equal(typeof obj2.reject, 'function');
```## Tests
Simply clone the repo, `npm install`, and run `npm test`[package-url]: https://npmjs.com/package/promise.withresolvers
[npm-version-svg]: https://versionbadg.es/es-shims/Promise.withResolvers.svg
[deps-svg]: https://david-dm.org/es-shims/Promise.withResolvers.svg
[deps-url]: https://david-dm.org/es-shims/Promise.withResolvers
[dev-deps-svg]: https://david-dm.org/es-shims/Promise.withResolvers/dev-status.svg
[dev-deps-url]: https://david-dm.org/es-shims/Promise.withResolvers#info=devDependencies
[npm-badge-png]: https://nodei.co/npm/promise.withresolvers.png?downloads=true&stars=true
[license-image]: https://img.shields.io/npm/l/promise.withresolvers.svg
[license-url]: LICENSE
[downloads-image]: https://img.shields.io/npm/dm/promise.withresolvers.svg
[downloads-url]: https://npm-stat.com/charts.html?package=promise.withresolvers
[codecov-image]: https://codecov.io/gh/es-shims/Promise.withResolvers/branch/main/graphs/badge.svg
[codecov-url]: https://app.codecov.io/gh/es-shims/Promise.withResolvers/
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/es-shims/Promise.withResolvers
[actions-url]: https://github.com/es-shims/Promise.withResolvers/actions