Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
, QProgress
if ( progressBar ) { QProgress = new progress(
'[:bar] Processing entity :current/:total: :q (eta :etas)',
{
complete: '='.green,
width: 20,
total: entKeys.length
}
) } else console.log( 'Processing recieved entity data...' )
for ( var entIndex = 0; entIndex < entKeys.length; entIndex++ ) {
var entKey = entKeys [ entIndex ]
, entity = entities[ entKey ]
entities[ entKey ] = wdk.simplifyClaims( entity.claims )
entity = entities[ entKey ]
var json = { wikiID: entKey, id: entKey }
, props = Object.keys( entity )
for ( var propIndex = 0; propIndex < props.length; propIndex++ ) {
var prop = props[ propIndex ]
, value = entity[ prop ]
var resp = parseProp( prop, value, lang )
json[ resp[ 0 ] ] = resp[ 1 ]
// Removing empty responses
delete json[ '' ]
return Promise.all(Object.keys(data.entities).map(async function (entityKey) {
const {labels, claims} = data.entities[entityKey]
const entity = wdk.simplifyClaims(claims, null, null, true)
const json = {
_wikiId: entityKey,
id: entityKey
}
await Promise.all(Object.keys(entity).map(async prop => {
const field = await parseWikidataPropAsync(prop, entity[prop], 'en')
if (field) {
const [fieldName, fieldValue] = field
if (Array.isArray(json[fieldName])) {
json[fieldName] = json[fieldName].concat(fieldValue)
} else if (fieldValue !== undefined) {
json[fieldName] = fieldValue
}
}
return Promise.all(Object.keys(data.entities).map(async function (entityKey) {
const {labels, claims} = data.entities[entityKey]
const entity = wdk.simplifyClaims(claims, null, null, true)
const json = {
_wikiId: entityKey,
id: entityKey
}
await Promise.all(Object.keys(entity).map(async prop => {
const field = await parseWikidataPropAsync(prop, entity[prop], 'en')
if (field) {
const [fieldName, fieldValue] = field
if (Array.isArray(json[fieldName])) {
json[fieldName] = json[fieldName].concat(fieldValue)
} else if (fieldValue !== undefined) {
json[fieldName] = fieldValue
}
}