function validateBodyLimitOption (bodyLimit) { if (bodyLimit === undefined) return if (!Number.isInteger(bodyLimit) || bodyLimit <= 0) { throw new TypeError(`'bodyLimit' option must be an integer > 0. Got '${bodyLimit}'`) } }
getSource(value) { if (this.origin === 'constants') { if (Number.isInteger(value)) { return `const float ${this.id} = ${value}.0;\n`; } return `const float ${this.id} = ${value};\n`; } return `uniform float ${this.id};\n`; }
test('detach child process', async t => { const {stdout} = await execa('detach'); const pid = Number(stdout); t.true(Number.isInteger(pid)); t.true(isRunning(pid)); process.kill(pid, 'SIGKILL'); });
static validateAccountLockoutPolicy(accountLockout) { if (accountLockout) { if (typeof accountLockout.duration !== 'number' || accountLockout.duration <= 0 || accountLockout.duration > 99999) { throw 'Account lockout duration should be greater than 0 and less than 100000'; } if (!Number.isInteger(accountLockout.threshold) || accountLockout.threshold < 1 || accountLockout.threshold > 999) { throw 'Account lockout threshold should be an integer greater than 0 and less than 1000'; } } }
describe('#getChatMembersCount', function getChatMembersCountSuite() { before(function before() { utils.handleRatelimit(bot, 'getChatMembersCount', this); }); it('should return an Integer', function test() { return bot.getChatMembersCount(GROUPID).then(resp => { assert.ok(Number.isInteger(resp)); }); }); });
addToMongooseSchema(schema) { const schemaOptions = { type: Number, validate: { validator: this.buildValidator(a => typeof a === 'number' && Number.isInteger(a)), message: '{VALUE} is not an integer value', }, }; schema.add({ [this.path]: this.mergeSchemaOptions(schemaOptions, this.config) }); }
// When parent process exits before child process const spawnAndKill = async (t, signal, cleanup, detached, isKilled) => { const subprocess = execa('sub-process', [cleanup, detached], {stdio: ['ignore', 'ignore', 'ignore', 'ipc']}); const pid = await pEvent(subprocess, 'message'); t.true(Number.isInteger(pid)); t.true(isRunning(pid)); process.kill(subprocess.pid, signal); await t.throwsAsync(subprocess); t.false(isRunning(subprocess.pid)); t.is(isRunning(pid), !isKilled); if (isRunning(pid)) { process.kill(pid, 'SIGKILL'); } }
/** * {{> switchTo }} */ async switchTo(locator) { if (Number.isInteger(locator)) { return this.browser.switchTo().frame(locator); } if (!locator) { return this.browser.switchTo().frame(null); } const els = await this._locate(withStrictLocator.call(this, locator), true); assertElementExists(els, locator); return this.browser.switchTo().frame(els[0]); }
/** * {{> switchTo }} */ async switchTo(locator) { if (Number.isInteger(locator)) { throw new Error('Not supported switching to iframe by number'); } if (!locator) { return this.t.switchToMainWindow(); } const el = await findElements.call(this, this.context, locator); return this.t.switchToIframe(el); }
const parseIntValue = value => { if (typeof value === 'string') { const int = Number(value); if (Number.isInteger(int)) { return int; } } throw new TypeValidationError(value, 'Int'); }
/** * @param {*} opts * @return {*} * @inner */ retry(opts) { if (!promise) return; if (opts === null) { opts = {}; } if (Number.isInteger(opts)) { opts = { retries: opts }; } return this.add(() => this.retries.push(opts)); }
function numberParser(key) { return function (opt) { const intOpt = parseInt(opt); if (!Number.isInteger(intOpt)) { throw new Error(`Key ${key} has invalid value ${opt}`); } return intOpt; }; }
_typeCheck(value) { return typeof value === 'string' || (Number.isInteger(value) && value >= 0); }
addToMongooseSchema(schema) { const schemaOptions = { type: Number, validate: { validator: this.buildValidator(a => typeof a === 'number' && Number.isInteger(a)), message: '{VALUE} is not an integer value', }, }; schema.add({ [this.path]: this.mergeSchemaOptions(schemaOptions, this.config) }); }
_typeCheck(value) { return typeof value === 'string' || (Number.isInteger(value) && value >= 0); }