How to use the @sindresorhus/is.number function in @sindresorhus/is

To help you get started, we’ve selected a few @sindresorhus/is examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github szmarczak / http2-wrapper / test / request.js View on Github external
test('`.maxHeadersCount` - getter', wrapper, async (t, server) => {
	const request = makeRequest(server.options);
	t.is(request.maxHeadersCount, undefined);
	request.end();

	await pEvent(request, 'response');
	request.abort();
	t.true(is.number(request.maxHeadersCount));
});
github szmarczak / http2-wrapper / test / response.js View on Github external
const response = await pEvent(request, 'response');
	response.resume();

	t.true(is.plainObject(response.headers));
	t.true(is.array(response.rawHeaders));
	t.true(is.plainObject(response.trailers));
	t.true(is.array(response.rawTrailers));
	t.is(request.socket, request.connection);
	t.is(response.socket, request.socket);
	t.is(response.connection, request.socket);
	t.truthy(response.req);
	t.is(response.httpVersion, '2.0');
	t.is(response.httpVersionMajor, 2);
	t.is(response.httpVersionMinor, 0);
	t.true(is.number(response.statusCode));
	t.is(response.statusMessage, '');
});
github sindresorhus / got / test / progress.ts View on Github external
const checkEvents: Macro<[Progress[], number?]> = (t, events, bodySize = undefined) => {
	t.true(events.length >= 2);

	let lastEvent = events.shift()!;

	if (!is.number(bodySize)) {
		t.is(lastEvent.percent, 0);
	}

	for (const [index, event] of events.entries()) {
		if (is.number(bodySize)) {
			t.is(event.percent, event.transferred / bodySize);
			t.true(event.percent > lastEvent.percent);
		} else {
			const isLastEvent = index === events.length - 1;
			t.is(event.percent, isLastEvent ? 1 : 0);
		}

		t.true(event.transferred >= lastEvent.transferred);
		t.is(event.total, bodySize);

		lastEvent = event;
	}
};
github sindresorhus / got / test / retry.ts View on Github external
calculateDelay: ({attemptCount}) => {
				t.true(is.number(attemptCount));
				return attemptCount < 2 ? 1 : 0;
			}
		}
github sx1989827 / DOClever / node_modules / got / index.js View on Github external
if (iter > retries || !isRetryAllowed(err)) {
				return 0;
			}

			const noise = Math.random() * 100;

			return ((1 << iter) * 1000) + noise;
		};
	}

	if (is.undefined(opts.followRedirect)) {
		opts.followRedirect = true;
	}

	if (opts.timeout) {
		if (is.number(opts.timeout)) {
			opts.gotTimeout = {request: opts.timeout};
		} else {
			opts.gotTimeout = opts.timeout;
		}
		delete opts.timeout;
	}

	return opts;
}
github android-js / androidjs-builder / example / helloworld / node_modules / got / source / normalize-arguments.js View on Github external
options.hooks = {};
	} else if (!is.object(options.hooks)) {
		throw new TypeError(`Parameter \`hooks\` must be an object, not ${is(options.hooks)}`);
	}

	for (const event of knownHookEvents) {
		if (is.nullOrUndefined(options.hooks[event])) {
			if (defaults) {
				options.hooks[event] = [...defaults.hooks[event]];
			} else {
				options.hooks[event] = [];
			}
		}
	}

	if (is.number(options.timeout)) {
		options.gotTimeout = {request: options.timeout};
	} else if (is.object(options.timeout)) {
		options.gotTimeout = options.timeout;
	}

	delete options.timeout;

	const {retry} = options;
	options.retry = {
		retries: 0,
		methods: [],
		statusCodes: [],
		errorCodes: []
	};

	if (is.nonEmptyObject(defaults) && retry !== false) {
github signalapp / Signal-Desktop / ts / components / Lightbox.tsx View on Github external
? this.renderObject({ objectURL, contentType, i18n, isViewOnce })
              : null}
            {caption ? <div style="{styles.caption}">{caption}</div> : null}
          
          <div style="{styles.controls}">
            
            {onSave ? (
              
            ) : null}
          </div>
        
        {isViewOnce &amp;&amp; is.number(videoTime) ? (
          <div style="{styles.navigationContainer}">
            <div style="{styles.timestampPill}">{formatDuration(videoTime)}</div>
          </div>
        ) : (
          <div style="{styles.navigationContainer}">
            {onPrevious ? (
              
            ) : (
              
            )}
            {onNext ? (
              
            ) : (
              
            )}
          </div>
github android-js / androidjs-builder / example / helloworld / node_modules / got / source / normalize-arguments.js View on Github external
delete options.timeout;

	const {retry} = options;
	options.retry = {
		retries: 0,
		methods: [],
		statusCodes: [],
		errorCodes: []
	};

	if (is.nonEmptyObject(defaults) && retry !== false) {
		options.retry = {...defaults.retry};
	}

	if (retry !== false) {
		if (is.number(retry)) {
			options.retry.retries = retry;
		} else {
			options.retry = {...options.retry, ...retry};
		}
	}

	if (options.gotTimeout) {
		options.retry.maxRetryAfter = Math.min(...[options.gotTimeout.request, options.gotTimeout.connection].filter(n => !is.nullOrUndefined(n)));
	}

	if (is.array(options.retry.methods)) {
		options.retry.methods = new Set(options.retry.methods.map(method => method.toUpperCase()));
	}

	if (is.array(options.retry.statusCodes)) {
		options.retry.statusCodes = new Set(options.retry.statusCodes);
github Hackdromeda / BugBrowser / node_modules / got / index.js View on Github external
if (iter &gt; retries || !isRetryAllowed(err)) {
				return 0;
			}

			const noise = Math.random() * 100;

			return ((1 &lt;&lt; iter) * 1000) + noise;
		};
	}

	if (is.undefined(opts.followRedirect)) {
		opts.followRedirect = true;
	}

	if (opts.timeout) {
		if (is.number(opts.timeout)) {
			opts.gotTimeout = {request: opts.timeout};
		} else {
			opts.gotTimeout = opts.timeout;
		}
		delete opts.timeout;
	}

	return opts;
}