Needless Patchouli Manufacture

    babel-plugin-reduce-with-operator

    1.0.4 • Public • Published

    babel-plugin-reduce-with-operator

    This plugin allows you reduce an array, without writing callback function. Example arr.reduceWithOperator(+). It looks for reduceWithOperator member function call and converts it into native reduce function with a callback. Currently it supports +, -, *, / and % operators.

    Note: This plugin uses custom parser to support operators as arguments.

    Installation 🛠

    • Install plugin

      yarn add babel-plugin-reduce-with-operator -D
    • Add plugin your babel configuration file, i.e. .babelrc

      {
        ...
        "plugins": [
          "babel-plugin-reduce-with-operator"
        ]
      }
       

    Usage 💻

    const arr = [1,2,3];
    const sum = arr.reduceWithOperator(+);
    console.log(sum); // 6

    For sample usage, you can check examples, or you can test on your browser.

    Credits 🙇‍♂️

    Keywords

    none

    Install

    npm i babel-plugin-reduce-with-operator

    DownloadsWeekly Downloads

    5

    Version

    1.0.4

    License

    MIT

    Unpacked Size

    66.9 kB

    Total Files

    11

    Last publish

    Collaborators

    • lakhansamani