https://github.com/vilicvane/segmented
https://github.com/vilicvane/segmented
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/vilicvane/segmented
- Owner: vilicvane
- License: mit
- Created: 2024-02-19T11:20:24.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-19T11:25:27.000Z (over 1 year ago)
- Last Synced: 2025-03-24T00:54:54.556Z (3 months ago)
- Language: TypeScript
- Size: 61.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://www.npmjs.com/package/segmented)
[](./package.json)
[](./LICENSE)
[](https://discord.gg/wEVn2qcf8h)# Segmented
Segmented async operations to abort.
## Installation
```sh
npm install segmented
```## Usage
```ts
import {segment} from 'segmented';const segmented = segment(() => fetch('https://example.com'))
.then(response => response.json())
.then(console.log);segmented.abort();
```The `segmented` object returned is also an callable equivalent to `abort()` method:
```ts
import {segment} from 'segmented';useEffect(
() =>
segment(() => fetch('https://example.com'))
.then(response => response.json())
.then(console.log),
[],
);
```## License
MIT License.