0.6.1 • Published 5 years ago
@elementary/proper v0.6.1
Proper
Play with Object Properties
Example
Low Level API
import { getProp } from '@elementary/proper';
const dumas = {
object: {
deepObject: {
musketeers: 3,
},
},
};
// With Map
compose(
map(map(getProp('musketeers'))),
map(getProp('deepObject')),
getProp('object'),
)(dumas)
.get()
.get()
.get(); //=> 3
// With Chain
compose(
chain(getProp('musketeers')),
chain(getProp('deepObject')),
chain(getProp('object')),
)(Maybe(dumas)).get(); //=> 3
High Level API
import { access } from '@elementary/proper';
const dumas = {
object: {
deepObject: {
musketeers: 3,
},
},
};
access('object.deepObject.musketeers')(dumas); //=> 3
access('object.deepObject.samurais')(dumas); //=> null
access('object.noObject.musketeers')(dumas); //=> null
Also includes omit
and pick
functions from Ramda
v 0.2.0
first
, last
and range
first([1, 2, 3]); //=> 1
last([1, 2, 3]); //=> 3
range(3, 8); //=> [3, 4, 5, 6, 7]
v 0.2.1
flatMap
flatMap(x => x.concat(1), [[1, 2], [3, 4]]); //=> [1, 2, 1, 3, 4, 1]
binder
Merge multiple functions to one
binder()
.add(flatMap(x => x.concat(1)))
.add(first)
.invoke([[1, 2], [3, 4]]);
0.6.1
5 years ago
0.6.1-alpha.8
5 years ago
0.6.1-alpha.7
5 years ago
0.6.1-alpha.6
5 years ago
0.6.1-alpha.5
5 years ago
0.6.1-alpha.4
5 years ago
0.6.1-alpha.3
5 years ago
0.6.1-alpha.2
5 years ago
0.6.1-alpha.1
5 years ago
0.6.1-alpha.0
5 years ago
0.2.5
5 years ago
0.2.4
5 years ago
0.2.3
5 years ago
0.2.2
6 years ago
0.2.1
6 years ago
0.2.0
6 years ago
0.1.7
6 years ago
0.1.6
6 years ago
0.1.5
6 years ago
0.1.4
6 years ago
0.1.3
6 years ago
0.1.2
6 years ago
0.1.1
6 years ago
0.1.0
6 years ago