How to use the typechecker.isString 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
next(new Error('Feed url was not supplied'))
			return this
		}

		// Check deprecations
		if (feed.checkReponse) {
			next(new Error('Feed checkResponse option is deprecated for check'))
			return this
		}

		// Ensure optional
		feed = this.prepareFeed(feed)

		// Plugins
		const plugins = {}
		if (typeChecker.isString(feed.plugins)) {
			feed.plugins = feed.plugins.split(' ')
		}
		if (typeChecker.isArray(feed.plugins)) {
			for (let i = 0; i < feed.plugins.length; ++i) {
				const name = feed.plugins[i]
				try {
					plugins[name] = require('./plugins/' + name)
				} catch (err) {
					next(err)
					return this
				}
			}
		}

		// Generators
		function generateParser(name, method, opts, complete) {
github bevry / projectz / source / lib / projectz.js View on Github external
}

		// Validate keywords field
		if (isString(this.mergedPackageData.keywords)) {
			next(new Error('projectz: keywords field must be array instead of CSV'))
			return this
		}

		// Validate sponsors array
		if (this.mergedPackageData.sponsor) {
			next(
				new Error('projectz: sponsor field is deprecated, use sponsors field')
			)
			return this
		}
		if (isString(this.mergedPackageData.sponsors)) {
			next(new Error('projectz: sponsors field must be array instead of CSV'))
			return this
		}

		// Validate maintainers array
		if (this.mergedPackageData.maintainer) {
			next(
				new Error(
					'projectz: maintainer field is deprecated, use maintainers field'
				)
			)
			return this
		}
		if (isString(this.mergedPackageData.maintainers)) {
			next(
				new Error('projectz: maintainers field must be array instead of CSV')
github bevry-archive / feedr / source / index.js View on Github external
}

		// Raw
		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
			}
github bevry / projectz / source / lib / projectz.js View on Github external
}
		if (isString(this.mergedPackageData.sponsors)) {
			next(new Error('projectz: sponsors field must be array instead of CSV'))
			return this
		}

		// Validate maintainers array
		if (this.mergedPackageData.maintainer) {
			next(
				new Error(
					'projectz: maintainer field is deprecated, use maintainers field'
				)
			)
			return this
		}
		if (isString(this.mergedPackageData.maintainers)) {
			next(
				new Error('projectz: maintainers field must be array instead of CSV')
			)
			return this
		}

		// Validate license SPDX string
		if (isObject(this.mergedPackageData.license)) {
			next(
				new Error(
					'projectz: license field must now be a valid SPDX string: https://docs.npmjs.com/files/package.json#license'
				)
			)
			return this
		}
		if (isObject(this.mergedPackageData.licenses)) {
github bevry-archive / feedr / source / index.js View on Github external
}
				me.log(
					'debug',
					`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
			}
github bevry / projectz / source / lib / projectz.js View on Github external
// ----------------------------------
		// Validation

		// Validate badges field
		if (this.mergedPackageData.badges && !this.mergedPackageData.badges.list) {
			next(
				new Error(
					'projectz: badges field must now be in the format of: {list: [], config: {}}\nSee https://github.com/bevry/badges for details.'
				)
			)
			return this
		}

		// Validate keywords field
		if (isString(this.mergedPackageData.keywords)) {
			next(new Error('projectz: keywords field must be array instead of CSV'))
			return this
		}

		// Validate sponsors array
		if (this.mergedPackageData.sponsor) {
			next(
				new Error('projectz: sponsor field is deprecated, use sponsors field')
			)
			return this
		}
		if (isString(this.mergedPackageData.sponsors)) {
			next(new Error('projectz: sponsors field must be array instead of CSV'))
			return this
		}
github bevry-archive / feedr / source / index.js View on Github external
tasks.addTask(function(complete) {
				// Prepare
				if (typeChecker.isString(feed)) {
					feed = { url: feed }
				}
				feeds[index] = feed = extendr.deep({}, defaultfeed, feed)

				// Read
				me.readFeed(feed, function(err, data) {
					// Handle
					if (err) {
						me.log(
							'warn',
							`Feedr failed to fetch [${feed.url}] to [${feed.path}]`,
							err.stack
						)
						failures.push(err)
					} else {
						results[index] = data
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 11 months ago

Package Health Score

70 / 100
Full package analysis