Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function nodeType (node) {
var v = type(node)
if (v === 'null' || node === false) return 'empty'
if (v !== 'object') return 'text'
if (type(node.type) === 'string') return 'element'
return 'component'
}
type(value, ctx, name) {
if (value == null) return true;
if (typeof name == 'function') {
return value.constructor === name;
}
return typeOf(value) === name;
},
this.onPageChange(newPage, oldPage);
}]);
this.ddListener.push(['on', 'change:product.id', (newProductId, oldProductId) => {
this.onProductChange(newProductId, oldProductId);
}]);
this.ddListener.push(['on', 'change:transaction.orderId', (newOrderId, oldOrderId) => {
this.onTransactionChange(newOrderId, oldOrderId);
}]);
}
const trackDOMComponents = this.options.trackDOMComponents;
if (!!window.jQuery && trackDOMComponents !== false) {
const options = {};
if (type(trackDOMComponents) === 'object') {
options.maxWebsiteWidth = trackDOMComponents.maxWebsiteWidth;
}
this.domComponentsTracking = new DOMComponentsTracking(options);
this.domComponentsTracking.initialize();
}
}
}
export const isType = (value, kind) => {
if (!kind) return type(value)
return type(value) === kind.toLowerCase()
}
export function isValidAttributeValue (value) {
var valueType = type(value)
switch (valueType) {
case 'string':
case 'number':
return true
case 'boolean':
return value
default:
return false
}
}
array: v => typeOf(v) === 'array',
boolean: v => typeOf(v) === 'boolean',
export function walk(obj, callback, path, prop) {
const type = typeOf(obj);
if (type === 'array') {
obj.forEach((v, i) =>
walk(v, callback, join(i, path), join('$', prop))
);
return;
}
if (type !== 'object') {
return;
}
for (const [key, val] of Object.entries(obj)) {
const newPath = join(key, path);
const newProp = join(key, prop);
if (callback(newPath, newProp)) {
export function nodeType (node) {
var v = type(node)
if (v === 'null' || node === false) return 'empty'
if (v !== 'object') return 'text'
if (type(node.type) === 'string') return 'element'
return 'component'
}
export function map (collection, fn) {
const kind = type(collection)
if (kind !== 'object' && kind !== 'array') {
return collection
}
const result = kind === 'array' ? [] : {}
each(collection, (value, key, collection) => {
result[key] = fn(value, key, collection)
})
return result
}