@dillonkearns/elm-graphql
Version:
<img src="https://cdn.jsdelivr.net/gh/martimatix/logo-graphqelm/logo.svg" alt="dillonearns/elm-graphql logo" width="40%" align="right">
37 lines (24 loc) • 891 B
JavaScript
;
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var _newArrowCheck = _interopDefault(require('babel-runtime/helpers/newArrowCheck'));
var Fun = require('flow-static-land/lib/Fun');
var _this = undefined;
/**
* Reduce the given array applying reduce function while shouldProceed function
* returns true.
*/
var reduceWhile = function (shouldProceed, reduce, resultInitial, array) {
_newArrowCheck(this, _this);
var result = resultInitial;
array.every(function (element, index) {
_newArrowCheck(this, _this);
var proceed = shouldProceed(element, index, result);
if (proceed) {
result = reduce(result, element, index);
}
return proceed;
}.bind(this));
return result;
}.bind(undefined);
var reduceWhile$1 = Fun.curry(reduceWhile);
module.exports = reduceWhile$1;