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

@teleology/fp

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@teleology/fp - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

lib/arrays.js

14

lib/filter.js

@@ -8,4 +8,16 @@ "use strict";

const filter = fn => src => Array.isArray(src) ? src.filter(fn) : [];
const {
objecToEquality
} = require('./arrays');
const filter = arg => src => {
let fn = arg;
if (typeof fn !== 'function') {
fn = objecToEquality(arg);
}
return Array.isArray(src) ? src.filter(fn) : [];
};
exports.filter = filter;

@@ -8,4 +8,16 @@ "use strict";

const find = fn => src => Array.isArray(src) ? src.find(fn) : undefined;
const {
objecToEquality
} = require('./arrays');
const find = arg => src => {
let fn = arg;
if (typeof fn !== 'function') {
fn = objecToEquality(arg);
}
return Array.isArray(src) ? src.find(fn) : undefined;
};
exports.find = find;

@@ -8,4 +8,16 @@ "use strict";

const map = fn => src => Array.isArray(src) ? src.map(fn) : src ? fn(src, 0, src) : undefined;
const {
pick
} = require('./pick');
const map = arg => src => {
let fn = arg;
if (Array.isArray(arg)) {
fn = pick(arg);
}
return Array.isArray(src) ? src.map(fn) : src ? fn(src, 0, src) : undefined;
};
exports.map = map;

2

package.json
{
"name": "@teleology/fp",
"version": "2.0.2",
"version": "2.0.3",
"description": "A small collection of functional programming utils",

@@ -5,0 +5,0 @@ "author": "Chris Sullivan <chrissullivan.dev@gmail.com>",

@@ -128,3 +128,21 @@ # @teleology/fp

## curry
Curry a specific function with a known [arity](https://en.wikipedia.org/wiki/Arity). Please note, optional arguments are not considered during invocation unless they are explicity set.
Example:
```javascript
const { curry } = require('@teleology/fp');
const test = (a, b, c) => console.log([a, b, c]);
const curried = curry(3, test);
// allows for flexibility
curried(1, 2, 3); // [1, 2, 3]
curried(1)(2)(3); // [1, 2, 3]
curried(1)(2, 3); // [1, 2, 3]
curried(1, 2)(3); // [1, 2, 3]
```
## map

@@ -146,21 +164,13 @@

]); // [ '1', '2' ]
```
## curry
Curry a specific function with a known [arity](https://en.wikipedia.org/wiki/Arity). Please note, optional arguments are not considered during invocation unless they are explicity set.
Example:
```javascript
const { curry } = require('@teleology/fp');
const test = (a, b, c) => console.log([a, b, c]);
const curried = curry(3, test);
// allows for flexibility
curried(1, 2, 3); // [1, 2, 3]
curried(1)(2)(3); // [1, 2, 3]
curried(1)(2, 3); // [1, 2, 3]
curried(1, 2)(3); // [1, 2, 3]
map(['id'])([
{
id: '1',
name: 'bob',
},
{
id: '2',
name: 'chris',
},
]) // [ { id: '1' }, { id: '2' } ]
```

@@ -184,2 +194,11 @@

]); // [ { id: '1' } ]
filter({ id: '1' })([
{
id: '1',
},
{
id: '2',
},
]); // [ { id: '1' } ]
```

@@ -204,5 +223,41 @@

]); // { id: '1' }
find({ id: '1' })([
{
id: '1',
},
{
id: '2',
},
]); // { id: '1' }
```
## some
A curried some function to be invoked within an Array.
Example:
```javascript
const { some } = require('@teleology/fp');
some((a) => a.id === '1')([
{
id: '1',
},
{
id: '2',
},
]); // true
some({ id: '1' })([
{
id: '1',
},
{
id: '2',
},
]); // true
```
## clean

@@ -209,0 +264,0 @@

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