How to use the typechecker.isEmptyArray 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 / boundation / source / package.js View on Github external
const result = arrangekeys(
				edition,
				'description directory entry tags engines'
			)
			if (result.tags) result.tags = Array.from(result.tags.values())
			return result
		})
	} else {
		delete packageData.editions
	}

	// trim empty keys
	for (const key in packageData) {
		if (packageData.hasOwnProperty(key)) {
			const value = packageData[key]
			if (typeChecker.isArray(value) && typeChecker.isEmptyArray(value)) {
				console.log(`trim: array: package.json:${key}`)
				delete packageData[key]
			} else if (
				typeChecker.isPlainObject(value) &&
				typeChecker.isEmptyPlainObject(value)
			) {
				console.log(`trim: empty: package.json:${key}`)
				delete packageData[key]
			} else if (value == null || value === '') {
				console.log(`trim: null|'': package.json:${key}`)
				delete packageData[key]
			}
		}
	}

	// ---------------------------------

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