Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vilicvane/segmented
https://github.com/vilicvane/segmented
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/vilicvane/segmented
- Owner: vilicvane
- License: mit
- Created: 2024-02-19T11:20:24.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-02-19T11:25:27.000Z (11 months ago)
- Last Synced: 2024-11-30T15:42:01.471Z (about 1 month 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
[![NPM version](https://img.shields.io/npm/v/segmented?color=%23cb3837&style=flat-square)](https://www.npmjs.com/package/segmented)
[![Repository package.json version](https://img.shields.io/github/package-json/v/vilicvane/segmented?color=%230969da&label=repo&style=flat-square)](./package.json)
[![MIT License](https://img.shields.io/badge/license-MIT-999999?style=flat-square)](./LICENSE)
[![Discord](https://img.shields.io/badge/chat-discord-5662f6?style=flat-square)](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.