0.1.0 • Published 1 year ago

fluent-interface v0.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

fluent-interface

npm

Easily build fluent interface in JavaScript.

Usage

const add = (t, n) => {
  t.value += n;
  return t;
};

const subtract = (t, n) => {
  t.value -= n;
  return t;
};

const multiply = (t, n) => {
  t.value *= n;
  return t;
};

const divide = (t, n) => {
  t.value /= n;
  return t;
};

const calculator = fi(
  { value: 0 },
  {
    add,
    subtract,
    multiply,
    divide,
  }
);

const result = calculator //
  .add(10)
  .subtract(5)
  .multiply(4)
  .divide(2);

console.log(result.value); // 10
// (0 + 10 - 5) * 4 / 2

License

MIT

0.1.0

1 year ago

0.0.1

1 year ago