PHP 7.4.33
Preview: matchNode.js Size: 971 B
/var/www/uibuilder.cmshelp.dk/httpdocs/node_modules/jscodeshift/src/matchNode.js
/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

'use strict';

const hasOwn =
  Object.prototype.hasOwnProperty.call.bind(Object.prototype.hasOwnProperty);

/**
 * Checks whether needle is a strict subset of haystack.
 *
 * @param {*} haystack Value to test.
 * @param {*} needle Test function or value to look for in `haystack`.
 * @return {bool}
 */
function matchNode(haystack, needle) {
  if (typeof needle === 'function') {
    return needle(haystack);
  }
  if (isNode(needle) && isNode(haystack)) {
    return Object.keys(needle).every(function(property) {
      return (
        hasOwn(haystack, property) &&
        matchNode(haystack[property], needle[property])
      );
    });
  }
  return haystack === needle;
}

function isNode(value) {
  return typeof value === 'object' && value;
}

module.exports = matchNode;

Directory Contents

Dirs: 3 × Files: 10
Name Size Perms Modified Actions
- drwxr-xr-x 2025-03-28 11:04:33
Edit Download
utils DIR
- drwxr-xr-x 2025-03-28 11:04:33
Edit Download
- drwxr-xr-x 2025-03-28 11:04:33
Edit Download
7.55 KB lrw-r--r-- 2025-03-28 11:04:33
Edit Download
11.85 KB lrw-r--r-- 2025-03-28 11:04:33
Edit Download
4.37 KB lrw-r--r-- 2025-03-28 11:04:33
Edit Download
648 B lrw-r--r-- 2025-03-28 11:04:33
Edit Download
1.73 KB lrw-r--r-- 2025-03-28 11:04:33
Edit Download
971 B lrw-r--r-- 2025-03-28 11:04:33
Edit Download
9.18 KB lrw-r--r-- 2025-03-28 11:04:33
Edit Download
4.79 KB lrw-r--r-- 2025-03-28 11:04:33
Edit Download
5.87 KB lrw-r--r-- 2025-03-28 11:04:33
Edit Download
5.48 KB lrw-r--r-- 2025-03-28 11:04:33
Edit Download
If ZipArchive is unavailable, a .tar will be created (no compression).