Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function logPatch(patch) {
const {type, path, ...rest} = patch
console.log(
// eslint-disable-line no-console
'%c%s%c %s =>',
'color:#2097ac',
type,
'color:inherit',
arrayToJSONMatchPath(path || []),
rest
)
}
export function toGradient(formBuilderPath: Path): string {
return arrayToJSONMatchPath(formBuilderPath)
}
function toGradientPatch(patch: Patch): GradientPatch {
const matchPath = arrayToJSONMatchPath(patch.path || [])
if (patch.type === 'insert') {
const {position, items} = patch
return {
insert: {
[position]: matchPath,
items: items
}
}
}
if (patch.type === 'unset') {
return {
unset: [matchPath]
}
}
export default function toGradientPatch(patch) {
const matchPath = arrayToJSONMatchPath(patch.path || [])
if (patch.type === 'insert') {
const {position, items} = patch
return {
insert: {
[position]: matchPath,
items: items
}
}
}
if (patch.type === 'unset') {
return {
unset: [matchPath]
}
}
function samePath(path, otherPath) {
return arrayToJSONMatchPath(path) === arrayToJSONMatchPath(otherPath)
}