wikibase-sdk
Advanced tools
Comparing version 9.2.0 to 9.2.1
@@ -95,9 +95,16 @@ import { wikibaseTimeToEpochTime, wikibaseTimeToISOString, wikibaseTimeToSimpleDay } from './time.js'; | ||
}; | ||
const normalizeDatatype = datatype => datatype.toLowerCase().replace(/[\s-]/g, ''); | ||
const normalizedParsers = {}; | ||
for (const [datatype, parser] of Object.entries(parsers)) { | ||
normalizedParsers[normalizeDatatype(datatype)] = parser; | ||
} | ||
export function parseClaim(datatype, datavalue, options, claimId) { | ||
// Known case of missing datatype: form.claims, sense.claims | ||
// Known case of missing datatype: form.claims, sense.claims, mediainfo.statements | ||
datatype = datatype || datavalue.type; | ||
// Known case requiring this: legacy "muscial notation" datatype | ||
datatype = datatype.replace(' ', '-'); | ||
try { | ||
return parsers[datatype](datavalue, options); | ||
// Known case requiring normalization | ||
// - legacy "muscial notation" datatype | ||
// - mediainfo won't have datatype="globe-coordinate", but datavalue.type="globecoordinate" | ||
const parser = normalizedParsers[normalizeDatatype(datatype)]; | ||
return parser(datavalue, options); | ||
} | ||
@@ -104,0 +111,0 @@ catch (err) { |
{ | ||
"name": "wikibase-sdk", | ||
"version": "9.2.0", | ||
"version": "9.2.1", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "utils functions to query a Wikibase instance and simplify its results", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
266423
3508