PHP 7.4.33
Preview: hash.js Size: 1.47 KB
/var/www/uibuilder.cmshelp.dk/httpdocs/node_modules/eslint-module-utils/hash.js
/**
 * utilities for hashing config objects.
 * basically iteratively updates hash with a JSON-like format
 */

'use strict';

exports.__esModule = true;

const createHash = require('crypto').createHash;

const stringify = JSON.stringify;

/** @type {import('./hash').default} */
function hashify(value, hash) {
  if (!hash) { hash = createHash('sha256'); }

  if (Array.isArray(value)) {
    hashArray(value, hash);
  } else if (typeof value === 'function') {
    hash.update(String(value));
  } else if (value instanceof Object) {
    hashObject(value, hash);
  } else {
    hash.update(stringify(value) || 'undefined');
  }

  return hash;
}
exports.default = hashify;

/** @type {import('./hash').hashArray} */
function hashArray(array, hash) {
  if (!hash) { hash = createHash('sha256'); }

  hash.update('[');
  for (let i = 0; i < array.length; i++) {
    hashify(array[i], hash);
    hash.update(',');
  }
  hash.update(']');

  return hash;
}
hashify.array = hashArray;
exports.hashArray = hashArray;

/** @type {import('./hash').hashObject} */
function hashObject(object, optionalHash) {
  const hash = optionalHash || createHash('sha256');

  hash.update('{');
  Object.keys(object).sort().forEach((key) => {
    hash.update(stringify(key));
    hash.update(':');
    // @ts-expect-error the key is guaranteed to exist on the object here
    hashify(object[key], hash);
    hash.update(',');
  });
  hash.update('}');

  return hash;
}
hashify.object = hashObject;
exports.hashObject = hashObject;

Directory Contents

Dirs: 1 × Files: 34
Name Size Perms Modified Actions
- drwxr-xr-x 2025-03-28 11:04:30
Edit Download
241 B lrw-r--r-- 2025-03-28 11:04:36
Edit Download
8.52 KB lrw-r--r-- 2025-03-28 11:04:37
Edit Download
1.13 KB lrw-r--r-- 2025-03-28 11:04:37
Edit Download
1.56 KB lrw-r--r-- 2025-03-28 11:04:36
Edit Download
245 B lrw-r--r-- 2025-03-28 11:04:37
Edit Download
471 B lrw-r--r-- 2025-03-28 11:04:36
Edit Download
343 B lrw-r--r-- 2025-03-28 11:04:37
Edit Download
1.47 KB lrw-r--r-- 2025-03-28 11:04:36
Edit Download
428 B lrw-r--r-- 2025-03-28 11:04:37
Edit Download
2.20 KB lrw-r--r-- 2025-03-28 11:04:36
Edit Download
1.05 KB lrw-r--r-- 2025-03-28 11:04:36
Edit Download
80 B lrw-r--r-- 2025-03-28 11:04:37
Edit Download
1.02 KB lrw-r--r-- 2025-03-28 11:04:36
Edit Download
603 B lrw-r--r-- 2025-03-28 11:04:37
Edit Download
1.65 KB lrw-r--r-- 2025-03-28 11:04:36
Edit Download
591 B lrw-r--r-- 2025-03-28 11:04:37
Edit Download
5.33 KB lrw-r--r-- 2025-03-28 11:04:36
Edit Download
2.29 KB lrw-r--r-- 2025-03-28 11:04:37
Edit Download
190 B lrw-r--r-- 2025-03-28 11:04:37
Edit Download
8.01 KB lrw-r--r-- 2025-03-28 11:04:36
Edit Download
77 B lrw-r--r-- 2025-03-28 11:04:37
Edit Download
264 B lrw-r--r-- 2025-03-28 11:04:36
Edit Download
87 B lrw-r--r-- 2025-03-28 11:04:37
Edit Download
2.06 KB lrw-r--r-- 2025-03-28 11:04:36
Edit Download
157 B lrw-r--r-- 2025-03-28 11:04:37
Edit Download
1.77 KB lrw-r--r-- 2025-03-28 11:04:36
Edit Download
1.11 KB lrw-r--r-- 2025-03-28 11:04:37
Edit Download
8.07 KB lrw-r--r-- 2025-03-28 11:04:36
Edit Download
175 B lrw-r--r-- 2025-03-28 11:04:37
Edit Download
310 B lrw-r--r-- 2025-03-28 11:04:37
Edit Download
167 B lrw-r--r-- 2025-03-28 11:04:37
Edit Download
935 B lrw-r--r-- 2025-03-28 11:04:36
Edit Download
238 B lrw-r--r-- 2025-03-28 11:04:37
Edit Download
672 B lrw-r--r-- 2025-03-28 11:04:36
Edit Download
If ZipArchive is unavailable, a .tar will be created (no compression).