fix: slice filter on negative begin, #117

This commit is contained in:
harttle
2019-04-01 10:57:08 +08:00
parent dba26f24e6
commit eadb6f3711
2 changed files with 3 additions and 2 deletions
+2 -2
View File
@@ -9,8 +9,8 @@ export default {
'sort': <T>(v: T[], arg: (lhs: T, rhs: T) => number) => v.sort(arg),
'size': (v: string | any[]) => v.length,
'concat': <T1, T2>(v: T1[], arg: T2[] | T2): Array<T1 | T2> => Array.prototype.concat.call(v, arg),
'slice': <T>(v: T[], begin: number, length: number): T[] => {
if (length === undefined) length = 1
'slice': <T>(v: T[], begin: number, length: number = 1): T[] => {
begin = begin < 0 ? v.length + begin : begin
return v.slice(begin, begin + length)
},
'uniq': function<T> (arr: T[]): T[] {