The idempotent function.
v
any
Returns any the parameter v
.
Convert fun
to an unary function.
fun
Returns Function
Biding function fun
with arguments fellow it.
fun
Function This is the function whos parameters you want to bind.args
…*any* The values you bind to the parameters offun
.
Return Function.
The length of return function is fun.length - args.length
,
if args
are all normal values, when args
includes placeholder _
,
the length will add the count of placeholders.
The place holder that can be use zero or manny times as element of args
in binding(fun,...args)
.
Compose functions fns
to make a new function.
<div>f ∘ g = f(g(x))</div>
Read as “f of g” or “f after g”.
Means f
after g
to run, or f
is function of value of g
.
fns
Function The functions you want to compose them to be one.
Returns Function
pipe
is like the compose
but reverse the execute order.
It is differtne with pipable
. pipable
make a functor.
fns
…Function
Returns Function
Convert a method to a function.
If you have a function fn
you can attch it to a object obj
like
obj.fn=fn
, so the this
in fn
now is obj
.
But how do you do if you want use a method as a function? Like sort arrays with a fixed way?
m2f
is use to help you for this.
method
Function The method you want covert to a function.
Returns Function.
The return function do same as md
, but add this
as the first parameter.
Deep copy the value
.
v
any$1
Object (optional, default{}
)$1.freeze
(optional, defaultfalse
)
Returns a new deep Copyed Object.
Give a value, get a function, which always return freezen deep copy of the given value.
If you just want get a immutable copy, just use
deepCopy(value,{freeze:true})
.
value
any
Returns Function : ()=>freezenDeepCopyOfValue
Note:This is the package of @keepzen/pipe.js
, and in package of @keepzen/fp
rexport
as Pipable
. So the snippets in this section, Pipe
, pipe
, from
, and -
are all in namespace of Pipable
.
Negative fun
.
If fun
is a predicater, return a new negative predicater.
If fun
is a compare function, return the negative compare function.
fun
Function :~(v,…args)=>Boolean|Number~
Returns Function other_fun: (v,...args)=>Boolean|Number
select some array with predicate
.
Support there is an array
include value v
, and predicate(v)
is true,
then select(array)
will include v
.
predicate
Function (v,index)=>Boolean;
Returns Function select: (array)=>array
Reject some array with predicate
.
Support there is an array
include value v
,and predicate(v)
is true,
then reject(array)
will **not** include v
.
predicate
Function : (v,index)=>Boolean;
Returns Function reject:(array)=>array
Order a array with a compare
function.
When asc
is true
, sort value in ascending order else in descending.
For compare(a,b)
, in asc order,
if you want a
in front of b
, return a negative number;
if your want b
in front of a
return a positive number;
else you do not care which first return zero.
compare
Function :~(a,b)=>Boolean~ (optional, default(a,b)=>a-b
)$1
Object (optional, default{}
)$1.asc
(optional, defaulttrue
)
Returns Function order:(array)=>array
Get a reversed new the array from array
.
array
Array
Returns Array
Zip arrays a1
and a2
to an array of array.
Returns Array Array<Array(2)>
Check is every
element in iteratble
satisfy contiontion fun
.
If iterable
is empty, return true
. See more at
[here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every*Description);
fun
Function :~(element[,index,array])~iterable
**Iterable**
Returns **any** boolean
Check is all
element in iteratble
satisfy contiontion fun
.
This is similarity as [every](#every) but if iterable
is empty, return false
.
fun
Function :(element[,index,array])=>boolean
iteratable
**Iterable**
Similarity as =all=, but if iterable
is empty, return true
.
Check is some
element in iterable
satisfy contiontion fun
.
fun
Function :(element[,index,array])=>boolean
iterable
**Iterable**
Alias of =any=.