New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

maybe-polyfill

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

maybe-polyfill

Promises for people afraid of commitment.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Maybe

Promises for those afraid of commitment. Maybe can be used just like Promise.

Browser Support

IE8+, Chrome, Firefox, IOS 4+, Safari 5+, Opera

Node

npm install maybe-polyfill

Bower

bower install maybe-polyfill

Simple use

var mayb = new Maybe(function(resolve, reject) {
  // do a thing, possibly async, then…

  if (/* everything turned out fine */) {
    resolve("Stuff worked!");
  }  else {
    reject(new Error("It broke"));
  }
});

// Do something when async done
maybe.then(function() {
  ...
});

Performance

By default maybe-polyfill uses setImmediate, but falls back to setTimeout for executing asynchronously. If a browser does not support setImmediate (IE/Edge are the only browsers with setImmediate), you may see performance issues. Use a setImmediate polyfill to fix this issue. setAsap or setImmediate work well.

If you polyfill window.setImmediate or use Maybe._setImmediateFn(immedateFn) it will be used instead of window.setTimeout

npm install setasap --save
var Maybe = require('maybe-polyfill');
var setAsap = require('setasap');
Maybe._setImmediateFn(setAsap);

Unhandled Rejections

maybe-polyfill will warn you about possibly unhandled rejections. It will show a console warning if a Maybe is rejected, but no .catch is used. You can turn off this behavior by setting Maybe._setUnhandledRejectionFn(<rejectError>). If you would like to disable unhandled rejections. Use a noop like below.

Maybe._setUnhandledRejectionFn(function(rejectError) {});

Testing

npm install
npm test

License

MIT

Keywords

FAQs

Package last updated on 20 Apr 2016

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