functools-ts
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -18,3 +18,4 @@ import { F1 } from "./function"; | ||
equals: <A>(list1: ReadonlyArray<A>, list2: ReadonlyArray<A>, eq?: ((a: A, b: A) => boolean) | undefined) => boolean; | ||
place: <A>(a: A, where: Selector<A>, newIdx: number) => (list: ReadonlyArray<A>) => ReadonlyArray<A>; | ||
}; | ||
export {}; |
@@ -61,4 +61,9 @@ "use strict"; | ||
} | ||
} | ||
}, | ||
place: function (a, where, newIdx) { return function (list) { | ||
var list_ = list.filter(function (item, idx) { return !match(where, item, idx, list); }); | ||
list_.splice(newIdx, 0, a); | ||
return list_; | ||
}; } | ||
}; | ||
//# sourceMappingURL=list.js.map |
@@ -10,3 +10,3 @@ { | ||
"typings": "dist/index.d.ts", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"repository": "git@bitbucket.org:chaaba_j/ts-functools.git", | ||
@@ -13,0 +13,0 @@ "author": "Jalal Chaabane", |
@@ -80,3 +80,10 @@ import { F1 } from "./function" | ||
} | ||
}, | ||
place: <A>(a: A, where: Selector<A>, newIdx: number) => (list: List<A>): List<A> => { | ||
const list_ = list.filter( | ||
(item, idx) => !match(where, item, idx, list) | ||
) | ||
list_.splice(newIdx, 0, a) | ||
return list_ | ||
} | ||
} |
@@ -12,3 +12,3 @@ import { List } from "../src/list"; | ||
name: "test3", | ||
description: "test2" | ||
description: "test3" | ||
}, | ||
@@ -44,2 +44,12 @@ { | ||
}) | ||
it("should move item from index 2 to index 1", () => { | ||
const moved = List.place(items[1], 1, 2)(items) | ||
expect(moved[2]).to.eql(items[1]) | ||
}) | ||
it("should move the first element to the end", () => { | ||
const moved = List.place(items[0], 0, 2)(items) | ||
expect(moved[2]).to.eql(items[0]) | ||
}) | ||
}) |
Sorry, the diff of this file is not supported yet
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
123996
86
2673
1
140