array-merges

    0.1.0 • Public • Published

    array-merge

    Merge arrays under strategy

    Example

    var merge = require('array-merges');
    var arr = merge([{a: 1}], [{a: 1}], {
      equal: function(prev, next) {
        return prev.a === next.a;
      },
      onMerge: function(prev, next) {
        return [prev, next];
      }
    });
    console.log(arr); // [{a: 1}, {a: 1}]

    Options

    • options.equal: Function used to make comparation. Default is
    function (prev, next) {
      return prev === next;
    }
    • options.onMerge: Hook that determines the merge result between two elements that are judged as equal. Default is
    function(prev, next) {
      return [prev];  // abandon dulicate element
    }

    Lisence

    MIT

    Keywords

    Install

    npm i array-merges

    DownloadsWeekly Downloads

    3

    Version

    0.1.0

    License

    none

    Last publish

    Collaborators

    • luckydrq