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 Hypercubed / f-flat_node / src / env.js View on Github external
if (isImmediate(action)) {
            if (Array.isArray(tokenValue)) {
              return self.queueFront(tokenValue);
            }
            if (!is.string(tokenValue)) {
              return stackPush(tokenValue);
            }
            if (tokenValue[0] === IIF && tokenValue.length > 1) {
              tokenValue = tokenValue.slice(1);
            }

            const lookup = self.dict.get(tokenValue);

            if (Action.isAction(lookup)) {
              return self.queueFront(lookup.value);
            } else if (is.function(lookup)) {
              return dispatchFn(lookup, functionLength(lookup), tokenValue);
            } else if (lookup) {
              return stackPush(cloneDeep(lookup));
            }
            // throw new Error(`${action} is not defined`);
            throw new FFlatError(`${action} is not defined`, self);
          }
          return stackPush(action);
        case '@@Seq':
          return stackPush(...tokenValue);
        case '@@Just':
          return stackPush(tokenValue);
        case '@@Future':
          return action.isResolved() ? stackPush(...tokenValue) : stackPush(action);
        default:
          return stackPush(action);
github android-js / androidjs-builder / example / helloworld / node_modules / got / source / normalize-arguments.js View on Github external
if (isFormData(body)) {
			// Special case for https://github.com/form-data/form-data
			headers['content-type'] = headers['content-type'] || `multipart/form-data; boundary=${body.getBoundary()}`;
		} else if (options.form) {
			headers['content-type'] = headers['content-type'] || 'application/x-www-form-urlencoded';
			options.body = (new URLSearchParams(body)).toString();
		} else if (options.json) {
			headers['content-type'] = headers['content-type'] || 'application/json';
			options.body = JSON.stringify(body);
		}

		options.method = options.method ? options.method.toUpperCase() : 'POST';
	}

	if (!is.function(options.retry.retries)) {
		const {retries} = options.retry;

		options.retry.retries = (iteration, error) => {
			if (iteration > retries) {
				return 0;
			}

			if ((!error || !options.retry.errorCodes.has(error.code)) && (!options.retry.methods.has(error.method) || !options.retry.statusCodes.has(error.statusCode))) {
				return 0;
			}

			if (Reflect.has(error, 'headers') && Reflect.has(error.headers, 'retry-after') && retryAfterStatusCodes.has(error.statusCode)) {
				let after = Number(error.headers['retry-after']);
				if (is.nan(after)) {
					after = Date.parse(error.headers['retry-after']) - Date.now();
				} else {
github htaussig / ProcProj / canvasSketch / future3D / node_modules / got / source / request-as-event-emitter.js View on Github external
const get = async options => {
		const currentUrl = redirectString || requestUrl;

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

		decodeURI(currentUrl);

		let fn;
		if (is.function(options.request)) {
			fn = {request: options.request};
		} else {
			fn = options.protocol === 'https:' ? https : http;
		}

		if (agents) {
			const protocolName = options.protocol === 'https:' ? 'https' : 'http';
			options.agent = agents[protocolName] || options.agent;
		}

		/* istanbul ignore next: electron.net is broken */
		if (options.useElectronNet && process.versions.electron) {
			const r = ({x: require})['yx'.slice(1)]; // Trick webpack
			const electron = r('electron');
			fn = electron.net || electron.remote.net;
		}
github Hackdromeda / BugBrowser / node_modules / got / index.js View on Github external
flush(callback) {
			ee.emit('downloadProgress', {
				percent: 1,
				transferred: downloaded,
				total: downloadBodySize
			});

			callback();
		}
	});

	mimicResponse(res, progressStream);
	progressStream.redirectUrls = redirects;

	const response = opts.decompress === true &&
		is.function(decompressResponse) &&
		opts.method !== 'HEAD' ? decompressResponse(progressStream) : progressStream;

	if (!opts.decompress && ['gzip', 'deflate'].indexOf(res.headers['content-encoding']) !== -1) {
		opts.encoding = null;
	}

	ee.emit('response', response);

	ee.emit('downloadProgress', {
		percent: 0,
		transferred: 0,
		total: downloadBodySize
	});

	res.pipe(progressStream);
}
github sx1989827 / DOClever / node_modules / got / index.js View on Github external
}

		opts.method = (opts.method || 'POST').toUpperCase();
	}

	if (opts.hostname === 'unix') {
		const matches = /(.+?):(.+)/.exec(opts.path);

		if (matches) {
			opts.socketPath = matches[1];
			opts.path = matches[2];
			opts.host = null;
		}
	}

	if (!is.function(opts.retries)) {
		const retries = opts.retries;

		opts.retries = (iter, err) => {
			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;
	}
github sindresorhus / got / source / utils / is-form-data.js View on Github external
module.exports = body => is.nodeStream(body) && is.function(body.getBoundary);
github Hypercubed / f-flat_node / src / env.js View on Github external
'Action': action => {
        if (Array.isArray(action.value)) {
          return new Seq(self.expandAction(action.value));
        }
        const r = self.dict.get(action.value);
        return is.function(r) ? new Seq([action]) : self.expandAction(r);
      },
      'Array': arr => {
github integreat-io / integreat / lib / service / authenticate.js View on Github external
const requestFromAuthentication = (authentication, authenticator, adapter, request) => {
  if (authentication.status === 'granted') {
    const fn = authenticator[adapter.authentication]
    if (is.function(fn)) {
      const auth = fn(authentication)
      return { ...request, auth }
    }
  }

  return { ...request, auth: null }
}