How to use the typechecker.isObject 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 / projectz / source / lib / projectz.js View on Github external
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)) {
			next(
				new Error(
					'projectz: licenses field is deprecated, you must now use the license field as a valid SPDX string: https://docs.npmjs.com/files/package.json#license'
				)
			)
			return this
		}

		// Validate package values
		for (const name in this.mergedPackageData.packages) {
			if (this.mergedPackageData.packages.hasOwnProperty(name)) {
				const value = this.mergedPackageData.packages[name]
				if (!isObject(value)) {
					next(
						new Error(
							`projectz: custom package data for package ${name} must be an object`
github bevry / projectz / source / lib / projectz.js View on Github external
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)) {
			next(
				new Error(
					'projectz: licenses field is deprecated, you must now use the license field as a valid SPDX string: https://docs.npmjs.com/files/package.json#license'
				)
			)
			return this
		}
github bevry / projectz / source / lib / projectz.js View on Github external
return this
		}
		if (isObject(this.mergedPackageData.licenses)) {
			next(
				new Error(
					'projectz: licenses field is deprecated, you must now use the license field as a valid SPDX string: https://docs.npmjs.com/files/package.json#license'
				)
			)
			return this
		}

		// Validate package values
		for (const name in this.mergedPackageData.packages) {
			if (this.mergedPackageData.packages.hasOwnProperty(name)) {
				const value = this.mergedPackageData.packages[name]
				if (!isObject(value)) {
					next(
						new Error(
							`projectz: custom package data for package ${name} must be an object`
						)
					)
					return this
				}
			}
		}

		// ----------------------------------
		// Merging

		// Set some basic object defaults
		extendr.defaults(this.mergedPackageData, {
			badges: {},

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