How to use the @sindresorhus/is.function_ 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 sindresorhus / got / test / create.ts View on Github external
server.get('/', echoHeaders);

	const instance = got.extend({
		handlers: [
			async (options, next) => {
				const result = await next(options);
				// @ts-ignore Manual tests
				result.modified = true;

				return result;
			}
		]
	});

	const promise = instance('');
	t.true(is.function_(promise.cancel));
	// @ts-ignore Manual tests
	t.true((await promise).modified);
});
github googleapis / cloud-debug-nodejs / src / agent / util / utils.ts View on Github external
export function findScripts(
  scriptPath: string,
  config: ResolvedDebugAgentConfig,
  fileStats: ScanStats,
  logger: consoleLogLevel.Logger
): string[] {
  // (path: string, knownFiles: string[], resolved: string[]) => string[]
  const resolved = resolveScripts(scriptPath, config, fileStats);
  if (config.pathResolver) {
    if (!is.function_(config.pathResolver)) {
      logger.warn(
        `The 'pathResolver' config must be a function.  Continuing ` +
          `with the agent's default behavior.`
      );
      return resolved;
    }

    const knownFiles = Object.keys(fileStats);
    const calculatedPaths = config.pathResolver(
      scriptPath,
      knownFiles,
      resolved
    );
    if (calculatedPaths === undefined) {
      return resolved;
    }
github Hypercubed / f-flat_node / src / core / dict.ts View on Github external
rcl(this: StackEnv, a) {
    const r = this.dict.get(a);
    if (typeof r === 'undefined') {
      return null;
    }
    if (USE_STRICT && is.function_(r)) { // carefull pushing functions to stack, watch immutability
      return new Action(r);
    }
    return r instanceof Action ? new Just(r) : r;
  },
github sindresorhus / got / source / normalize-arguments.ts View on Github external
headers.accept = 'application/json';
	}

	if (options.decompress && is.undefined(headers['accept-encoding'])) {
		headers['accept-encoding'] = supportsBrotli ? 'gzip, deflate, br' : 'gzip, deflate';
	}

	// Validate URL
	if (options.url.protocol !== 'http:' && options.url.protocol !== 'https:') {
		throw new UnsupportedProtocolError(options);
	}

	decodeURI(options.url.toString());

	// Normalize request function
	if (!is.function_(options.request)) {
		options.request = options.url.protocol === 'https:' ? https.request : http.request;
	}

	// UNIX sockets
	if (options.url.hostname === 'unix') {
		const matches = /(?.+?):(?
github sindresorhus / got / test / stream.ts View on Github external
test('check for pipe method', withServer, (t, server, got) => {
	server.get('/', defaultHandler);

	const stream = got.stream('');
	t.true(is.function_(stream.pipe));
	t.true(is.function_(stream.on('foobar', () => {}).pipe));

	stream.destroy();
});
github sindresorhus / got / source / utils / is-form-data.ts View on Github external
export default (body: unknown): body is FormData => is.nodeStream(body) && is.function_((body as FormData).getBoundary);
github sindresorhus / got / source / request-as-event-emitter.ts View on Github external
get: (target, name) => {
							if (name === 'trailers' || name === 'rawTrailers') {
								return [];
							}

							const value = (target as any)[name];
							return is.function_(value) ? value.bind(target) : value;
						}
					});