How to use the wikidata-sdk.isPropertyId function in wikidata-sdk

To help you get started, we’ve selected a few wikidata-sdk 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 maxlath / wikibase-cli / lib / format_one_line_per_property.js View on Github external
module.exports = (pattern, filter) => data => {
  // Special case: when the pattern is a property id, just log the property
  if (wdk.isPropertyId(pattern) && data[pattern] != null) {
    const obj = {}
    obj[pattern] = data[pattern]
    return JSON.stringify(obj, null, 2)
  }

  var text = '{'
  for (let key in data) {
    let value = data[key]
    if (!filter || filter(value)) {
      let bla = `\n  "${key}": ${spacedInlinedJson(value)},`
      text += bla
    }
  }
  // Remove the last comma
  text = text.replace(/,$/, '')
  text += '\n}'