function generateBinArgs( name ) { if ( Object.prototype.hasOwnProperty.call( config.codemodArgs, name ) ) { // Is the codemod defined in the codemodArgs object? return config.codemodArgs[ name ]; } if ( getLocalCodemodFileNames().includes( name ) ) { return [ `--transform=${ transformsDir }/${ name }.js` ]; } throw new Error( `"${ name }" is an unrecognized codemod.` ); }
function getNormalizedKey(key) { const normalizedKey = getNormalizedKeyAttributeValue(key); if (key !== normalizedKey) { this.debugSection('Input', `Mapping key '${key}' to '${normalizedKey}'`); } // Use key definition to ensure correct key is displayed when Shift modifier is active if (Object.prototype.hasOwnProperty.call(keyDefinitionMap, normalizedKey)) { return keyDefinitionMap[normalizedKey]; } return normalizedKey; }
/** * @desc Return WebGlUniformLocation for various variables * related to webGl program, such as user-defined variables, * as well as, dimension sizes, etc. */ getUniformLocation(name) { if (this.programUniformLocationCache.hasOwnProperty(name)) { return this.programUniformLocationCache[name]; } return this.programUniformLocationCache[name] = this.context.getUniformLocation(this.program, name); }
const getDateObject = (dateString) => { const date = new Date(dateString) // Thanks to https://stackoverflow.com/questions/1353684/detecting-an-invalid-date-date-instance-in-javascript if (Object.prototype.toString.call(date) === '[object Date]' && isNaN(date.getTime())) { throw new Error(`invalid date string ${dateString}`) } return date }
messagesByNonAuthor.map(message => updateReputation( message.senderId, communityId, MESSAGE_DELETED_SCORE, MESSAGE_DELETED ) )
Promise.all( filteredRecipients.map(async user => { const [channelPermissions, communityPermissions] = await Promise.all([ getUserPermissionsInChannel(user.userId, thread.channelId), getUserPermissionsInCommunity(thread.communityId, user.userId), ]); const isNotBlocked = !channelPermissions.isBlocked && !communityPermissions.isBlocked; // only return the user if they aren't blocked in both the community & channel return isNotBlocked ? user : null; }) )
function replaceTitle(title, dataRow) { if (typeof dataRow.data !== 'object') { return `${title} | {${JSON.stringify(dataRow.data)}}`; } // if `dataRow` is object and has own `toString()` method, // it should be printed if (Object.prototype.toString.call(dataRow.data) === (Object()).toString() && dataRow.data.toString() !== (Object()).toString()) { return `${title} | ${dataRow.data}`; } return `${title} | ${JSON.stringify(dataRow.data)}`; }
getInternalVariableName(name) { if (!this._internalVariableNames.hasOwnProperty(name)) { this._internalVariableNames[name] = 0; } this._internalVariableNames[name]++; if (this._internalVariableNames[name] === 1) { return name; } return name + this._internalVariableNames[name]; }
/** * Returns `true` if `v` is a DOM File instance, `false` otherwise. * * @param {any} v - instance to analyze * @returns {boolean} `true` if `v` is a DOM File instance */ function isFile( v ) { return v && Object.prototype.toString.call( v ) === '[object File]'; }
function applyDeviceTokenExists(where) { where = (0, _deepcopy.default)(where); if (!Object.prototype.hasOwnProperty.call(where, 'deviceToken')) { where['deviceToken'] = { $exists: true }; } return where; }
Object.keys(options).forEach(key => { if (!Object.prototype.hasOwnProperty.call(this, key)) { this[key] = options[key]; } });
export function dump(obj) { let out = ''; for (const key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { out += `${key}: ${obj[key]}\n`; } } return out; }
const getDateObject = (dateString) => { const date = new Date(dateString) // Thanks to https://stackoverflow.com/questions/1353684/detecting-an-invalid-date-date-instance-in-javascript if (Object.prototype.toString.call(date) === '[object Date]' && isNaN(date.getTime())) { throw new Error(`invalid date string ${dateString}`) } return date }
// If obj.hasOwnProperty has been overridden, then calling // obj.hasOwnProperty(prop) will break. // See: https://github.com/joyent/node/issues/1707 function hasOwnProperty(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
function convertKeyToRawKey(key) { if (Object.prototype.hasOwnProperty.call(keyUnicodeMap, key)) { return keyUnicodeMap[key]; } // Key is raw key when no representative unicode code point for value return key; }