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; }
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 }
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)}`; }
function getPrefix(access) { // prettier-ignore let prefix = `${yesNo(access.create)}Create${yesNo(access.read)}Read${yesNo(access.update)}Update${yesNo(access.auth)}Auth`; if (Object.prototype.hasOwnProperty.call(access, 'delete')) { prefix = `${prefix}${yesNo(access.delete)}Delete`; } return prefix; }
// Private function isArrayLike(x: mixed): boolean { return ( typeof x === 'object' && x !== null && typeof x.length === 'number' && (x.length === 0 || (x.length > 0 && Object.prototype.hasOwnProperty.call(x, x.length - 1))) ); }
// tslint:disable-next-line no-any function isPlainObject(obj: any) { if (!obj || typeof obj !== 'object' || String(obj) !== '[object Object]') return false; const proto = Object.getPrototypeOf(obj); if (proto === null || proto === Object.prototype) { return true; } return false; }
function init() { const { toString } = Object.prototype function getObjectTag(value) { return toString.call(value) } return getObjectTag }
/** * 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; }