promises.push(processJob(chunk[i], clone(configuration), false))
// sign params, add signature. Return the created payload function signedParams(method, path, host, keys, params = {}) { params = defaults(clone(params), { access_key: keys.accessKey, timestamp: new Date().toISOString() }); params.signature = generateHmacSignature(method, path, host, keys, params); return params; }
function run(fns, data, testname) { let k, arr, res=[]; for (k in fns) { arr = clone(data); // `reduce` mutates res.push( test(k, fns[k], arr) ); } report(res, testname); }
UPLOAD_SOUND_RESET (state) { Object.keys(clone(initialState)).forEach(key => { state[key] = initialState[key] }) }
// Create signature using method, path, host access key and query function generateHmacSignature(method, path, host, keys, params) { const paramsCopy = clone(params); const signatureData = `${method.toUpperCase()};${host.toLowerCase()};${path};${buildSortedQuery( paramsCopy )}`; //console.log(`Signature data: ${signatureData}`); const hmac = crypto.createHmac('sha256', keys.secretKey.toUpperCase()); hmac.update(signatureData); return hmac.digest('base64'); }
/** * Recalculates rules * * @param rules */ recalcRules(rules) { let firstVal = rules.shift(); let newVal = { rules: [firstVal] }; if (typeof firstVal === 'boolean') { newVal = firstVal; } for (let rule of rules) { newVal = clone(this.getNewApplyValue(clone(newVal), clone(rule))); } return newVal; }
/** * Wraps model to build an access map * * @param model * @param ctx * @param options */ constructor(model, ctx, options = {}, parentData) { debug(model.getName(), 'constructor', options); // TODO: filter by requested fields this.parentData = parentData; // TODO: deprecated? this.model = model; this.ctx = ctx; this.options = options; this.sourceACLs = clone(options.acls || model.getACLs()); //let staticRoles = this.model.getStaticRoles(ctx); this.staticRoles = this.model.getStaticRoles(ctx); this.dynamicRoles = this.model.getRealDynamicRoles(ctx); }
// -- private methods: function parseModelAttributes (attrs, we) { if (!attrs) return {}; let attr = {}; for (let name in attrs) { attr[name] = clone(attrs[name]); attr[name].type = getModelTypeFromDefinition(attrs[name], we); } return attr; }
const modelsUsed = Object.keys(assign(clone(this.api) || {}, this.plugins)) .filter(x => isObject(get(this.api, [x, 'models']) || get(this.plugins, [x, 'models']))) // Filter API with models .map(x => get(this.api, [x, 'models']) || get(this.plugins, [x, 'models'])) // Keep models
let args = clone(paramsCollection[0].arguments); args[0] = _;
let rule = clone(sourceRule);
acls = clone(acls); acls = acls.map(rule => {
/** * Remove unmatched properties if specified * * @param properties * @param sourceRule * @returns {*} */ filterRuleProperties(properties, sourceRule) { if (!properties) { return sourceRule; } let rule = clone(sourceRule); if (~rule.properties.indexOf('*')) { return rule; } rule.properties = rule.properties.filter(prop => ~properties.indexOf(prop)); if (!rule.properties.length) { return null; } return rule; }
/** * Input data will have global id but we can only work internally with database id */ extractInputKeys(data) { let input = clone(data); for (let key of Object.keys(input)) { let prop = this.publicProperties[key]; // typeof check is added in order to avoid attempts to convert already substituted ObjectId like userId // TODO: but it looks like kind of workaround if (prop && prop.type == 'id' && typeof input[key] === 'string') { input[key] = fromGlobalId(input[key]).id; } } return input; }
RESET_SOUND_POSITION (state) { state.soundPosition = clone(initSoundPosition) }