Skip to content

vilicvane/segmented

Repository files navigation

NPM version Repository package.json version MIT License Discord

Segmented

Segmented async operations to abort.

Installation

npm install segmented

Usage

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:

import {segment} from 'segmented';

useEffect(
  () =>
    segment(() => fetch('https://example.com'))
      .then(response => response.json())
      .then(console.log),
  [],
);

License

MIT License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published