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

arbitrary-promise

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arbitrary-promise

ArbitraryPromise is a simple Promise library that allows you to make your own arbitrarily named resolve/then functions.

  • 1.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

arbitrary-promise

ArbitraryPromise is a simple Promise library that allows you to make your own arbitrarily named resolve/then functions.

Travis Codecov npm

Examples

Go with a classic:

import ArbitraryPromise from 'arbitrary-promise'

const promise = new ArbitraryPromise([['resolve', 'then']])

promise.then(console.log)
promise.resolve('Mathematical!')

-> Mathematical!

Or, spice it up with what this library provides, customization!

import ArbitraryPromise from 'arbitrary-promise'

const promise = new ArbitraryPromise([['handleData', 'onData']])

promise.onData(console.log)
promise.handleData('Whoa! Algebraic!')

-> Whoa! Algebraic!

Of course, the promise will also work in reverse order, it being a promise and all:

import ArbitraryPromise from 'arbitrary-promise'

const promise = new ArbitraryPromise([['handleData', 'onData']])

promise.handleData('Whoa! Algebraic!')
promise.onData(console.log)

-> Whoa! Algebraic!

Unless, that is, you don't want it to:

import ArbitraryPromise from 'arbitrary-promise'

const promise = new ArbitraryPromise([['handleData', 'onData']], false)

promise.handleData('Whoa! Algebraic!')
promise.onData(console.log)

-> Zilch.

Check out the tests for all the info, of which there is not much more than what you already know :)

Keywords

FAQs

Package last updated on 27 Sep 2018

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