wikibase-sdk
Advanced tools
Comparing version 8.0.5 to 8.1.0
const { getSitelinkUrl } = require('./sitelinks') | ||
module.exports = (sitelinks, options = {}) => { | ||
const { addUrl } = options | ||
return Object.keys(sitelinks).reduce(aggregateValues(sitelinks, addUrl), {}) | ||
let { addUrl, keepBadges, keepAll } = options | ||
keepBadges = keepBadges || keepAll | ||
return Object.keys(sitelinks).reduce(aggregateValues({ | ||
sitelinks, | ||
addUrl, | ||
keepBadges | ||
}), {}) | ||
} | ||
const aggregateValues = (sitelinks, addUrl) => (index, key) => { | ||
const aggregateValues = ({ sitelinks, addUrl, keepBadges }) => (index, key) => { | ||
// Accomodating for wikibase-cli, which might set the sitelink to null | ||
@@ -15,5 +20,8 @@ // to signify that a requested sitelink was not found | ||
} | ||
const { title } = sitelinks[key] | ||
if (addUrl) { | ||
index[key] = { title, url: getSitelinkUrl(key, title) } | ||
const { title, badges } = sitelinks[key] | ||
if (addUrl || keepBadges) { | ||
index[key] = { title } | ||
if (addUrl) index[key].url = getSitelinkUrl(key, title) | ||
if (keepBadges) index[key].badges = badges | ||
} else { | ||
@@ -20,0 +28,0 @@ index[key] = title |
{ | ||
"name": "wikibase-sdk", | ||
"version": "8.0.5", | ||
"version": "8.1.0", | ||
"description": "utils functions to query a Wikibase instance and simplify its results", | ||
@@ -5,0 +5,0 @@ "main": "lib/wikibase-sdk.js", |
@@ -31,3 +31,2 @@ # wikibase-sdk | ||
- [Changelog](#changelog) | ||
@@ -34,0 +33,0 @@ - [Dependencies](#dependencies) |
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
63033
1576
168