Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 => {
.then(matchingClaimsGuids => {
matchingClaimsGuids.should.be.an.Array()
matchingClaimsGuids[0].should.be.an.String()
should(isItemId(matchingClaimsGuids[0].split('$')[0])).be.true()
done()
})
})
module.exports = id => {
if (!isItemId(id)) throw new Error(`invalid id: ${id}`)
return `SELECT ?item WHERE {
?item wdt:P31/wdt:P279* wd:${id} .
}`
}
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, '')