This repository has been archived by the owner on Jan 22, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 930
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created
@solana/promises
and moved getAbortablePromise
into it
- Loading branch information
1 parent
6c4e3ba
commit e327607
Showing
17 changed files
with
170 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@solana/promises': patch | ||
--- | ||
|
||
Created a package for dealing with JavaScript Promises, and copied the implementation of `getAbortablePromise` into it |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# @solana/promises |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright (c) 2023 Solana Labs, Inc | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
[![npm][npm-image]][npm-url] | ||
[![npm-downloads][npm-downloads-image]][npm-url] | ||
[![semantic-release][semantic-release-image]][semantic-release-url] | ||
<br /> | ||
[![code-style-prettier][code-style-prettier-image]][code-style-prettier-url] | ||
|
||
[code-style-prettier-image]: https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square | ||
[code-style-prettier-url]: https://github.com/prettier/prettier | ||
[npm-downloads-image]: https://img.shields.io/npm/dm/@solana/promises/rc.svg?style=flat | ||
[npm-image]: https://img.shields.io/npm/v/@solana/promises/rc.svg?style=flat | ||
[npm-url]: https://www.npmjs.com/package/@solana/promises/v/rc | ||
[semantic-release-image]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg | ||
[semantic-release-url]: https://github.com/semantic-release/semantic-release | ||
|
||
# @solana/promises | ||
|
||
This package contains helpers for using JavaScript promises. | ||
|
||
## Functions | ||
|
||
### `getAbortablePromise(promise, abortSignal?)` | ||
|
||
Rejects if the `abortSignal` is aborted before the promise settles. Resolves or rejects with the value of the promise otherwise. | ||
|
||
```ts | ||
const result = await getAbortablePromise( | ||
// Resolves or rejects when `fetch` settles. | ||
fetch('https://example.com/json').then(r => r.json()), | ||
// ...unless it takes longer than 5 seconds, after which the `AbortSignal` is triggered. | ||
AbortSignal.timeout(5000), | ||
); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
{ | ||
"name": "@solana/promises", | ||
"version": "2.0.0-rc.0", | ||
"description": "Helpers for using JavaScript promises", | ||
"exports": { | ||
"browser": { | ||
"import": "./dist/index.browser.mjs", | ||
"require": "./dist/index.browser.cjs" | ||
}, | ||
"node": { | ||
"import": "./dist/index.node.mjs", | ||
"require": "./dist/index.node.cjs" | ||
}, | ||
"react-native": "./dist/index.native.mjs", | ||
"types": "./dist/types/index.d.ts" | ||
}, | ||
"browser": { | ||
"./dist/index.node.cjs": "./dist/index.browser.cjs", | ||
"./dist/index.node.mjs": "./dist/index.browser.mjs" | ||
}, | ||
"main": "./dist/index.node.cjs", | ||
"module": "./dist/index.node.mjs", | ||
"react-native": "./dist/index.native.mjs", | ||
"types": "./dist/types/index.d.ts", | ||
"type": "commonjs", | ||
"files": [ | ||
"./dist/" | ||
], | ||
"sideEffects": false, | ||
"keywords": [ | ||
"blockchain", | ||
"solana", | ||
"web3" | ||
], | ||
"scripts": { | ||
"compile:js": "tsup --config build-scripts/tsup.config.package.ts", | ||
"compile:typedefs": "tsc -p ./tsconfig.declarations.json", | ||
"dev": "jest -c ../../node_modules/@solana/test-config/jest-dev.config.ts --rootDir . --watch", | ||
"prepublishOnly": "pnpm pkg delete devDependencies", | ||
"publish-impl": "npm view $npm_package_name@$npm_package_version > /dev/null 2>&1 || pnpm publish --tag ${PUBLISH_TAG:-canary} --access public --no-git-checks", | ||
"publish-packages": "pnpm prepublishOnly && pnpm publish-impl", | ||
"style:fix": "pnpm eslint --fix src/* && pnpm prettier --log-level warn --ignore-unknown --write ./*", | ||
"test:lint": "TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@solana/test-config/jest-lint.config.ts --rootDir . --silent", | ||
"test:prettier": "TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@solana/test-config/jest-prettier.config.ts --rootDir . --silent", | ||
"test:treeshakability:browser": "agadoo dist/index.browser.mjs", | ||
"test:treeshakability:native": "agadoo dist/index.native.mjs", | ||
"test:treeshakability:node": "agadoo dist/index.node.mjs", | ||
"test:typecheck": "tsc --noEmit", | ||
"test:unit:browser": "TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@solana/test-config/jest-unit.config.browser.ts --rootDir . --silent", | ||
"test:unit:node": "TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@solana/test-config/jest-unit.config.node.ts --rootDir . --silent" | ||
}, | ||
"author": "Solana Labs Maintainers <[email protected]>", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/solana-labs/solana-web3.js" | ||
}, | ||
"bugs": { | ||
"url": "http://github.com/solana-labs/solana-web3.js/issues" | ||
}, | ||
"browserslist": [ | ||
"supports bigint and not dead", | ||
"maintained node versions" | ||
], | ||
"peerDependencies": { | ||
"typescript": ">=5" | ||
}, | ||
"bundlewatch": { | ||
"defaultCompression": "gzip", | ||
"files": [ | ||
{ | ||
"path": "./dist/index*.js" | ||
} | ||
] | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...t/src/__tests__/abortable-promise-test.ts → .../promises/src/__tests__/abortable-test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './abortable'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"declaration": true, | ||
"declarationMap": true, | ||
"emitDeclarationOnly": true, | ||
"outDir": "./dist/types" | ||
}, | ||
"extends": "./tsconfig.json", | ||
"include": ["src/index.ts", "src/types"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/tsconfig", | ||
"compilerOptions": { | ||
"lib": ["DOM", "ES2015"] | ||
}, | ||
"display": "@solana/promises", | ||
"extends": "../tsconfig/base.json", | ||
"include": ["src"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.