exec('node -v', function (err, stdout) { if (err) throw err; if (parseFloat(stdout.slice(1)) < 8) { throw new Error('React Slingshot requires node 8.0 or greater.'); } });
delete() { let value = this.value || ''; this.value = value ? value.slice(0, -1) : ''; this.cursor = value.length; this.render(); }
test('with custom timestamp', async ({ is }) => { var actual = '' const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'custom-time.js')]) child.stdout.pipe(writer((s, enc, cb) => { actual += s cb() })) await once(child, 'close') is(strip(actual).slice(0, 6), '[test]') })
function generateOfflineThreadingID() { var ret = Date.now(); var value = Math.floor(Math.random() * 4294967295); var str = ("0000000000000000000000" + value.toString(2)).slice(-22); var msgs = ret.toString(2) + str; return binaryToDecimal(msgs); }
/** * @private * @description Generate a backup key * @example * const key = await generateBackupKey(); * @returns {Promise} Resolving with the key. */ async function generateBackupKey() { const apiKey = (await randomBytes(Math.ceil(BACKUP_KEY_LENGTH / 2))).toString('hex').slice(0, BACKUP_KEY_LENGTH); return apiKey; }
function getPluginByRuleUrl(ruleUrl) { if (!ruleUrl || typeof ruleUrl != 'string') { return; } var index = ruleUrl.indexOf(':'); if (index == -1) { return null; } var protocol = ruleUrl.substring(0, index + 1); return pluginIsDisabled(protocol.slice(0, -1)) ? null : allPlugins[protocol]; }
source() { let value = this.value || '\n'; let short = <ReplOutputString str={value.slice(0, value.indexOf('\n'))} limit={ReplConstants.OUTPUT_TRUNCATE_LENGTH / 2}/>; return <ReplOutputCljsSource short={short} source={ReplCommon.highlight(this.value)}/> }
test('without timestamp', async ({ isNot }) => { var actual = '' const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'no-time.js')]) child.stdout.pipe(writer((s, enc, cb) => { actual += s cb() })) await once(child, 'close') isNot(strip(actual).slice(2), '[]') })
delete() { let value = this.value || ''; this.value = value ? value.slice(0, -1) : ''; this.cursor = value.length; this.render(); }