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

fn-compose

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fn-compose - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

16

index.js
var maybe = require('maybe-args');
module.exports = maybe(compose);
var slice = Array.prototype.slice;
function compose(){
var args = Array.prototype.slice.call(arguments);
var compose = maybe(function (){
var args = slice.call(arguments);

@@ -12,4 +12,8 @@ if(args.length === 1) return args[0];

return _compose(args.shift(), compose.apply(this, args));
}
})
compose.ltr = function() {
return compose.apply(compose, slice.call(arguments).reverse());
};
function _compose(fn2, fn1){

@@ -19,2 +23,4 @@ return function(arg){

};
}
}
module.exports = compose;
{
"name": "fn-compose",
"version": "1.0.1",
"version": "1.1.0",
"description": "compose an arbitrary number of functions from right to left.",

@@ -22,3 +22,3 @@ "main": "index.js",

"type": "git",
"url": "https://github.com/wilhelmson/fn-compose.git"
"url": "https://github.com/thunklife/fn-compose.git"
},

@@ -25,0 +25,0 @@ "readmeFilename": "README.md",

fn-compose
=============
A simple function to compose an arbitrary number of functions from right to left.
A simple function to compose an arbitrary number of functions from right to left,
or left to right.

@@ -16,3 +17,3 @@ install

```
```js
var compose = require('fn-compose'),

@@ -24,3 +25,13 @@ mul2 = function mul2(a){ return a * 2 },

mul2Sub1(5); //=> 9
```
There is also a left to right mode, which is exported as `ltr`:
```js
var compose = require('fn-compose').ltr, // Notice the .ltr
mul2 = function mul2(a){ return a * 2 },
sub1 = function sub1(a){ return a - 1 },
mul2Sub1 = compose(sub1, mul2);
mul2Sub1(5); //=> 8
```

@@ -27,0 +38,0 @@

@@ -32,2 +32,10 @@ var test = require('tap').test,

test('should can compose ltr as well', function(t){
t.plan(1);
var mul = function mul2(a){ return a * 2 },
sub = function sub1(a){ return a - 1 },
composed = compose.ltr(sub, mul),
result = composed(5);
t.equals(result, 8);
})
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