How to use the wikibase-sdk.isItemId function in wikibase-sdk

To help you get started, we’ve selected a few wikibase-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-edit / lib / datatype_tests.js View on Github external
quantity: amount => {
    var unit
    amount = amount.value || amount
    if (_.isPlainObject(amount)) {
      unit = amount.unit || amount.value.unit
      amount = amount.amount || amount.value.amount
      if (!isItemId(parseUnit(unit)) && unit !== '1') return false
    } else {
      unit = '1'
    }
    // Accepting both numbers or string numbers as the amount will be
    // turned as a string lib/claim/builders.js signAmount function anyway
    return _.isNumber(amount) || _.isStringNumber(amount)
  },
  globecoordinate: obj => {
github maxlath / wikibase-edit / test / claim / exists.js View on Github external
.then(matchingClaimsGuids => {
        matchingClaimsGuids.should.be.an.Array()
        matchingClaimsGuids[0].should.be.an.String()
        should(isItemId(matchingClaimsGuids[0].split('$')[0])).be.true()
        done()
      })
    })
github maxlath / wikibase-cli / lib / queries / all_instances.js View on Github external
module.exports = id => {
  if (!isItemId(id)) throw new Error(`invalid id: ${id}`)

  return `SELECT ?item WHERE {
    ?item wdt:P31/wdt:P279* wd:${id} .
  }`
}
github maxlath / wikibase-edit / lib / claim / quantity.js View on Github external
parseQuantity: (amount, unit = '1') => {
    if (_.isPlainObject(amount)) ({ amount, unit } = amount)
    if (isItemId(unit)) unit = unitPrefix + unit
    if (_.isString(amount)) {
      if (!_.isStringNumber(amount)) throw error_.new('invalid string number', { amount, unit })
    }
    return { amount: signAmount(amount), unit }
  },
  parseUnit: unit => unit.replace(unitPrefix, '')