test(`coverage is ignored if it's ${JSON.stringify(arg)}`, function (t) { t.plan(2) const cwd = tempy.directory() const nyc = path.join(cwd, '.nyc_output') cc.write(cwd, arg, function (err) { t.ifError(err) fs.readdir(nyc, function (err) { t.is(err.code, 'ENOENT') }) }) })
getVersion((err, tag) => { if (err) { throw err; } getBranch((err, branch) => { if (err) { throw err; } pjs.version = getPackageVersion(tag, branch); fs.writeFileSync(pjsPath, JSON.stringify(pjs, null, 2)); }) });
function dispatch(type, id, arg) { let selectedID = lastID+1; if (selectedID > numCPUs-1) selectedID = 0; cluster.workers[workers[selectedID]].send(JSON.stringify({ id, type, arg })); lastID = selectedID; }
it('serialized httpResponse correctly with body string', () => { const httpResponse = new HTTPResponse({}, 'hello'); expect(httpResponse.text).toBe('hello'); expect(httpResponse.data).toBe(undefined); expect(httpResponse.body).toBe('hello'); const serialized = JSON.stringify(httpResponse); const result = JSON.parse(serialized); expect(result.text).toBe('hello'); expect(result.data).toBe(undefined); expect(result.body).toBe(undefined); });
function setItem( key, value ) { try { localStorage.setItem( key, JSON.stringify( value ) ); } catch ( e ) { debug( 'couldnt set localStorage item for: %s', key ); } }
function logTriggerSuccessBeforeHook(triggerType, className, input, result, auth) { const cleanInput = _logger.logger.truncateLogMessage(JSON.stringify(input)); const cleanResult = _logger.logger.truncateLogMessage(JSON.stringify(result)); _logger.logger.info(`${triggerType} triggered for ${className} for user ${userIdForLog(auth)}:\n Input: ${cleanInput}\n Result: ${cleanResult}`, { className, triggerType, user: userIdForLog(auth) }); }
const _sendMessage = (message) => { if (typeof localStorage !== 'undefined') { const timestamp = Math.floor(new Date().getTime() / 1000) localStorage.setItem('nextauth.message', JSON.stringify({ ...message, clientId: __NEXTAUTH._clientId, timestamp })) // eslint-disable-line } }
it('should handle a compressed response', async function() { const res = await this.relativeFetch('/compress', { method: 'POST', body: JSON.stringify({ foo: 'bar' }), headers: { 'Content-Type': 'application/json' } }); expect(res.status).to.equal(200); expect(await res.json()).to.deep.equal({ foo: 'bar' }); });
const transformer = atom => { const result = transformFunction(atom, field); if (result === CannotTransform) { throw new Parse.Error( Parse.Error.INVALID_JSON, `bad atom: ${JSON.stringify(atom)}` ); } return result; }
toFunctionString() { return ` var characterTable = ${JSON.stringify(this.characterTable)}; var indexTable = ${JSON.stringify(this.indexTable)}; var characters = ${JSON.stringify(this.characters)}; var dataFormatter = { toIndexes: ${this.toIndexes.toString()}, toIndexesInputOutput: ${this.toIndexesInputOutput.toString()}, toCharacters: ${this.toCharacters.toString()}, };`; }
/** * Logs any error notice which is shown to the user so we can determine how often * folks see different errors and what types of sites they occur on. * * @param {string} content The error message. Like "Update failed." * @param {object} options Optional. Extra data logged with the error in Gutenberg. */ const trackErrorNotices = ( content, options ) => tracksRecordEvent( 'wpcom_gutenberg_error_notice', { notice_text: content, notice_options: JSON.stringify( options ), // Returns undefined if options is undefined. } )
/** * @description Save gateway user keys. * @param {Array} keys - Array of keys. * @example * saveUsersKeys([]); */ async function saveUsersKeys(keys) { await this.variable.setValue('GLADYS_GATEWAY_USERS_KEYS', JSON.stringify(keys)); }
/* * Deep clone an object. * Note: This will not clone functions and dates * @param {object} object Object to clone * @return {object} */ deepClone (object) { return JSON.parse(JSON.stringify(object)) }
logResponse({ method, url, result }) { this.verbose(() => { const stringifiedResponse = JSON.stringify(result, null, 2); return `RESPONSE from [${method}] ${url}: ${stringifiedResponse}`; }, { result: result }); }
function sendWsMessage(type, data){ if(wsConnection){ var message = { type: type, data: data }; wsConnection.send(JSON.stringify(message)); } }