Skip to content

isuvorov/fishbird

Repository files navigation

Fishbird

NPM version Tests Install size Bundle size License Ask me in Telegram

Fishbird is a simple, lightweight, and fast Promise utility library.

  • Small. Less 1Kb (minified and gzipped). No dependencies.
  • Fast. Its 2 times faster than Bluebird by benchmarkes.
  • ES modules and tree-shaking support.
  • TypeScript friendly.
  • Portable Supports modern browsers, IE with Babel, Node.js and React Native.
  • Compatible with Bluebird API.
import { map } from 'fishbird';

const res = map([1 ,2, 3], async (id) => {
  const res = await fetch(id);
  return res.json();
});

Installation

npm i fishbird
yarn i fishbird
pnpm i fishbird

Usage

map

import { map } from 'fishbird';

const res = map([1 ,2, 3], async (id) => {
  const res = await fetch(id);
  return res.json();
});

// map with concurrency

const res2 = map([1 ,2, 3], async (id) => {
  const res = await fetch(id);
  return res.json();
}, { concurrency: 2 });

props

import { props } from 'fishbird';
const users = {
  john: { id: 1 },
  bob: { id: 2 },
  alice: { id: 3 },
}
const res = await props(users, async ({ id }) => {
  const res = await fetch(id);
  return res.json();
});

// res = {
//   john: { name: 'John', ... },
//   bob: { name: 'Bob', ... },
//   alice: { name: 'Alice', ... },
// }


// Props with concurrency and Map
const users2 = new Map([
  ['john', { name: 'John' }],
  ['bob', { name: 'Bob' }],
  ['alice', { name: 'Alice' }],
]);
const res = await props(users, async (user) => {
  const res = await fetch(user.name);
  return res.json();
}, { concurrency: 2 });

Inspired by

About

Fishbird is a simple, lightweight, and fast Promise utility library

Resources

License

Stars

Watchers

Forks

Packages

No packages published