🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
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
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
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

compose

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