Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = (pattern, filter, includeAllDetails, includeTypes) => data => {
// Special case: when the pattern is a property id, just log the property
if (isPropertyId(pattern) && data[pattern] != null) {
const prop = pattern
const obj = {}
obj[prop] = getValue(data[prop], includeAllDetails, includeTypes)
return JSON.stringify(obj, null, 2)
}
const propsData = {}
for (let prop in data) {
let propData = data[prop]
if (!filter || filter(propData)) {
let value = getValue(data[prop], includeAllDetails, includeTypes)
propsData[prop] = value
}
}
const getPropsAndSubKeys = propStr => {
const [ prop, subkey ] = propStr.split('.')
if (isPropertyId(prop)) return lazyProps.claims(prop)
else if (prop.match(langPattern)) return lazyProps.terms(prop)
else if (isSitelinkKey(prop)) return lazyProps.sitelinks(prop)
else return [ { prop, subkey } ]
}
property: value => {
if (isPropertyId(value)) {
return `wdt:${value}`
} else {
errors_.exit(`invalid property: ${value}`)
}
},
object: value => {
property: property => {
if (!_.isNonEmptyString(property)) {
throw error_.new('missing property', { property })
}
if (!isPropertyId(property)) {
throw error_.new('invalid property', { property })
}
},
language: language => {