コード例 #1
0
ファイル: paycheck.js プロジェクト: nightlifemusic/paycheck
    match(payloadIn, payloadTemplate) {
        var payload = _.cloneDeep(payloadIn);
        var template = _.cloneDeep(payloadTemplate);

        // strip all wildcards out of template and payload
        _.deepMapValues(payloadTemplate, (value, path) => {
            if (/\<\%\= *\* *\%\>/.test(value)) {
                _.unset(template, path);
                _.unset(payload, path);
            }
        });

        // compare for equality - partially matching on any array defined in template
        let isMatch = _.isEqualWith(payload, template, (p, t, k) => { // p - from payload, t - from template, k - key 
            if (_.isArray(t)) { // 
                p = (_.isArray(p))? p : [p];
                return _(p)  
                    .intersectionWith(t, _.isEqual) // finds common
                    .value().length == p.length; // 
            }
        })

        if(!isMatch) this.log.error("paycheck cannot match ", JSON.stringify(payload), JSON.stringify(template))

        return isMatch;
    }
コード例 #2
0
 return find(callSites, callSite =>
   isEqualWith(callSite.location, location, (cloc, loc) => {
     return (
       loc.line === cloc.start.line &&
       (loc.column >= cloc.start.column && loc.column <= cloc.end.column)
     );
   })
コード例 #3
0
const isEq = (o1, o2) => {
  const isEq = isEqualWith(o1, o2, function(val1, val2) {
    if (isFunction(val1) && isFunction(val2)) {
      return val1 === val2 || val1.toString() === val2.toString();
    }
  });
  return isEq;
};
コード例 #4
0
ファイル: paycheck.js プロジェクト: nightlifemusic/paycheck
 isStructureSame(a, b) { // same structure, excluding arrays
     return _.isEqualWith(a, b, 
         (a, b) => { 
             // is object and not an array, ie, arrays are considered as values
             if(!(_.isObject(a) && !_.isArray(a)) && 
                !(_.isObject(b) && !_.isArray(b)))
                 return true;
         }
     )
 }
コード例 #5
0
/**
 * Returns whether the two expressions refer to the same object (e.g. a['b'].c and a.b.c)
 * @param {Object} a
 * @param {Object} b
 * @returns {boolean}
 */
function isEquivalentExp(a, b) {
    return _.isEqualWith(a, b, (left, right, key) => {
        if (_.includes(['loc', 'range', 'computed', 'start', 'end'], key)) {
            return true
        }
        if (isComputed(left) || isComputed(right)) {
            return false
        }
        if (key === 'property') {
            const leftValue = left.name || left.value
            const rightValue = right.name || right.value
            return leftValue === rightValue
        }
    })
}
コード例 #6
0
/**
 * Returns whether the two expressions refer to the same object (e.g. a['b'].c and a.b.c)
 * @param {Object} a
 * @param {Object} b
 * @returns {boolean}
 */
function isEquivalentExp(a, b) {
    return _.isEqualWith(a, b, function (left, right, key) {
        if (_.includes(["loc", "range", "computed", "start", "end"], key)) {
            return true;
        }
        if (isComputed(left) || isComputed(right)) {
            return false;
        }
        if (key === "property") {
            var leftValue = left.name || left.value;
            var rightValue = right.name || right.value;
            return leftValue === rightValue;
        }
    });
}
コード例 #7
0
ファイル: index.js プロジェクト: JamesMGreene/chai-deep-match
    function assertDeepMatch( val, msg ) {

      var actual = this._obj;
      var expected = val;

      var isDeep = !!util.flag( this, 'deep' );

      if ( isDeep && typeof actual === 'object' && typeof expected === 'object' && ( expected == null || toString.call( expected ) !== '[object RegExp]' ) ) {
        if ( msg ) {
          util.flag( this, 'message', msg );
        }

        var matchResult = actual == null && expected == null;
        if ( matchResult === false ) {
          matchResult = whatwgUrlComparator( actual, expected );
        }
        // This particular `if` check is critical to correctly verifying URLs
        if ( matchResult === undefined ) {
          matchResult = _.isEqualWith( actual, expected, whatwgUrlComparator );

          if ( matchResult === false ) {
            matchResult = ( typeof actual === 'object' && typeof expected === 'object' && actual != null && expected != null && _.isMatchWith( actual, expected, whatwgUrlComparator ) );
          }
        }

        this.assert(
          matchResult,
          'expected #{this} to deeply match #{exp}',
          'expected #{this} to deeply not match #{exp}',
          expected,
          actual == null ? actual : pickDeep( actual, keysDeep( expected ) ),
          true
        );
      }
      else {
        _super.apply( this, arguments );
      }

    }
コード例 #8
0
ファイル: isEqualAst.js プロジェクト: apexearth/lebab
/**
 * True when two AST nodes are structurally equal.
 * When comparing objects it ignores the meta-data fields for
 * comments and source-code position.
 * @param  {Object}  a
 * @param  {Object}  b
 * @return {Boolean}
 */
export default function isEqualAst(a, b) {
  return _.isEqualWith(a, b, (aValue, bValue, key) => metaDataFields[key]);
}
コード例 #9
0
ファイル: supportShim.js プロジェクト: Tharabas/sequelize
/**
 * Compares two options objects and returns if they are deep equal to each other.
 * Objects which are not plain objects (e.g. Models) are compared by reference.
 * Everything else deep-compared by value.
 *
 * @param {Object} options - Options object
 * @param {Object} original - Original options object
 * @returns {boolean} - true if options and original are same, false if not
 */
function optionsEqual(options, original) {
  return _.isEqualWith(options, original, (value1, value2) => {
    if (typeof value1 === 'object' && !_.isPlainObject(value1) || typeof value2 === 'object' && !_.isPlainObject(value2)) return value1 === value2;
  });
}
コード例 #10
0
ファイル: widgets.js プロジェクト: Brugis-SPRB/MapStore2
 (a, b) => isEqualWith(a, b, isShallowEqual)
コード例 #11
0
ファイル: deepEqual.js プロジェクト: HankMcCoy/redux-form
const deepEqual = (a: any, b: any) => isEqualWith(a, b, customizer)
コード例 #12
0
ファイル: deepEqual.js プロジェクト: HankMcCoy/redux-form
 obj.every((value, key) => {
   return other.has(key) && isEqualWith(value, other.get(key), customizer)
 })
コード例 #13
0
ファイル: deepEqual.js プロジェクト: Mnyanduga/redux-form
const deepEqual = (a, b) => isEqualWith(a, b, customizer)