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

compose-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

compose-async

Compose with promise support

  • 0.0.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

compose-async

Like compose, but functions can return Promises

var composeAsync = require('compose-async');

var deleteFriends = composeAsync(deleteUsersFriends, findUserById);

deleteFriends(3453).then((deletedFriends) => /* ... */);

var composeAsync = require('compose-async');

function reverse(srt) {
  return str.split('').reverse().join('');
}

function nl2br(str) {
  return str.replace(/\n/g, '<br />');
}

function fetchLinkTitles(str) {
  // Async magic
  return new Promise(function(resolve, reject) {
    resolve(str.replace(
      /https?:\/\/\S+/g,
      'California man bitten while taking selfie with rattlesnake'
    ));
  });
}

const defaultTextFormatter = composeAsync(nl2br, fetchLinkTitles, reverse);

defaultTextFormatter('hello everyone check this site out https://www.reddit.com/').then(function(formatted) {
  console.log(formatted); // ekanselttar htiw eifles gnikat elihw nettib nam ainrofilaC tuo etis siht kcehc enoyreve olleh
});

Keywords

FAQs

Package last updated on 29 Aug 2015

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