Skip to content

jiameng123/Mengt.js

Repository files navigation

Members

alwaysfunction

返回一个函数,该函数总是返回给定值

assoc

浅复制对象,然后设置或覆盖对象的指定属性。 assoc :: String -> a -> {k: v} -> {k: v}

call*

提取第一个参数作为函数,其余参数作为刚提取的函数的参数,调用该函数并将结果返回。

cloneobject

深拷贝一个对象,不会复制原型链上的属性

concatList

连接列表或字符串。

curryfunction

柯里化未知参数个数的函数

curryNfunction

对函数进行柯里化,并限制柯里化函数的元数

defaultTo*

如果第二个参数不是null或者undefined或者NAN,则返回第第二个参数,否者返回第一个参数(默认值);

divideNumber

两个数相除 a / b

dropArray

删除一个列表中前几个元素 drop :: n -> [] -> []

filter*

迭代列表,在每个函数上调用断言函数,返回满足断言函数的元素。返回值与传入的列表类型相同

findObject

查找并返回 list 中首个满足 predicate 的元素的索引;如果未找到满足条件的元素,则返回 -1 。

findIndexNumber

查找并返回 list 中首个满足 predicate 的元素的索引;如果未找到满足条件的元素,则返回 -1 。

findLastObject

查找并返回list中最后一个满足 predicate 的元素的索引;如果未找到满足条件的元素,则返回undefined 。

findLastIndexNumber

查找并返回 list中最后满足 predicate 的元素的索引;如果未找到满足条件的元素,则返回 -1 。

flip

flip :: (a -> b -> c) -> a -> b -> c flip函数简单的取一个函数作为参数,返回一个效果相同的函数,但是新的函数前两个参数的顺序和之前的函数两个参数的顺序正好颠倒

hasBoolean

如果对象自身含有指定的属性,则返回 true;否则返回 false。

head*

求列表或字符串的首个元素

identity*

作为默认值或占位符功能,永远返回传入的参数

includesBoolean

只要列表中有一个元素等于指定值,则返回 true;否则返回 false。通过 M.isEquals 函数进行相等性判断。也可以判断字符串中是否包含指定值。

indexOfNumber

返回给定元素在数组中首次出现时的索引值,如果数组中没有该元素,则返回 -1。通过 M.isEquals 函数进行相等性判断

init*

返回 list 或 string 删除最后一个元素后的部分。

isBoolean

检查对象是否是构造函数的实例 is :: ( -> ) -> a -> Boolean

isEmptyBoolean

检测给定值是否为其所属类型的空值,若是则返回 true ;否则返回 false 。

isEqualBoolean

如果传入的参数相等,返回true,否则返回false

keysArray

返回一个组数,包含输入对象所有的key的数组,顺序可能不一致,不会提取原型上的key

mapArray

为Array和Object实现了map方法,如果第二个参数有自身的map方法,则使用自身的map方法,如果第二个参数传入的是函数类型。map会将他们组合起来相当于compose

multiplyNumber

两个数相乘 a * b

nth*

返回列表或字符串的第 n 个元素。如果 n 为负数,则返回索引为 length + n 的元素。

oncefunction

接受一个函数,返回一个包装函数,使得接受的函数无论调用多少次,只返回第一次调用的结果

path*

取出给定路径上的值

pathsArray

检索对象给定路径上的值

prop*

获取对象指定属性的值,如果不存在则返回undefined prop :: s -> {s:a} -> a | Undefined

propEqBoolean

如果指定对象属性与给定的值相等,则返回 true ;否则返回 false 。通过 M.equals 函数进行相等性判断。可以使用M.whereEq进行多个属性判断 propEq :: String -> a -> Object -> Boolean

propIsBoolean

判断指定对象的属性是否为给定的数据类型(实例),是则返回 true ;否则返回 false 。 propIs :: Type -> String -> Object -> Boolean

propsArray

返回 prop 的数组: 输入为 keys 数组,输出为对应的 values 数组。values 数组的顺序与 keys 的相同。 prop :: [k] -> {k:v} -> [v]

rangeArray

返回从 from 到 to 之间的所有数的升序列表。左闭右开(包含 from,不包含 to)

sliceArray | string

返回给定列表或字符串的元素,从from开始到to-1;如果传入的对象有slice方法,则直接调用该方法

sortArray

根据传入的比较器函数进行列表排序

sortByArray

根据传入的函数对列表进行排序

subtractNumber

两个值相减

tail*

删除列表中的首个元素

takeArray

提取一个数字和一个列表作为参数,返回列表中指定的前几个元素 take:: n -> [] -> []

tap*

使用提供的参数运行给定的函数,总是返回该参数,通常在链式调用或者compose | pipe 函数中调试

timesArray

执行输入的函数 n 次,返回由函数执行结果组成的数组。fn 为一元函数,n 次调用接收的参数为:从 0 递增到 n-1 。

TypeString

检测数据类型

zipArray

生成一组序对的列表

zipWith

zipWith :: (a -> b -> c) -> [a] -> [b] -> [c] 取一个函数和两个列表作为参数,使用两个列表相应的元素去调用这个函数,返回一个新的列表

Constants

compose*

函数组合从右至左调用函数 a => b => c = a(b(c))

forEachlist

循坏遍历数组或类数组对象

omitobject

去除对象中的属性

pipe*

管道方法 从左到右执行函数

reduce*

对列表中每一个元素执行提供的函数,将其结果汇总为单个返回值。

reduceRight*

对列表中每一个元素执行提供的函数(从右至左迭代),将其结果汇总为单个返回值。

reverselist

以相反的顺序返回包含元素或字符新列表或字符串

always ⇒ function

返回一个函数,该函数总是返回给定值

Kind: global variable
Returns: function - function:: * -> val

Param Type
val *

Example

const a = always('b');
     b('a') //=> 'b'
     b() //=> b

assoc ⇒

浅复制对象,然后设置或覆盖对象的指定属性。 assoc :: String -> a -> {k: v} -> {k: v}

Kind: global variable
Returns: 返回Object除已更改的属性外,等效于原始对象的新对象

Param Type Description
prop String 要设置的属性名称
val * 要设置属性的值
要克隆的对象 Object

Example

M.assoc('c', 3, {a: 1, b: 2}); //=> {a: 1, b: 2, c: 3}

call ⇒ *

提取第一个参数作为函数,其余参数作为刚提取的函数的参数,调用该函数并将结果返回。

Kind: global variable
Todo

  • 支持柯里化和部分应用
Param Type
...第一个参数为函数 *

Example

M.call(R.add, 1, 2); //=> 3

clone ⇒ object

深拷贝一个对象,不会复制原型链上的属性

Kind: global variable
Returns: object - 一个新的对象

Param Type
obj object

Example

const objects = [{}, {}, {}];
     const objectsClone = M.clone(objects);
     objects === objectsClone; //=> false
     objects[0] === objectsClone[0]; //=> false

concat ⇒ List

连接列表或字符串。

Kind: global variable
Returns: List - 返回一个有a和b组成的新的列表

Param Type Description
a List 第一个列表
b List 第二个列表

Example

M.concat('ABC', 'DEF'); // 'ABCDEF'
     M.concat([4, 5, 6], [1, 2, 3]); //=> [4, 5, 6, 1, 2, 3] 
     M.concat([], []); //=> []

curry ⇒ function

柯里化未知参数个数的函数

Kind: global variable

curryN ⇒ function

对函数进行柯里化,并限制柯里化函数的元数

Kind: global variable

Param Type
待柯里化函数参数的个数 number
待柯里化的函数 function

defaultTo ⇒ *

如果第二个参数不是null或者undefined或者NAN,则返回第第二个参数,否者返回第一个参数(默认值);

Kind: global variable

Param Type Description
def * 默认值
val * 输入值

Example

defaultTo(1, null) //=> 1
     defaultTo(1, '') //=> ''

divide ⇒ Number

两个数相除 a / b

Kind: global variable

Param Type
a Number
b Number

Example

ivide(10, 100) //=> 0.1
     divide(10)(100) //=> 0.1

drop ⇒ Array

删除一个列表中前几个元素 drop :: n -> [] -> []

Kind: global variable
Returns: Array - [*] 一个新的列表

Param Type Description
n Number 删除列表的个数
list Array 待删除的列表

Example

M.drop(1, [1,2]) //=> [2]
     M.drop(1, 'abc') //=> 'bc'

filter ⇒ *

迭代列表,在每个函数上调用断言函数,返回满足断言函数的元素。返回值与传入的列表类型相同

Kind: global variable
Returns: * - 根据传入的对象类型,返回一个新的数组或对象

Param Type Description
fn function 断言函数
list * 数组或者对象

Example

const isEven = n => n % 2 === 0;
      M.filter(isEven, [1, 2, 3, 4]); //=> [2, 4]

find ⇒ Object

查找并返回 list 中首个满足 predicate 的元素的索引;如果未找到满足条件的元素,则返回 -1 。

Kind: global variable
Returns: Object - 首次满足fn的元素或undefined

Param Type Description
fn function
list Array 查找的数组

Example

const xs = [{a: 1}, {a: 2}, {a: 3}];
     M.find( (x) => x.a == 2, x) //=> {a:2}

findIndex ⇒ Number

查找并返回 list 中首个满足 predicate 的元素的索引;如果未找到满足条件的元素,则返回 -1 。

Kind: global variable
Returns: Number - 返回列表中第一个满足fn的元素的索引,否则返回-1

Param Type Description
fn function 列表中的每一项循环调用谓词函数
list Array

Example

const xs = [{a: 1}, {a: 2}, {a: 3}];
      M.findIndex({a:2}, xs) //=> 1
      M.findIndex({a:4}, xs) //=> -1

findLast ⇒ Object

查找并返回list中最后一个满足 predicate 的元素的索引;如果未找到满足条件的元素,则返回undefined 。

Kind: global variable
Returns: Object - 最后次满足fn的元素或undefined

Param Type Description
fn function
list Array 查找的数组

Example

const xs = [{a: 1, b: 0}, {a:1, b: 1}];
     M.find( (x) => x.a == 1, x) //=> {a:1, b: 1}

findLastIndex ⇒ Number

查找并返回 list中最后满足 predicate 的元素的索引;如果未找到满足条件的元素,则返回 -1 。

Kind: global variable
Returns: Number - 返回列表中最后一个满足fn的元素的索引,否则返回-1

Param Type Description
fn function 列表中的每一项循环调用谓词函数
list Array

Example

const xs = [{a: 1, b: 0}, {a:1, b: 1}];
      M.findIndex(x => x.a == 1, xs) //=> 1

flip

flip :: (a -> b -> c) -> a -> b -> c flip函数简单的取一个函数作为参数,返回一个效果相同的函数,但是新的函数前两个参数的顺序和之前的函数两个参数的顺序正好颠倒

Kind: global variable
Tod: 支持多参数部分应用

has ⇒ Boolean

如果对象自身含有指定的属性,则返回 true;否则返回 false。

Kind: global variable
Returns: Boolean - 该属性是否存在
Oarma: Obejct obj 要查询的对象

Param Type Description
key String 要检查属性的key

Example

const obj = {a: 1};
     has('a', obj) //=> true
     has('a')({}) //=> false

head ⇒ *

求列表或字符串的首个元素

Kind: global variable

Param Type Description
list * 数组或者字符串

Example

head(['a', 'b', 'c']) //=> 'a';
     head([]) //=> 'undefined';
     head('abc') //=> 'a';
     head('') //=> ''

identity ⇒ *

作为默认值或占位符功能,永远返回传入的参数

Kind: global variable
Returns: * - 返回输入值'x'

Param Type Description
x * 返回的value

Example

identity(1) == 1
    identity({a:1}) //=> {a:1}

includes ⇒ Boolean

只要列表中有一个元素等于指定值,则返回 true;否则返回 false。通过 M.isEquals 函数进行相等性判断。也可以判断字符串中是否包含指定值。

Kind: global variable
Returns: Boolean - 如果列表中包含输入的指定值则返回true, 否则返回false

Param Type Description
a Object 要比较的元素
list Array

Example

M.includes(3, [1, 2, 3]); //=> true
     M.includes(4, [1, 2, 3]); //=> false
     M.includes({ name: 'Fred' }, [{ name: 'Fred' }]); //=> true
     M.includes([42], [[42]]); //=> true
     M.includes('ba', 'banana'); //=>true

indexOf ⇒ Number

返回给定元素在数组中首次出现时的索引值,如果数组中没有该元素,则返回 -1。通过 M.isEquals 函数进行相等性判断

Kind: global variable
Returns: Number - 目标索引,如果未找到则返回-1

Param Type Description
target * 要查找的项
sorce Array 要搜索的数组

Example

M.indexOf(3, [1,2,3,4]); //=> 2
      M.indexOf(10, [1,2,3,4]); //=> -1

init ⇒ *

返回 list 或 string 删除最后一个元素后的部分。

Kind: global variable

Param Type
list *

Example

M.init([1, 2, 3]);  //=> [1, 2]
     M.init([1, 2]);     //=> [1]
     M.init([1]);        //=> []
     M.init([]);         //=> []

     M.init('abc');  //=> 'ab'
     M.init('ab');   //=> 'a'
     M.init('a');    //=> ''
     M.init('');     //=> ''

is ⇒ Boolean

检查对象是否是构造函数的实例 is :: (* -> *) -> a -> Boolean

Kind: global variable

Param Type Description
ctor Funtion 构造函数
val * 待检测的值

Example

M.is(Object, {}); //=> true
     M.is(Number, 1); //=> true
     M.is(Object, 1); //=> false
     M.is(String, 's'); //=> true
     M.is(String, new String('')); //=> true
     M.is(Object, new String('')); //=> true
     M.is(Object, 's'); //=> false
     M.is(Number, {}); //=> false

isEmpty ⇒ Boolean

检测给定值是否为其所属类型的空值,若是则返回 true ;否则返回 false 。

Kind: global variable

Param Type
obj *

Example

isEmpty([1, 2, 3]);   //=> false
     isEmpty([]);          //=> true
     isEmpty('');          //=> true
     isEmpty(null);        //=> false
     isEmpty({});          //=> true
     isEmpty({length: 0}); //=> false

isEqual ⇒ Boolean

如果传入的参数相等,返回true,否则返回false

Kind: global variable

Param Type
a *
b *

Example

isEquals(1, 1); //=> true
     isEquals(1, '1'); //=> false
     isEquals([1, 2, 3], [1, 2, 3]); //=> true

     const a = {}; a.v = a;
     const b = {}; b.v = b;
     isEquals(a, b); //=> true

keys ⇒ Array

返回一个组数,包含输入对象所有的key的数组,顺序可能不一致,不会提取原型上的key

Kind: global variable
Returns: Array - 包含obj所有key的数组

Param Type Description
obj Object 要提取key的对象

Example

keys({a: 1, b: 2, c: 3}); //=> ['a', 'b', 'c']

map ⇒ Array

为Array和Object实现了map方法,如果第二个参数有自身的map方法,则使用自身的map方法,如果第二个参数传入的是函数类型。map会将他们组合起来相当于compose

Kind: global variable
Returns: Array - The new list.

Param Type Description
fn function 遍历list每次执行的函数
list List | function

Example

var double = x => x * 2;
     map(double, [1,2,3]) //=> [2,4,6];
     map(double, {a:1, b:2, c:3}) //=> {a:2, b:4, c:6};

multiply ⇒ Number

两个数相乘 a * b

Kind: global variable

Param Type
a Number
b Number

Example

multiply(10, 100) //=> 1000
     multiply(10)(100) //=> 1000

nth ⇒ *

返回列表或字符串的第 n 个元素。如果 n 为负数,则返回索引为 length + n 的元素。

Kind: global variable

Param Type
n Number
list List

Example

const list = ['foo', 'bar', 'baz', 'quux'];
     M.nth(1, list); //=> 'bar'
     M.nth(-1, list); //=> 'quux'
     M.nth(-99, list); //=> undefined

     M.nth(2, 'abc'); //=> 'c'
     M.nth(3, 'abc'); //=> ''

once ⇒ function

接受一个函数,返回一个包装函数,使得接受的函数无论调用多少次,只返回第一次调用的结果

Kind: global variable
Returns: function - 返回一个包装函数
@example: const addOnce = M.once(x => x+1) addOnce(10); // 11; addOnce((addOneOnce(50)); //11

Param Type
func function

path ⇒ *

取出给定路径上的值

Kind: global variable

Type
Array
Object

Example

M.path(['a', 'b'], {a: {b: 2}}); //=> 2
     M.path(['a', 'b'], {c: {b: 2}}); //=> undefined

paths ⇒ Array

检索对象给定路径上的值

Kind: global variable
Returns: Array - 返回paths指定的路径上的值组成的数组

Param Type Description
paths Array 给定路径的数组
obj Object 要检索属性的对象

Example

M.paths([['a', 'b'], ['p', 0, 'q']], {a: {b: 2}, p: [{q: 3}]}); //=> [2, 3]
     M.paths([['a', 'b'], ['p', 'r']], {a: {b: 2}, p: [{q: 3}]}); //=> [2, undefined]

prop ⇒ *

获取对象指定属性的值,如果不存在则返回undefined prop :: s -> {s:a} -> a | Undefined

Kind: global variable
Returns: * - obj.prop

Param Type Description
prop * 属性名称
obj Object 查询的对象

Example

const obj = {x:1, y:2};
     M.prop('x', obj) //=> 1;

propEq ⇒ Boolean

如果指定对象属性与给定的值相等,则返回 true ;否则返回 false 。通过 M.equals 函数进行相等性判断。可以使用M.whereEq进行多个属性判断 propEq :: String -> a -> Object -> Boolean

Kind: global variable

Param Type Description
key String 属性名称
value *
obj Object 要查找的对象

Example

var obj1 = {name: 'Abby', age: 7, hair: 'blond'};
     M.propEq('name', 'Abby', obj1) //=> true

propIs ⇒ Boolean

判断指定对象的属性是否为给定的数据类型(实例),是则返回 true ;否则返回 false 。 propIs :: Type -> String -> Object -> Boolean

Kind: global variable

Param Type Description
type function
prop String 属性名称
obj * 要查找的对象

Example

M.propIs(Number, 'x', {x: 1, y: 2});  //=> true
     M.propIs(Number, 'x', {x: 'foo'});    //=> false

props ⇒ Array

返回 prop 的数组: 输入为 keys 数组,输出为对应的 values 数组。values 数组的顺序与 keys 的相同。 prop :: [k] -> {k:v} -> [v]

Kind: global variable
Returns: Array - 返回数组中相对应的值

Param Type Description
props Array 属性名称的数组
obj Object 查询的对象

Example

M.props(['x', 'y'], {x: 1, y: 2}); //=> [1, 2]
     M.props(['c', 'a', 'b'], {b: 2, a: 1}); //=> [undefined, 1, 2]

range ⇒ Array

返回从 from 到 to 之间的所有数的升序列表。左闭右开(包含 from,不包含 to)

Kind: global variable
Returns: Array - from到to之间的集合,不包含to

Param Type Description
from Number 列表中的第一个数字
to Number 列表中最后一个数字加1

Example

M.range(1, 5);    //=> [1, 2, 3, 4]
     M.range(50, 53);  //=> [50, 51, 52]

slice ⇒ Array | string

返回给定列表或字符串的元素,从from开始到to-1;如果传入的对象有slice方法,则直接调用该方法

Kind: global variable
Returns: Array | string - }

Param Type Description
from Number 起始位置
to Number 结束位置
} Array | string list 列表或字符串

Example

slice(1, 2, [a, b, c, d]) //=> [b]
    slice(1, Infinity, [a, b, c, d, e]) //=> [b, c, d, e]
    slice(0, -1, ['a', 'b', 'c', 'd']) //=> [a, b, c]
    slice(-1, -3, [a, b, c, d]) //=> [b ,c]
    slice(1,2, 'abc') //=> 'a'

sort ⇒ Array

根据传入的比较器函数进行列表排序

Kind: global variable
Returns: Array - 排序后的新的列表

Param Type Description
comparator function 排序函数
list Array 待排序的列表

Example

const diff = (a, b) => a - b;
     sort(diff, [1,0, 4, 3, 2]) //=> [0, 1, 2, 3, 4]

sortBy ⇒ Array

根据传入的函数对列表进行排序

Kind: global variable
Returns: Array - 排序后的新的列表

Param Type Description
fn function
list Array 待排序的列表

Example

const diff = (x) => x.age;
     sort(diff, [{age: 3}, {age:8}, {age:1}]) //=> [{age:1}, {age:3}, {age:8}]

subtract ⇒ Number

两个值相减

Kind: global variable

Param Type
a Number
b Number

Example

add(1,2) //=> -1
     add('1', '2') //=> -1
     add(1)(2) //=> -1

tail ⇒ *

删除列表中的首个元素

Kind: global variable

Param Type
list *

Example

const list = [1, 2, 3];
     tail(list) //=>[2,3];
     tail([1, 2]) //=>[2]
     tail([1]) //=>[]
     tail([]) //=> []
     tail('abc') //=>'bc'
     tail('a') //=> ''
     tail('') //=> ''

take ⇒ Array

提取一个数字和一个列表作为参数,返回列表中指定的前几个元素 take:: n -> [] -> []

Kind: global variable
Returns: Array - [*] 一个新的列表

Param Type Description
n Number 提取列表的个数
list Array 待提取的列表

Example

M.take(1, [1,2]) //=> [1]
     M.take(1, 'abc') //=> a

tap ⇒ *

使用提供的参数运行给定的函数,总是返回该参数,通常在链式调用或者compose | pipe 函数中调试

Kind: global variable
Returns: * - val

Param Type
使用参数val调用fn,返回值将被丢弃 function
val *

Example

const consoleX = x => console.log(x);
    tap(consoleX, 'aa') //=> aa    

times ⇒ Array

执行输入的函数 n 次,返回由函数执行结果组成的数组。fn 为一元函数,n 次调用接收的参数为:从 0 递增到 n-1 。

Kind: global variable
Returns: Array - 一个数组,包含对fn调用的所有返回值。

Param Type Description
fn function 要调用的函数。接受一个参数,即n的当前值。
n Number 0到n-1之间的值,每次函数调用后递增。

Example

M.times(M.identity, 5); //=> [0, 1, 2, 3, 4] 
     M.times(f, 2) = [f(0), f(1)]

Type ⇒ String

检测数据类型

Kind: global variable

Param Type
x *

Example

type({}) //=> 'Object'
    type(1) //=> 'Number'
    type([]) //=> 'Array'
    type(/\.s/) //=> 'RegExp'
    type(null) //=> '�Null'
    type(undefined) //=> "Undefined"
    type(() => {}); //=> "Function"    

zip ⇒ Array

生成一组序对的列表

Kind: global variable

Param Type Description
list1 Array 第一个数组
list2 Array 第二个数组

Example

M.zip([1, 2, 3], ['a', 'b', 'c']); //=> [[1, 'a'], [2, 'b'], [3, 'c']]

zipWith

zipWith :: (a -> b -> c) -> [a] -> [b] -> [c] 取一个函数和两个列表作为参数,使用两个列表相应的元素去调用这个函数,返回一个新的列表

Kind: global variable

compose ⇒ *

函数组合从右至左调用函数 a => b => c = a(b(c))

Kind: global constant

Param Description
[Function] 调用的函数

Example

compose(f1,f2,f3)(6)

forEach ⇒ list

循坏遍历数组或类数组对象

Kind: global constant

Param Type Description
callback 一个回调函数,参数为数组的每一项
遍历的数组项 list

Example

const fn = x => console.log(x);
     const arr = [1, 2, 3];
     M.forEach(fn, arr) //=> 1, 2 , 3
     

omit ⇒ object

去除对象中的属性

Kind: global constant
Returns: object - 去除属性后的一个新的对象
Fun:

Param Type Description
names Array 是一个obj中的keys数组
obj object 将要去除属性的源对象

Example

_M.omit(['a', 'b'], {a:1, b:2,c:3}); // { c:3}
     _M.omit(['a','b'])({a:1, b:2, c:3}) //{c:3}

pipe ⇒ *

管道方法 从左到右执行函数

Kind: global constant

Param Type
...functions function

Example

pipe(f1, f2, f3)({x:1,y:2});
	    pipe(f1)(f2)(f3)({x:1,y:2}, 8, 10);

reduce ⇒ *

对列表中每一个元素执行提供的函数,将其结果汇总为单个返回值。

Kind: global constant
Returns: * - 累加值

Param Type Description
fn处理list每一项的回调 function
list list
init * 首次执行的初始值

reduceRight ⇒ *

对列表中每一个元素执行提供的函数(从右至左迭代),将其结果汇总为单个返回值。

Kind: global constant
Returns: * - 累加值

Param Type Description
fn处理list每一项的回调 function
list Array 数组
init * 首次执行的初始值

reverse ⇒ list

以相反的顺序返回包含元素或字符新列表或字符串

Kind: global constant

Param Type
list list

Example

everse([1, 2]); //=> [2,1];
     reverse([]); //=> []
     reverse('abc'); //=> 'cba'
     reverse(''); //=> ''

~add ⇒ Number

两个值相加

Kind: inner member

Param Type
a Number
b Number

Example

M.add(1,2) //=>3
     M.add('1', '2') //=>3
     M.add(1)(2) //=>3

~append ⇒ Array

返回包含给定列表内容的新列表,后跟给定的元素。

Kind: inner member
Returns: Array - 一个新列表,包含旧列表的元素,数组最后一个元素为item。

Param Type Description
item * 要添加到新列表末尾的元素。
list Array 要添加新项目的元素列表。

Example

R.append('d', ['b', 'c']); //=> ['b', 'c', 'd']
     M.append('1', []) //=> [1]
    

~prepend ⇒ Array

返回包含给定列表内容的新列表,头部为给定的元素。

Kind: inner member
Returns: Array - 一个新列表,包含旧列表的元素,数组第一个元素为item。

Param Type Description
item * 要添加到新列表头部的元素。
list Array 要添加新项目的元素列表。

Example

R.prepend('a', ['b', 'c']); //=> ['a', 'b', 'c']
     M.prepend('1', []) //=> [1]