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

unless-async

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

unless-async

Async unless conditional flow.

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

UnlessAsync

Async unless conditional flow inspired by Ruby.

Node 6+

Why?

Because programming is fun, and implementing what you think you know shows you what you've yet to learn.

Installation

npm i -S unless-async

Usage

const unless = require('unless-async');

const foo = false;
unless(foo, () => console.log('Foo is false so I am called!'));

const bar = true;
unless(bar, () => console.log('Bar is true so I am NOT called!'));

unless(user.isAuthenticated(), () => authenticate(user))
.then(() => {
  return mail.send(user.email);
});

const isAdmin = User.find(params.userId).then(u => u.isAdmin);

return unless(isAdmin, () => {
  throw new Error('Forbidden');
})
.then(() => Message.find(params));

API

unless(
  Promise<any>|boolean condition,
  function action
) -> Promise

Creates a promise that is resolved with the given action function when false, otherwise resolves undefined.

Test

npm test

License

MIT

Keywords

FAQs

Package last updated on 20 Jan 2017

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