GithubHelp home page GithubHelp logo

doodlewind / nativebird Goto Github PK

View Code? Open in Web Editor NEW
72.0 3.0 8.0 85 KB

🐦 Bluebird alternative within ~200 loc

JavaScript 100.00%
async bluebird promise promise-library promises-aplus javascript bluebird-promise

nativebird's Introduction

NativeBird

Ultralight promise extension compatible with Bluebird

logo

Introduction

中文介绍

As a pioneer in JavaScript async ecosystem, Bluebird is a great userland promise library with handy utility methods included. However the way it works leads to larger bundle size and more verbose stack trace.

NativeBird is compatible with a core Bluebird subset by extending native promise, and all of its extended APIs (implemented within ~200 lines) are fully tested with the corresponding test cases in Bluebird.

NativeBird can be used in several scenarios:

  • To reuse promise utility methods like Promise.map and Promise.each without copying snippets from a gist.
  • To perform migration in existing Bluebird projects.
  • To simply learn JavaScript async operation skills 🐶.

Installation

npm install nativebird
import Promise from "nativebird";

It's also fine to copy promise.mjs and its type definition directly into your project directory.

API

Since NativeBird inherits from native promise, all promise APIs defined in ECMAScript standard (say Promise.allSettled and Promise.any) are naturally supported.

Caveats

  • Promise.cancel is not supported.
  • Synchronous inspection (e.g. Promise.isFulfilled) is not supported.

Contribution

To implement a new API in Bluebird, please also port the corresponding test cases under test/mocha in Bluebird repo and test it with npm test.

License

MIT

nativebird's People

Contributors

doodlewind avatar hlg-facai avatar lionad-morotar avatar xlianghang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nativebird's Issues

Add a cjs version?

Though esm is the future of JavaScript, there are still many projects using cjs. If we can use nativebird in cjs (such as hexo - to drop bluebird) it would be fantastic.

If you like I can send a pr.

Tree shaking support

Not sure if this is required for the ~200 LOC size, but can be useful if we want it to scale.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.