How to use the wikidata-sdk.customize 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 / customized_wdk.js View on Github external
module.exports = program => {
  wdk.customize = (fnName, ...args) => {
    const urls = wdk[fnName].apply(null, args)
    const isSparqlFunction = sparqlFunctions.includes(fnName)
    const customizer = isSparqlFunction ? 'sparql_endpoint' : 'wikibase_instance'
    const { isCustomized, customize } = require(`./custom_${customizer}`)(program)
    if (!isCustomized) return urls
    if (typeof urls === 'string') return customize(urls)
    return urls.map(customize)
  }
  return wdk
}