Пример #1
0
/**
 * @name maximum
 * @method
 * @memberof Frampton.List
 * @param {Array} xs
 */
export default function maximum(xs) {
  return foldl((acc, next) => {
    if (isNothing(acc) || next > acc) {
      acc = next;
    }
    return acc;
  }, null, xs);
}
Пример #2
0
/**
 * Extends one object with one or more other objects
 *
 * @name extend
 * @memberof Frampton.Utils
 * @method
 * @param {Object} base
 * @param {Object} args
 * @returns {Object}
 */
export default function extend(base, ...args) {
  return foldl((acc, next) => {
    for (let key in next) {
      if (next.hasOwnProperty(key)) {
        acc[key] = next[key];
      }
    }
    return acc;
  }, base, args);
}
Пример #3
0
/**
 * + sum :: Number a => List a -> a
 *
 * @name sum
 * @method
 * @memberof Frampton.List
 * @param {Array} xs
 */
export default function sum(xs) {
  return foldl((acc, next) => {
    return (acc + next);
  }, 0, xs);
}