Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 3x 3x 3x 1x 1x 3x 2x 2x 2x 1x 1x | const checkForError = require('./src/checkForError'); /** * Get first key of object, with string key * @param {Object} object - input object * @param {Boolean} fatalError - should error be thrown in case no keys are found? * @returns {String} first key if input is indeed object */ const getFirstKeyFromObject = (object, fatalError) => { if (typeof object === 'object') { const element = Object.keys(object)[0]; if (element !== undefined) { return element; } } checkForError(fatalError); return undefined; }; module.exports = getFirstKeyFromObject; |