Skip to content

Commit

Permalink
fix: update project config (#99)
Browse files Browse the repository at this point in the history
Updates project config and ci files
  • Loading branch information
achingbrain authored Aug 7, 2024
1 parent e43efdf commit c6660f5
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ updates:
schedule:
interval: daily
time: "10:00"
open-pull-requests-limit: 10
open-pull-requests-limit: 20
commit-message:
prefix: "deps"
prefix-development: "deps(dev)"
5 changes: 4 additions & 1 deletion .github/workflows/js-test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,20 @@ on:

permissions:
contents: write
id-token: write
packages: write
pull-requests: write

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

jobs:
js-test-and-release:
uses: pl-strflt/uci/.github/workflows/js-test-and-release.yml@v0.0
uses: ipdxco/unified-github-workflows/.github/workflows/js-test-and-release.yml@v1.0
secrets:
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
UCI_GITHUB_TOKEN: ${{ secrets.UCI_GITHUB_TOKEN }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
12 changes: 12 additions & 0 deletions .github/workflows/semantic-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Semantic PR

on:
pull_request_target:
types:
- opened
- edited
- synchronize

jobs:
main:
uses: pl-strflt/.github/.github/workflows/[email protected]
13 changes: 13 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Close and mark stale issue

on:
schedule:
- cron: '0 0 * * *'

permissions:
issues: write
pull-requests: write

jobs:
stale:
uses: pl-strflt/.github/.github/workflows/[email protected]
125 changes: 61 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,80 +1,81 @@
# abortable-iterator <!-- omit in toc -->
# abortable-iterator

[![codecov](https://img.shields.io/codecov/c/github/alanshaw/abortable-iterator.svg?style=flat-square)](https://codecov.io/gh/alanshaw/abortable-iterator)
[![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)

> Make any iterator or iterable abortable via an AbortSignal
## Table of contents <!-- omit in toc -->

- [Install](#install)
- [Browser `<script>` tag](#browser-script-tag)
- [Usage](#usage)
- [API](#api)
- [`abortableSource(source, signal, [options])`](#abortablesourcesource-signal-options)
- [Parameters](#parameters)
- [Returns](#returns)
- [`abortableSink(sink, signal, [options])`](#abortablesinksink-signal-options)
- [`abortableTransform(transform, signal, [options])`](#abortabletransformtransform-signal-options)
- [`abortableDuplex(duplex, signal, [options])`](#abortableduplexduplex-signal-options)
- [Related](#related)
- [Contribute](#contribute)
- [API Docs](#api-docs)
- [License](#license)
- [Contribution](#contribution)

## Install
# About

```console
$ npm i abortable-iterator
```
<!--
### Browser `<script>` tag
!IMPORTANT!
Loading this module through a script tag will make it's exports available as `AbortableIterator` in the global namespace.
Everything in this README between "# About" and "# Install" is automatically
generated and will be overwritten the next time the doc generator is run.
```html
<script src="https://unpkg.com/abortable-iterator/dist/index.min.js"></script>
```
To make changes to this section, please update the @packageDocumentation section
of src/index.js or src/index.ts
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.
To experiment with formatting, please run "npm run docs" from the root of this
repo and examine the changes made.
## Usage
-->

## Example

```js
import { abortableSource } from 'abortable-iterator'

// An example function that creates an async iterator that yields an increasing
// number every x milliseconds and NEVER ENDS!
const asyncCounter = async function * (start, delay) {
let i = start
while (true) {
yield new Promise(resolve => setTimeout(() => resolve(i++), delay))
async function main () {
// An example function that creates an async iterator that yields an increasing
// number every x milliseconds and NEVER ENDS!
const asyncCounter = async function * (start, delay) {
let i = start
while (true) {
yield new Promise(resolve => setTimeout(() => resolve(i++), delay))
}
}

// Create a counter that'll yield numbers from 0 upwards every second
const everySecond = asyncCounter(0, 1000)

// Make everySecond abortable!
const controller = new AbortController()
const abortableEverySecond = abortableSource(everySecond, controller.signal)

// Abort after 5 seconds
setTimeout(() => controller.abort(), 5000)

try {
// Start the iteration, which will throw after 5 seconds when it is aborted
for await (const n of abortableEverySecond) {
console.log(n)
}
} catch (err) {
if (err.code === 'ERR_ABORTED') {
// Expected - all ok :D
} else {
throw err
}
}
}

// Create a counter that'll yield numbers from 0 upwards every second
const everySecond = asyncCounter(0, 1000)
main()
```

# Install

// Make everySecond abortable!
const controller = new AbortController()
const abortableEverySecond = abortableSource(everySecond, controller.signal)
```console
$ npm i abortable-iterator
```

// Abort after 5 seconds
setTimeout(() => controller.abort(), 5000)
## Browser `<script>` tag

try {
// Start the iteration, which will throw after 5 seconds when it is aborted
for await (const n of abortableEverySecond) {
console.log(n)
}
} catch (err) {
if (err.code === 'ERR_ABORTED') {
// Expected - all ok :D
} else {
throw err
}
}
Loading this module through a script tag will make its exports available as `AbortableIterator` in the global namespace.

```html
<script src="https://unpkg.com/abortable-iterator/dist/index.min.js"></script>
```

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

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

## Contribute

Feel free to dive in! [Open an issue](https://github.com/alanshaw/abortable-iterator/issues/new) or submit PRs.

## API Docs
# API Docs

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

## License
# License

Licensed under either of

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

## Contribution
# Contribution

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.
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
"bugs": {
"url": "https://github.com/alanshaw/abortable-iterator/issues"
},
"publishConfig": {
"access": "public",
"provenance": true
},
"keywords": [
"AbortController",
"AbortSignal",
Expand All @@ -23,10 +27,6 @@
"signal",
"stop"
],
"engines": {
"node": ">=16.0.0",
"npm": ">=7.0.0"
},
"type": "module",
"types": "./dist/src/index.d.ts",
"typesVersions": {
Expand Down Expand Up @@ -64,6 +64,7 @@
"eslintConfig": {
"extends": "ipfs",
"parserOptions": {
"project": true,
"sourceType": "module"
}
},
Expand Down
6 changes: 6 additions & 0 deletions typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"entryPoints": [
"./src/index.ts",
"./src/duplex.ts"
]
}

0 comments on commit c6660f5

Please sign in to comment.