Answers for "match property js"

0

match property js

const matchProperty = (data, compare) => {
	let compareIn = Object.keys(compare)
	let inData = Object.keys(data)
	const newInData = inData
		.slice(0, compareIn.length)
		.map((v, i) => {
			if (v !== compareIn[i]) {
				return compareIn[i]
			}
		})
		.map((v) => v !== undefined && true)
	return newInData.includes(true) ? false : true
}

let data = { directory: null, pattern: null, fileName: null, extension: null }
let compare = { directory: null, patternx: null }

let res = matchProperty(data, compare)
console.log(res)
Posted by: Guest on July-19-2021
0

js match property

export const matchProperty = (data: Record<string, any>, compare: Record<string, any>): boolean => {
	let compareIn = Object.keys(compare)
	const newInData = compareIn.map((v) => `${v}` in data)
	return newInData.includes(false) ? false : true
}
Posted by: Guest on July-19-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language