Methods
-
<static> contains(list, value)
-
判断list是否包含value
Parameters:
Name Type Description list
list 目标集合
value
* value
Returns:
- Type
- boolean
-
<static> each(list, fn)
-
遍历list中所有元素,list可以是array,arryLike or object
Parameters:
Name Type Description list
list 准备遍历的集合对象
fn
eachCallback 回调方法(value,index,list)
Returns:
myReturnValue description.
- Type
- list
-
<static> every(list, fn)
-
若list中所有值都通过fn的真值检测,则返回true
Parameters:
Name Type Description list
list 目标集合
fn
eachCallback 检测函数
Returns:
若list中所有值都通过fn的真值检测,则返回true
- Type
- boolean
-
<static> filter(list, fn)
-
对list遍历,返回所有通过fn的检测(return:true)的值
Parameters:
Name Type Description list
list 目标集合
fn
eachCallback 检测函数
Returns:
所有通过fn检测的值组成的数组
- Type
- array
-
<static> find(list, fn)
-
对list遍历,返回第一个通过fn的检测(return:true)的值
Parameters:
Name Type Description list
list 目标集合
fn
eachCallback 检测函数
Returns:
list中第一个通过fn检测的值
- Type
- *
-
<static> groupBy(list, fn)
-
对list分组,若fn是函数,list每一项作为参数传入,输出作为分组key 若fn为字符串('length'),使用value.length作为分组标准
Parameters:
Name Type Description list
list 目标集合
fn
eachCallback | string 遍历回调函数或string:'length'
Returns:
分组结果
- Type
- object
-
<static> map(list, fn)
-
输出list根据转换函数fn映射的新数组
Parameters:
Name Type Description list
list 目标集合
fn
eachCallback 回调方法(value,index,list)
Returns:
返回经由fn生成的新数组
- Type
- array
-
<static> max(list [, fn])
-
返回list中最大值,若传递fn,则将其返回值作为每个值排序的依据
Parameters:
Name Type Argument Description list
list 目标集合
fn
eachCallback <optional>
检测函数,可选
Returns:
返回拥有匹配后最大值的项
- Type
- *
-
<static> min(list [, fn])
-
返回list中最小值,若传递fn,则将其返回值作为每个值排序的依据
Parameters:
Name Type Argument Description list
list 目标集合
fn
eachCallback <optional>
检测函数,可选
Returns:
返回拥有匹配后最小值的项
- Type
- *
-
<static> partition(list, fn)
-
返回由list拆分的两个数组,第一个数组内元素均满足fn真值检测,第二个均不满足
Parameters:
Name Type Description list
list 目标集合
fn
eachCallback 真值检测回调函数
Returns:
第一个数组内元素均满足fn真值检测,第二个均不满足
- Type
- array
-
<static> pluck(list, key)
-
萃取集合对象中某属性值,返回值数组
Parameters:
Name Type Description list
list 目标集合
key
string key
Returns:
对应key的value组成的数组
- Type
- array
-
<static> reduce(list, fn, memo)
-
对list遍历,并执行fn,每次遍历结果作为第一个参数传递给下次遍历,最后返回一个结果
Parameters:
Name Type Description list
list 目标集合
fn
reduceCallback 回调方法(memo,value,index,list)
memo
* reduce初始值
Returns:
reduce结果
- Type
- *
-
<static> reject(list, fn)
-
遍历list,返回所有未通过fn的检测(return:true)的值,与filter相仿
Parameters:
Name Type Description list
list 目标集合
fn
eachCallback 检测函数
Returns:
所有未通过fn检测的值组成的数组
- Type
- array
-
<static> sample(list [, n])
-
返回list中一个长度为n的随机样本,n默认为1
Parameters:
Name Type Argument Default Description list
list 目标集合
n
number <optional>
1 样本长度,默认为1
Returns:
样本数组
- Type
- array
-
<static> shuffle(list)
-
返回list的随机乱序副本, shuffle详见: https://bost.ocks.org/mike/shuffle/
Parameters:
Name Type Description list
list 目标集合
Returns:
乱序副本
- Type
- list
-
<static> size(list)
-
返回list的长度/属性数量
Parameters:
Name Type Description list
list 目标集合
Returns:
长度or属性数量
- Type
- number
-
<static> some(list, fn)
-
只要list中有值通过fn的真值检测,则返回true
Parameters:
Name Type Description list
list 目标集合
fn
eachCallback 检测函数
Returns:
只要list中有值通过fn的真值检测,则返回true
- Type
- boolean
-
<static> sortBy(list [, fn])
-
返回一个排序后的list副本,若传递fn,则将其作为排序依据,默认升序
Parameters:
Name Type Argument Description list
list 目标集合
fn
sortCallback <optional>
检测函数,可选
Returns:
排序后的list副本
- Type
- array
-
<static> where(list, props)
-
遍历list, 返回包含props列出键值对的数组
Parameters:
Name Type Description list
list 目标集合
props
object 需要匹配的键值对
Returns:
包含props列出键值对的数组
- Type
- array