src/modules/reduction.js
function init(collection) {
  switch (true) {
    case isImplemented(collection, 'init'):
      return collection[p.init];
    case isString(collection):
      return () => '';
    case isArray(collection):
      return () => [];
    case isObject(collection):
      return () => ({});
    case isFunction(collection):
      return () => {
        throw Error('init not available');
      };
    default:
      return null;
  }
}
function init(collection) {
  switch (true) {
    case isImplemented(collection, 'init'):
      return collection[p.init];
    case isString(collection):
      return () => '';
    case isArray(collection):
      return () => [];
    case isObject(collection):
      return () => ({});
    case isFunction(collection):
      return () => {
        throw Error('init not available');
      };
    default:
      return null;
  }
}
function init ( collection ) { switch ( true ) { case isImplemented ( collection , 'init' ) : return collection [ p . init ] ; case isString ( collection ) : return ( ) => '' ; case isArray ( collection ) : return ( ) => [ ] ; case isObject ( collection ) : return ( ) => ( { } ) ; case isFunction ( collection ) : return ( ) => { throw Error ( 'init not available' ) ; } ; default : return null ; } }
Returns an init function for a collection. This is a function that returns a new, empty instance of the collection in
question. If the collection doesn't support reduction, `null` is returned. This makes conditionals a bit easier to
work with.

In order to support the conversion of functions into reducers, function support is also provided.

@private

@param {*} collection A collection to create an init function for. This can be anything that supports the ES2015
iteration protocol, a plain object, a pre-ES2015 string or array, or a function.
@return {module:xduce~init} A function that, when called, returns an initial version of the provided collection. If
the provided collection is not iterable, then `null` is returned.
Returns an init function for a collection . This is a function that returns a new empty instance of the collection in question . If the collection doesn t support reduction null is returned . This makes conditionals a bit easier to work with .