How to use the iter-tools/es5/reduce function in iter-tools

To help you get started, we’ve selected a few iter-tools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github conartist6 / sequins / src / factories / reduce.js View on Github external
Indexed: function reduce(iterable, reducer, initial) {
    let reduced;
    if (arguments.length > 2) {
      reduced = reduceIterable(initial, reducer, iterable);
    } else {
      reduced = reduceIterable(reducer, iterable);
    }
    return reduced;
  },
  Keyed: function reduce(iterable, reducer, initial) {
github conartist6 / sequins / src / factories / reduce.js View on Github external
Duplicated: function reduce(iterable, reducer, initial) {
    const setReducer = (acc, item) => reducer(acc, item, item);
    let reduced;
    if (arguments.length > 2) {
      reduced = reduceIterable(initial, setReducer, iterable);
    } else {
      reduced = reduceIterable(setReducer, iterable);
    }
    return reduced;
  },
  Indexed: function reduce(iterable, reducer, initial) {
github conartist6 / sequins / src / factories / reduce.js View on Github external
Keyed: function reduce(iterable, reducer, initial) {
    let invocations = 0;
    let hasInitial = arguments.length > 2;
    let reduced;
    const keyedReducer = (acc, [key, value]) => {
      if (invocations++ === 0 && !hasInitial) {
        acc = acc[1];
      }

      return reducer(acc, value, key);
    };
    if (hasInitial) {
      reduced = reduceIterable(initial, keyedReducer, iterable);
    } else {
      reduced = reduceIterable(keyedReducer, iterable);
    }
    return reduced;
  },
};
github conartist6 / sequins / src / factories / reduce.js View on Github external
Keyed: function reduce(iterable, reducer, initial) {
    let invocations = 0;
    let hasInitial = arguments.length > 2;
    let reduced;
    const keyedReducer = (acc, [key, value]) => {
      if (invocations++ === 0 && !hasInitial) {
        acc = acc[1];
      }

      return reducer(acc, value, key);
    };
    if (hasInitial) {
      reduced = reduceIterable(initial, keyedReducer, iterable);
    } else {
      reduced = reduceIterable(keyedReducer, iterable);
    }
    return reduced;
  },
};
github conartist6 / sequins / src / factories / reduce.js View on Github external
Indexed: function reduce(iterable, reducer, initial) {
    let reduced;
    if (arguments.length > 2) {
      reduced = reduceIterable(initial, reducer, iterable);
    } else {
      reduced = reduceIterable(reducer, iterable);
    }
    return reduced;
  },
  Keyed: function reduce(iterable, reducer, initial) {
github conartist6 / sequins / src / factories / reduce.js View on Github external
Duplicated: function reduce(iterable, reducer, initial) {
    const setReducer = (acc, item) => reducer(acc, item, item);
    let reduced;
    if (arguments.length > 2) {
      reduced = reduceIterable(initial, setReducer, iterable);
    } else {
      reduced = reduceIterable(setReducer, iterable);
    }
    return reduced;
  },
  Indexed: function reduce(iterable, reducer, initial) {