Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
});
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
}
]);
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;
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");
.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
})
)
}
getHash = () => {
const doc = this.view.state.doc;
return MD5(JSON.parse(JSON.stringify(doc.toJSON())), {unorderedArrays: true});
}
var attachHash = (entry) => {
entry.hash = hash.MD5(entry)
return entry
}
cacheKey (key, obj) {
return `${key}-${ObjectHash.MD5(obj)}`
}
computeManifestChecksum(context) {
context.data.checksum = hash.MD5(context.data.manifest);
return context;
}
}
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 };
}