0.0.2 • Published 5 years ago

kasen v0.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

Kasen

npm version CircleCI codecov

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.

What does Kasen mean?

"Kasen" means "underscore" in Japanese :stuck_out_tongue:

Installation

npm install kasen

Import

  • ES Modules: import Kasen from "kasen";
  • CommonJS: const Kasen = require("kasen");

Example

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]

Feature

  1. 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]
  2. 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
  3. Great Selection of Methods: Kasen will have a lot of collection methods.

    • 96 methods for Array.
    • 57 methods for Object.
  4. Light Weight: Kasen will be light weight library.
    • Kasen is 68 KB now.

APIs

Note that documentation is under construction.

Contribution

TBD

License

Kasen is MIT-licensed.