How to use the wikibase-sdk.simplify 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 / claim / find_snak.js View on Github external
const { claim: simplifyClaim } = require('wikibase-sdk').simplify
const _ = require('../utils')
// const findPropertyDataType = require('../properties/find_datatype')
const { parseUnit } = require('./quantity')
const error_ = require('../error')

module.exports = (property, datatype, propSnaks, value) => {
  if (!propSnaks) return

  const matchingSnaks = propSnaks.filter(isMatchingSnak(datatype, value))

  if (matchingSnaks.length === 0) return
  if (matchingSnaks.length === 1) return matchingSnaks[0]

  const context = { property, propSnaks, value }
  throw error_.new('snak not found: too many matching snaks', 400, context)
}
github maxlath / wikibase-edit / lib / claim / claim_parsers.js View on Github external
const { claim: simplifyClaim } = require('wikibase-sdk').simplify
const { hasSpecialSnaktype } = require('./special_snaktype')

module.exports = {
  matchClaim: value => claim => {
    if (typeof value === 'object') {
      if (hasSpecialSnaktype(value)) {
        if (claim.mainsnak.snaktype === value.snaktype) return true
      }
      value = value.value
    }
    return value === simplifyClaim(claim)
  },
  getGuid: claim => claim.id
}