Kasen is the library of collection methods which is inspired by Lodash, Immutable, Rambda, Scala and Elixir.
Note that Kasen is experimental state. APIs can be changed in the future.
"Kasen" means "underscore" in Japanese 😛
npm install kasen
- ES Modules:
import Kasen from "kasen";
- CommonJS:
const Kasen = require("kasen");
const result1 = Kasen.map({ a: 1, b: 2, c: 3 }, v => v + 1);
console.log(result1); // => { a: 2, b: 3, c: 4 }
const result2 = Kasen([1, 2, 3])
.filter(v => v % 2 === 1)
.map(v => v + 1)
.toJS();
console.log(result2); // => [2, 4]
-
Immutability: Methods do not mutate an input collection.
const input = [1, 2, 3]; const result = Kasen.push(input, 4); console.log(input); // => [1, 2, 3] console.log(result); // => [1, 2, 3, 4]
-
Lazy Evaluation: Method chaining does not process unnecessary calculations.
const result = Kasen([1, 2, 3]) .map(v => { console.log(v); return v + 1; }) .every(v => v % 2 === 0); // => 1 // => 2 console.log(result); // => false
-
Great Selection of Methods: Kasen will have a lot of collection methods.
- 96 methods for Array.
- 57 methods for Object.
-
Light Weight: Kasen will be light weight library.
- Kasen is 68 KB now.
Note that documentation is under construction.
TBD
Kasen is MIT-licensed.