Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

avow

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

avow

Example Promises/A+ implementation. Simple, tiny, fast, fully async

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
decreased by-53.85%
Maintainers
1
Weekly downloads
 
Created
Source

avow

Avow is a very tiny, very fast, fully asynchronous Promises/A+ implementation, and passes the Promises/A+ Test Suite.

It is less than 150 lines of code (sans comments and UMD boilerplate), less than 500 bytes when closured+gzipped, and in very limited testing appears to be as fast as or faster than most other synchronous implementations in environments where a fast nextTick is available. It uses process.nextTick or setImmediate if available (you can use NobleJS's setImmediate polyfill), and will fall back to setTimeout (srsly, use the polyfill) otherwise.

Why?

I wrote avow as a stripped-down test bed for new ideas for when.js, cujo.js's full-featured promise implementation. I also hope that it serves as a simple example implementation for others who might want to implement promises either as a learning exercise, or as a part of a project/library/framework.

Can I use it?

Yes, but you shouldn't. You should try when.js instead. It is even faster (although currently its resolutions are synchronous), and provides many more features, like dealing with collections of promises, competitive races, and timed promises.

Should I use it?

Again, probably not. I have no plans to support it in any way. I'll probably change the API without warning. You're on your own.

Ok, ok, if you want to try it out

Download it, clone it, or npm install git://github.com/briancavalier/avow.git

The API

var avow = require('avow');

// Create a pending promise
var vow = avow();

// Fulfill it
vow.fulfill(value);

// Or reject it
vow.reject(reason);

// Create a fulfilled promise
vow = avow.fulfilled(value);

// Create a rejected promise
vow = avow.rejected(reason);

Make your own

You can make your own custom configured instance of avow:

var myAvow = require('avow').construct(options);

Where options is an object that can have any of the following properties:

  • nextTick - specify your own nextTick function
  • unhandled - callback to be notified when an unhandled rejection reaches the end of a promise chain.
  • protect - function that is called on every promise avow creates, to give you a chance to protect it, e.g. by supplying Object.freeze() here.

Running the tests

  1. npm install
  2. npm test

License

MIT License, Copyright (c) 2012 Brian Cavalier

Keywords

FAQs

Package last updated on 10 Nov 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc