How to use the typechecker.isFunction function in typechecker

To help you get started, we’ve selected a few typechecker 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 bevry-archive / feedr / source / index.js View on Github external
parseResponse = generateParser.bind(
					null,
					feed.parse,
					plugins[feed.parse].parse
				)
			}

			// Missing
			else {
				next(new Error('Invalid parse value: ' + feed.parse))
				return this
			}
		}

		// Custom
		else if (typeChecker.isFunction(feed.parse)) {
			parseResponse = generateParser.bind(null, 'custom', feed.parse)
		}

		// Auto
		else if (feed.parse === true) {
			parseResponse = function(opts, parseComplete) {
				const checkTasks = new TaskGroup().done(parseComplete)
				eachr(plugins, function(value, key) {
					if (value.parse != null) {
						checkTasks.addTask(function(parseTaskComplete) {
							generateParser.bind(
								null,
								key,
								value.parse
							)(opts, function(err, data) {
								if (data) {
github sx1989827 / DOClever / Desktop / node_modules / extract-opts / es2015 / index.js View on Github external
module.exports = function (opts, next) {
	var config = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];

	// Empty, set default
	if (config.completionCallbackNames == null) {
		config.completionCallbackNames = ['next'];
	}

	// Not array, make array
	else if (typeChecker.isArray(config.completionCallbackNames) === false) {
			config.completionCallbackNames = [config.completionCallbackNames];
		}

	// Arguments
	if (typeChecker.isFunction(opts) && next == null) {
		next = opts;
		opts = {};
	} else if (!opts) {
		opts = {};
	}

	// Completion callback
	if (!next) {
		// Cycle the completionCallbackNames to check if the completion callback name exists in opts
		// if it does, then use it as the next and delete it's value
		eachr(config.completionCallbackNames, function (completionCallbackName) {
			if (typeof opts[completionCallbackName] !== 'undefined') {
				next = opts[completionCallbackName];
				delete opts[completionCallbackName];
				return false; // break
				// ^ why this only does the first, and not all, using the last, I don't know ...
github bevry-archive / feedr / source / index.js View on Github external
else {
			parseResponse = function(opts, parseComplete) {
				parseComplete()
			}
		}

		// ------------------------------
		// Checker

		let checkResponse = null

		// Specific
		if (typeChecker.isString(feed.check)) {
			// Exists
			if (
				typeChecker.isFunction(plugins[feed.check] && plugins[feed.check].check)
			) {
				checkResponse = generateChecker.bind(
					null,
					feed.check,
					plugins[feed.check].check
				)
			}

			// Missing
			else {
				next(new Error('Invalid check value: ' + feed.check))
				return this
			}
		}

		// Custom
github bevry-archive / feedr / source / index.js View on Github external
`Feedr check [${feed.url}] with ${name} attempt, success`
				)
				complete(null, data)
			})
		}

		// ------------------------------
		// Parser

		let parseResponse = null

		// Specific
		if (typeChecker.isString(feed.parse)) {
			// Exists
			if (
				typeChecker.isFunction(plugins[feed.parse] && plugins[feed.parse].parse)
			) {
				parseResponse = generateParser.bind(
					null,
					feed.parse,
					plugins[feed.parse].parse
				)
			}

			// Missing
			else {
				next(new Error('Invalid parse value: ' + feed.parse))
				return this
			}
		}

		// Custom
github sx1989827 / DOClever / Desktop / node_modules / extract-opts / source / index.js View on Github external
module.exports = function (opts, next, config = {}) {
	// Empty, set default
	if ( config.completionCallbackNames == null ) {
		config.completionCallbackNames = ['next']
	}

	// Not array, make array
	else if ( typeChecker.isArray(config.completionCallbackNames) === false ) {
		config.completionCallbackNames = [config.completionCallbackNames]
	}

	// Arguments
	if ( typeChecker.isFunction(opts) && next == null ) {
		next = opts
		opts = {}
	}
	else if ( !opts ) {
		opts = {}
	}

	// Completion callback
	if ( !next ) {
		// Cycle the completionCallbackNames to check if the completion callback name exists in opts
		// if it does, then use it as the next and delete it's value
		eachr(config.completionCallbackNames, function (completionCallbackName) {
			if ( typeof opts[completionCallbackName] !== 'undefined' ) {
				next = opts[completionCallbackName]
				delete opts[completionCallbackName]
				return false  // break
github bevry-archive / feedr / source / index.js View on Github external
checkResponse = generateChecker.bind(
					null,
					feed.check,
					plugins[feed.check].check
				)
			}

			// Missing
			else {
				next(new Error('Invalid check value: ' + feed.check))
				return this
			}
		}

		// Custom
		else if (typeChecker.isFunction(feed.check)) {
			checkResponse = generateChecker.bind(null, 'custom', feed.check)
		}

		// Auto
		else if (feed.check) {
			checkResponse = function(opts, checkComplete) {
				const checkTasks = new TaskGroup().done(checkComplete)
				eachr(plugins, function(value, key) {
					if (value.check != null) {
						checkTasks.addTask(function(checkTaskComplete) {
							generateChecker.bind(
								null,
								key,
								value.check
							)(opts, checkTaskComplete)
						})
github bevry-archive / feedr / source / index.js View on Github external
args.forEach(function(arg) {
			if (typeChecker.isString(arg)) {
				url = arg
			} else if (typeChecker.isFunction(arg)) {
				next = arg
			} else if (typeChecker.isPlainObject(arg)) {
				feed = arg
			}
		})

typechecker

Utilities to get and check variable types (isString, isPlainObject, isRegExp, etc)

Artistic-2.0
Latest version published 7 months ago

Package Health Score

70 / 100
Full package analysis