Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wikibase-sdk

Package Overview
Dependencies
Maintainers
1
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wikibase-sdk - npm Package Compare versions

Comparing version 7.10.0 to 7.11.0

3

CHANGELOG.md
# CHANGELOG
*versions follow [SemVer](http://semver.org)*
## 7.11.0 - 2021-04-10
* Added [`simplify.references`](https://github.com/maxlath/wikidata-sdk/blob/master/docs/simplify_claims.md#simplify-references) function
## 7.10.0 - 2021-04-10

@@ -5,0 +8,0 @@ * Added [`cirrusSearchPages`](https://github.com/maxlath/wikidata-sdk/blob/master/docs/search_entities.md#cirrussearchpages) function

39

lib/helpers/simplify_claims.js

@@ -120,3 +120,3 @@ const { parse: parseClaim } = require('./parse_claim')

if (keepQualifiers) {
valueObj.qualifiers = simplifyClaims(claim.qualifiers, subSnaksOptions)
valueObj.qualifiers = simplifyQualifiers(claim.qualifiers, subSnaksOptions)
}

@@ -126,7 +126,3 @@

claim.references = claim.references || []
valueObj.references = claim.references.map(refRecord => {
const snaks = simplifyClaims(refRecord.snaks, subSnaksOptions)
if (keepHashes) return { snaks, hash: refRecord.hash }
else return snaks
})
valueObj.references = simplifyReferences(claim.references, subSnaksOptions)
}

@@ -149,15 +145,29 @@

const simplifyQualifiers = (claims, options) => {
return simplifyClaims(claims, getSubSnakOptions(options))
const simplifyQualifiers = (qualifiers, options) => {
return simplifyClaims(qualifiers, getSubSnakOptions(options))
}
const simplifyPropertyQualifiers = (propClaims, options) => {
return simplifyPropertyClaims(propClaims, getSubSnakOptions(options))
const simplifyPropertyQualifiers = (propertyQualifiers, options) => {
return simplifyPropertyClaims(propertyQualifiers, getSubSnakOptions(options))
}
// Using a new object so that the original options object isn't modified
const getSubSnakOptions = options => {
return Object.assign({}, options, { areSubSnaks: true })
const simplifyReferences = (references, options) => {
return references.map(refRecord => {
return simplifyReferenceRecord(refRecord, options)
})
}
const simplifyReferenceRecord = (refRecord, options) => {
const subSnaksOptions = getSubSnakOptions(options)
const snaks = simplifyClaims(refRecord.snaks, subSnaksOptions)
if (subSnaksOptions.keepHashes) return { snaks, hash: refRecord.hash }
else return snaks
}
const getSubSnakOptions = (options = {}) => {
if (options.areSubSnaks) return options
// Using a new object so that the original options object isn't modified
else return Object.assign({}, options, { areSubSnaks: true })
}
const keepOptions = [ 'keepQualifiers', 'keepReferences', 'keepIds', 'keepHashes', 'keepTypes', 'keepSnaktypes', 'keepRanks', 'keepRichValues' ]

@@ -180,3 +190,4 @@

simplifyPropertyQualifiers,
simplifyQualifier: simplifyClaim
simplifyQualifier: simplifyClaim,
simplifyReferences,
}

@@ -9,3 +9,4 @@ const { labels, descriptions, aliases, lemmas, glosses } = require('./simplify_text_attributes')

simplifyPropertyQualifiers: propertyQualifiers,
simplifyQualifiers: qualifiers
simplifyQualifiers: qualifiers,
simplifyReferences: references,
} = require('./simplify_claims')

@@ -29,2 +30,3 @@

qualifiers,
references,
sitelinks,

@@ -31,0 +33,0 @@

{
"name": "wikibase-sdk",
"version": "7.10.0",
"version": "7.11.0",
"description": "utils functions to query a Wikibase instance and simplify its results",

@@ -5,0 +5,0 @@ "main": "lib/wikibase-sdk.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc