How to use the object-hash.MD5 function in object-hash

To help you get started, we’ve selected a few object-hash examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hummal / crittr / src / classes / Ast.class.js View on Github external
});
                map.set(media, [...mediaRulesArr, ...newRules]);
            } else {
                // Fresh media rules can be created
                map.set(media, mRules.map(mRule => {
                    const objHash = hash.MD5(mRule);
                    return {
                        hash: objHash,
                        rule: mRule
                    }
                }));
            }
        } else {
            const ruleKey = Rule.generateRuleKey(ruleObj);
            const rulesArray = map.get(ruleKey);
            const objHash    = hash.MD5(ruleObj);

            if (rulesArray) {
                // If this rule object (hash) already exists in this ruleKey ignore else insert
                if (!rulesArray.some(ruleObj => ruleObj.hash === objHash)) {
                    rulesArray.push({
                        hash: objHash,
                        rule: ruleObj
                    });
                }
            } else {
                map.set(ruleKey, [
                    {
                        hash: objHash,
                        rule: ruleObj
                    }
                ]);
github kpi-wdc / dj / api / controllers / DataProcController.js View on Github external
process: function (req, res) {
    var tempObj = req.body;

    sails.log.debug("REQUEST ",req.body)
    // response type doesn't matter - we compute every time
    delete tempObj.response_type;
    var md5 = require('object-hash').MD5(tempObj);

    ProcData.findOneByHash(md5).then(function (json) {
      var obj_to_process = {};
      // json, corresponding to md5 hash of the request already
      // exists in a database, so there is no need to process it
      // again, just send back previous computational result
      if (json) {
        if (!json.parent) {
          delete json.parent;
        }
        json.data = json.value;
        delete json.value;
        if (req.body.response_type === 'data_id') {
          delete json.data;
        }
        delete json.hash;
github tungv / jerni / packages / jerni-dev / cli / fsQueue.js View on Github external
const parseJson = require("json-parse-better-errors");
const hash = require("object-hash");
const fs = require("fs");
const getLogger = require("./dev-logger");
const INITIAL_EVENT = { type: "@@INIT" };
const initialChecksum = hash.MD5(INITIAL_EVENT);

exports.checksumFile = function checksumFile(filePath) {
  const logger = getLogger({ service: "queue", verbose: true });

  if (!fs.existsSync(filePath)) {
    logger.info("creating new data file");
    fs.writeFileSync(filePath, `### BEGIN checksum: ${initialChecksum} ###`);
    return [initialChecksum, initialChecksum, []];
  }

  const data = String(fs.readFileSync(filePath));
  const rows = data.length ? data.split("\n") : [];
  const events = [];

  if (!rows[0] || !rows[0].length) {
    logger.info("data file is empty");
github kpi-wdc / dj / api / controllers / Cache.js View on Github external
.then(function(obj){
						if (obj){
							resolve( CacheData.update(
								{hash  : MD5(query)},
								{
									value : json,
									params: params,
									"tag" : tag
								})
							)
						}else{
							resolve(
							 CacheData.create({
								hash  : MD5(query),
								value : json,
								params: params,
								"tag" : tag
							})
							)					
						}
github pubpub / pubpub-editor / packages / pubpub-prose / src / editors / collaborativeEditor.js View on Github external
getHash = () => {
		const doc = this.view.state.doc;
		return MD5(JSON.parse(JSON.stringify(doc.toJSON())), {unorderedArrays: true});
	}
github atom / github / lib / cached-request.js View on Github external
cacheKey (key, obj) {
    return `${key}-${ObjectHash.MD5(obj)}`
  }
github jenkins-infra / evergreen / services / src / services / versions / versions.hooks.js View on Github external
computeManifestChecksum(context) {
    context.data.checksum = hash.MD5(context.data.manifest);
    return context;
  }
}
github imodeljs / imodeljs / presentation / backend / src / PresentationManager.ts View on Github external
private ensureRulesetRegistered(options: TOptions) {
    const { rulesetOrId, rulesetId, ...strippedOptions } = options;

    if (!rulesetOrId && !rulesetId)
      throw new PresentationError(PresentationStatus.InvalidArgument, "Neither ruleset nor ruleset id are supplied");

    let nativeRulesetId: string;
    if (rulesetOrId && typeof rulesetOrId === "object") {
      const rulesetNativeId = `${rulesetOrId.id}-${hash.MD5(rulesetOrId)}`;
      const rulesetWithNativeId = { ...rulesetOrId, id: rulesetNativeId };
      nativeRulesetId = this._rulesets.add(rulesetWithNativeId).id;
    } else {
      nativeRulesetId = rulesetOrId || rulesetId!;
    }

    return { rulesetId: nativeRulesetId, ...strippedOptions };
  }

object-hash

Generate hashes from javascript objects in node and the browser.

MIT
Latest version published 2 years ago

Package Health Score

78 / 100
Full package analysis