reduce a string to a value
@param  {string}   string          string to reduce
@param  {function} reducerCb    reducer function
@param  {*}        initialValue reduce initial value
@return {*} result
767085
function stringReduce (string, reducerCallback, initialValue) {
  if (string.length === 0) {
    assertErr(initialValue, TypeError, 'Reduce of empty string with no initial value')
    return initialValue
  }
  var initialValuePassed = arguments.length === 3
  var result
  var startIndex
  if (initialValuePassed) {
    // initial value, initialize reduce state
    result = initialValue
    startIndex = 0
  } else {
    // no initial value
    if (string.length === 1) {
      return string.charAt(0)
    }
    // no initial value, initialize reduce state
    result = string.charAt(0)
    startIndex = 1
  }
  for (var i = startIndex; i < string.length; i++) {
    result = reducerCallback(result, string.charAt(i), i, string)
  }
  return result
}
860387
function __stringStartsWith(str, prefix) {
  // returns true for empty string or null prefix
  if ((!str)) return false;
  if (prefix == "" || prefix == null) return true;
  return str.indexOf(prefix, 0) === 0;
}
475345
public function reduce(callable $reduceCallback, $initial = null)
    {
        foreach ($this->iterator as $value) {
            $initial = call_user_func($reduceCallback, $initial, $value);
        }

        return $initial;
    }
903592
@Override
  public StreamBuilderImpl<T,U> reduce(T init,
                                       BinaryOperatorSync<T> op)
  {
    return new ReduceOpInitSync<>(this, init, op);
  }
1116799
function handlerReducersForType(type:String) {
  let apiActionTypes = getApiTypes(type);
  let reducers = {};
  let namesToState = {};
  apiActionTypes.forEach((key, idx) => {
    reducers[apiActionTypes[idx]] = apiReducers[apiStates[idx]];
    namesToState[upcase(apiStates[idx])] = toApiKey(apiActionTypes[idx]);
  });
  return {reducers, namesToState};
}
356589
def reduce_value(value, default=EMPTY_STR):
    

    if hasattr(value, '__len__'):
        vlen = len(value)

        if vlen == 0:
            return default
        elif vlen == 1:
            if isinstance(value, set):
                return value.pop()
            elif isinstance(value, _reduce_types):
                return value[0]

    return default if value is None else value
699495
function isAtStart(string, index) {
  const before = string.substring(0, index).trim();

  return before.length === 0 || before.search(/[({,]$/) !== -1;
}
1039224
public MapReduceOptions<T> reduce(final String reduce) {
        Assert.parametersNotNull("reduce", reduce);
        Assert.parameterNotEmpty("reduce", reduce);
        this.reduce = reduce;
        return this;
    }
943839
function(string) {
		var result = String(string);
		switch (result) {
			case "null":
				result = null;
				break;
			case "true":
			case "false":
				result = (result === "true");
				break;
			default:
				if (String(parseInt(result, 10)) === result) {
					result = parseInt(result, 10);
				} else if (String(parseFloat(result)) === result) {
					result = parseFloat(result);
				}
				break;
		}
		return result;
	}
838099
function ( obj ) {
		var result = 0;

		if ( obj.length > 0 ) {
			result = obj.reduce( function ( prev, cur ) {
				return prev + cur;
			});
		}

		return result;
	}
134838
public function reduce(callable $callback, $initial = null)
    {
        foreach ($this->generator as $key => $value) {
            $initial = $callback($initial, $value, $key);
        }

        return $initial;
    }
228791
function reduceVal(conf, val) {
  val = val.call(conf);
  return typeof val === 'function' ? reduceVal(conf, val) : val;
}
198078
function (value, replacer, space) {

            // The stringify method takes a value and an optional replacer, and an optional
            // space parameter, and returns a JSON text. The replacer can be a function
            // that can replace values, or an array of strings that will select the keys.
            // A default replacer method can be provided. Use of the space parameter can
            // produce text that is more easily readable.

            var i;
            hashomatic._gap = '';
            hashomatic._indent = '';

            // If the space parameter is a number, make an indent string containing that
            // many spaces.

            if (typeof space === 'number') {
                for (i = 0; i < space; i += 1) {
                    hashomatic._indent += ' ';
                }

                // If the space parameter is a string, it will be used as the indent string.

            }
            else if (typeof space === 'string') {
                hashomatic._indent = space;
            }

            // If there is a replacer, it must be a function or an array.
            // Otherwise, throw an error.

            hashomatic._rep = replacer;
            if (replacer && typeof replacer !== 'function' &&
                (typeof replacer !== 'object' ||
                    typeof replacer.length !== 'number')) {
                throw new Error('JSON.stringify');
            }

            // Make a fake root object containing our value under the key of ''.
            // Return the result of stringifying the value.

            return hashomatic._str('', {'': value});
        }
754984
public function reduce($closure, $initial = false)
    {
        $result = $initial;
        foreach ($this as $val) {
            $result = $closure($result, $val);
        }
        return $result;
    }
74237
function fromString (string) {
  assert.equal(typeof string, 'string')

  return from(function (size, next) {
    if (string.length <= 0) return this.push(null)

    const chunk = string.slice(0, size)
    string = string.slice(size)

    next(null, chunk)
  })
}
421147
function sum(input, initial) {

    return (!isArray(input)) ? input :
        input.reduce(function(prev, curr) {
            return prev + curr;
        }, initial || 0);
}
258090
function getString(cb) {
    getEncodedLen(function(err, encLen, isEncoded) {
      if(err) {
        return cb(err);
      }
      if (isEncoded) {
        switch(encLen) {
        case REDIS_RDB_ENC_INT8:
          getFixedBytes(1, function(err, buffers) {
            if(err) {
              cb(err);
            } else {
              cb(null, new Buffer(String(Buffer.concat(buffers).readInt8(0))));
            }
          });
          break;
        case REDIS_RDB_ENC_INT16:
          getFixedBytes(2, function(err, buffers) {
            if(err) {
              cb(err);
            } else {
              cb(null, new Buffer(String(Buffer.concat(buffers).readInt16LE(0))));
            }
          });
          break;
        case REDIS_RDB_ENC_INT32:
          getFixedBytes(4, function(err, buffers) {
            if(err) {
              cb(err);
            } else {
              cb(null, new Buffer(String(Buffer.concat(buffers).readInt32LE(0))));
            }
          });
          break;
        case REDIS_RDB_ENC_LZF:
          getEncodedLen(function(err, encLen) {
            if(err) {
              return cb(err);
            }
            getEncodedLen(function(err, len) {
              if(err) {
                return cb(err);
              }
              getFixedBytes(encLen, function(err, buffers) {
                if(err) {
                  return cb(err);
                }
                var compressed = Buffer.concat(buffers);
                var decompressed = lzf.decompress(compressed);
                cb(null, decompressed);
              });
            });
          });
          break;
        default:
          cb('unknown encoding');
        }
      } else {
        // FIXME can getFixedBytes be called inside a callback?
        getFixedBytes(encLen, function(err, buffers) {
          if(err) {
            cb(err);
          } else {
            cb(null, Buffer.concat(buffers));
          }
        });
      }
    });
  }