Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
}
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
}