How to use the @sindresorhus/is.null 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 public-transport / hafas-client / test / lib / validate-line-without-mode.js View on Github external
a.strictEqual(typeof line.name, 'string', name + '.name must be a string')
	a.ok(line.name.length > 0, name + '.name can\'t be empty')

	// skipping line validation here
	// see https://github.com/derhuerst/hafas-client/issues/8#issuecomment-355839965
	if (is.undefined(line.mode) || is.null(line.mode)) {
		console.error(`ÖBB: Missing \`mode\` for line ${line.name} (at ${name}).`)
	}

	if (!is.undefined(line.subMode)) {
	a.fail(name + '.subMode is reserved an should not be used for now')
	}

	// todo: routes

	if (!is.null(line.operator) && !is.undefined(line.operator)) {
		validate(['operator'], line.operator, name + '.operator')
	}
}
github public-transport / hafas-client / test / lib / validate-line-without-mode.js View on Github external
const validateLineWithoutMode = (validate, line, name) => {
	validateItem(line, name)

	a.strictEqual(line.type, 'line', name + '.type must be `line`')

	validateReference(line.id, name + '.id')

	a.strictEqual(typeof line.name, 'string', name + '.name must be a string')
	a.ok(line.name.length > 0, name + '.name can\'t be empty')

	// skipping line validation here
	// see https://github.com/derhuerst/hafas-client/issues/8#issuecomment-355839965
	if (is.undefined(line.mode) || is.null(line.mode)) {
		console.error(`ÖBB: Missing \`mode\` for line ${line.name} (at ${name}).`)
	}

	if (!is.undefined(line.subMode)) {
	a.fail(name + '.subMode is reserved an should not be used for now')
	}

	// todo: routes

	if (!is.null(line.operator) && !is.undefined(line.operator)) {
		validate(['operator'], line.operator, name + '.operator')
	}
}
github htaussig / ProcProj / canvasSketch / future3D / node_modules / got / source / request-as-event-emitter.js View on Github external
setImmediate(async () => {
		try {
			// Convert buffer to stream to receive upload progress events (#322)
			const {body} = options;
			if (is.buffer(body)) {
				options.body = toReadableStream(body);
				uploadBodySize = body.length;
			} else {
				uploadBodySize = await getBodySize(options);
			}

			if (is.undefined(options.headers['content-length']) && is.undefined(options.headers['transfer-encoding'])) {
				if ((uploadBodySize > 0 || options.method === 'PUT') && !is.null(uploadBodySize)) {
					options.headers['content-length'] = uploadBodySize;
				}
			}

			for (const hook of options.hooks.beforeRequest) {
				// eslint-disable-next-line no-await-in-loop
				await hook(options);
			}

			requestUrl = options.href || (new URL(options.path, urlLib.format(options))).toString();

			await get(options);
		} catch (error) {
			emitError(error);
		}
	});
github Hackdromeda / BugBrowser / node_modules / got / index.js View on Github external
ee.on('response', res => {
			const stream = is.null(opts.encoding) ? getStream.buffer(res) : getStream(res, opts);

			stream
				.catch(err => reject(new got.ReadError(err, opts)))
				.then(data => {
					const statusCode = res.statusCode;
					const limitStatusCode = opts.followRedirect ? 299 : 399;

					res.body = data;

					if (opts.json && res.body) {
						try {
							res.body = JSON.parse(res.body);
						} catch (err) {
							if (statusCode >= 200 && statusCode < 300) {
								throw new got.ParseError(err, statusCode, opts, data);
							}
github sx1989827 / DOClever / node_modules / got / index.js View on Github external
ee.on('response', res => {
			const stream = is.null(opts.encoding) ? getStream.buffer(res) : getStream(res, opts);

			stream
				.catch(err => reject(new got.ReadError(err, opts)))
				.then(data => {
					const statusCode = res.statusCode;
					const limitStatusCode = opts.followRedirect ? 299 : 399;

					res.body = data;

					if (opts.json && res.body) {
						try {
							res.body = JSON.parse(res.body);
						} catch (err) {
							if (statusCode >= 200 && statusCode < 300) {
								throw new got.ParseError(err, statusCode, opts, data);
							}