Skip to content

Commit c6660f5

Browse files
authored
fix: update project config (#99)
Updates project config and ci files
1 parent e43efdf commit c6660f5

7 files changed

+102
-70
lines changed

.github/dependabot.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ updates:
55
schedule:
66
interval: daily
77
time: "10:00"
8-
open-pull-requests-limit: 10
8+
open-pull-requests-limit: 20
99
commit-message:
1010
prefix: "deps"
1111
prefix-development: "deps(dev)"

.github/workflows/js-test-and-release.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,20 @@ on:
99

1010
permissions:
1111
contents: write
12+
id-token: write
1213
packages: write
14+
pull-requests: write
1315

1416
concurrency:
1517
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }}
1618
cancel-in-progress: true
1719

1820
jobs:
1921
js-test-and-release:
20-
uses: pl-strflt/uci/.github/workflows/js-test-and-release.yml@v0.0
22+
uses: ipdxco/unified-github-workflows/.github/workflows/js-test-and-release.yml@v1.0
2123
secrets:
2224
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
2325
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
2426
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
2527
UCI_GITHUB_TOKEN: ${{ secrets.UCI_GITHUB_TOKEN }}
28+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Semantic PR
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- edited
8+
- synchronize
9+
10+
jobs:
11+
main:
12+
uses: pl-strflt/.github/.github/workflows/[email protected]

.github/workflows/stale.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Close and mark stale issue
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *'
6+
7+
permissions:
8+
issues: write
9+
pull-requests: write
10+
11+
jobs:
12+
stale:
13+
uses: pl-strflt/.github/.github/workflows/[email protected]

README.md

+61-64
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,81 @@
1-
# abortable-iterator <!-- omit in toc -->
1+
# abortable-iterator
22

33
[![codecov](https://img.shields.io/codecov/c/github/alanshaw/abortable-iterator.svg?style=flat-square)](https://codecov.io/gh/alanshaw/abortable-iterator)
44
[![CI](https://img.shields.io/github/actions/workflow/status/alanshaw/abortable-iterator/js-test-and-release.yml?branch=master\&style=flat-square)](https://github.com/alanshaw/abortable-iterator/actions/workflows/js-test-and-release.yml?query=branch%3Amaster)
55

66
> Make any iterator or iterable abortable via an AbortSignal
77
8-
## Table of contents <!-- omit in toc -->
9-
10-
- [Install](#install)
11-
- [Browser `<script>` tag](#browser-script-tag)
12-
- [Usage](#usage)
13-
- [API](#api)
14-
- [`abortableSource(source, signal, [options])`](#abortablesourcesource-signal-options)
15-
- [Parameters](#parameters)
16-
- [Returns](#returns)
17-
- [`abortableSink(sink, signal, [options])`](#abortablesinksink-signal-options)
18-
- [`abortableTransform(transform, signal, [options])`](#abortabletransformtransform-signal-options)
19-
- [`abortableDuplex(duplex, signal, [options])`](#abortableduplexduplex-signal-options)
20-
- [Related](#related)
21-
- [Contribute](#contribute)
22-
- [API Docs](#api-docs)
23-
- [License](#license)
24-
- [Contribution](#contribution)
25-
26-
## Install
8+
# About
279

28-
```console
29-
$ npm i abortable-iterator
30-
```
10+
<!--
3111
32-
### Browser `<script>` tag
12+
!IMPORTANT!
3313
34-
Loading this module through a script tag will make it's exports available as `AbortableIterator` in the global namespace.
14+
Everything in this README between "# About" and "# Install" is automatically
15+
generated and will be overwritten the next time the doc generator is run.
3516
36-
```html
37-
<script src="https://unpkg.com/abortable-iterator/dist/index.min.js"></script>
38-
```
17+
To make changes to this section, please update the @packageDocumentation section
18+
of src/index.js or src/index.ts
3919
40-
The [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) is used in the fetch API to abort in flight requests from, for example, a timeout or user action. The same concept is used here to halt iteration of an async iterator.
20+
To experiment with formatting, please run "npm run docs" from the root of this
21+
repo and examine the changes made.
4122
42-
## Usage
23+
-->
24+
25+
## Example
4326

4427
```js
4528
import { abortableSource } from 'abortable-iterator'
4629

47-
// An example function that creates an async iterator that yields an increasing
48-
// number every x milliseconds and NEVER ENDS!
49-
const asyncCounter = async function * (start, delay) {
50-
let i = start
51-
while (true) {
52-
yield new Promise(resolve => setTimeout(() => resolve(i++), delay))
30+
async function main () {
31+
// An example function that creates an async iterator that yields an increasing
32+
// number every x milliseconds and NEVER ENDS!
33+
const asyncCounter = async function * (start, delay) {
34+
let i = start
35+
while (true) {
36+
yield new Promise(resolve => setTimeout(() => resolve(i++), delay))
37+
}
38+
}
39+
40+
// Create a counter that'll yield numbers from 0 upwards every second
41+
const everySecond = asyncCounter(0, 1000)
42+
43+
// Make everySecond abortable!
44+
const controller = new AbortController()
45+
const abortableEverySecond = abortableSource(everySecond, controller.signal)
46+
47+
// Abort after 5 seconds
48+
setTimeout(() => controller.abort(), 5000)
49+
50+
try {
51+
// Start the iteration, which will throw after 5 seconds when it is aborted
52+
for await (const n of abortableEverySecond) {
53+
console.log(n)
54+
}
55+
} catch (err) {
56+
if (err.code === 'ERR_ABORTED') {
57+
// Expected - all ok :D
58+
} else {
59+
throw err
60+
}
5361
}
5462
}
5563

56-
// Create a counter that'll yield numbers from 0 upwards every second
57-
const everySecond = asyncCounter(0, 1000)
64+
main()
65+
```
66+
67+
# Install
5868

59-
// Make everySecond abortable!
60-
const controller = new AbortController()
61-
const abortableEverySecond = abortableSource(everySecond, controller.signal)
69+
```console
70+
$ npm i abortable-iterator
71+
```
6272

63-
// Abort after 5 seconds
64-
setTimeout(() => controller.abort(), 5000)
73+
## Browser `<script>` tag
6574

66-
try {
67-
// Start the iteration, which will throw after 5 seconds when it is aborted
68-
for await (const n of abortableEverySecond) {
69-
console.log(n)
70-
}
71-
} catch (err) {
72-
if (err.code === 'ERR_ABORTED') {
73-
// Expected - all ok :D
74-
} else {
75-
throw err
76-
}
77-
}
75+
Loading this module through a script tag will make its exports available as `AbortableIterator` in the global namespace.
76+
77+
```html
78+
<script src="https://unpkg.com/abortable-iterator/dist/index.min.js"></script>
7879
```
7980

8081
## API
@@ -138,21 +139,17 @@ Note that this will abort *both* sides of the duplex. Use `duplex.sink = abortab
138139

139140
- [`it-pipe`](https://www.npmjs.com/package/it-pipe) Utility to "pipe" async iterables together
140141

141-
## Contribute
142-
143-
Feel free to dive in! [Open an issue](https://github.com/alanshaw/abortable-iterator/issues/new) or submit PRs.
144-
145-
## API Docs
142+
# API Docs
146143

147144
- <https://alanshaw.github.io/abortable-iterator>
148145

149-
## License
146+
# License
150147

151148
Licensed under either of
152149

153-
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
154-
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
150+
- Apache 2.0, ([LICENSE-APACHE](https://github.com/alanshaw/abortable-iterator/LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
151+
- MIT ([LICENSE-MIT](https://github.com/alanshaw/abortable-iterator/LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
155152

156-
## Contribution
153+
# Contribution
157154

158155
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

package.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
"bugs": {
1313
"url": "https://github.com/alanshaw/abortable-iterator/issues"
1414
},
15+
"publishConfig": {
16+
"access": "public",
17+
"provenance": true
18+
},
1519
"keywords": [
1620
"AbortController",
1721
"AbortSignal",
@@ -23,10 +27,6 @@
2327
"signal",
2428
"stop"
2529
],
26-
"engines": {
27-
"node": ">=16.0.0",
28-
"npm": ">=7.0.0"
29-
},
3030
"type": "module",
3131
"types": "./dist/src/index.d.ts",
3232
"typesVersions": {
@@ -64,6 +64,7 @@
6464
"eslintConfig": {
6565
"extends": "ipfs",
6666
"parserOptions": {
67+
"project": true,
6768
"sourceType": "module"
6869
}
6970
},

typedoc.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"entryPoints": [
3+
"./src/index.ts",
4+
"./src/duplex.ts"
5+
]
6+
}

0 commit comments

Comments
 (0)