New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@citation-js/plugin-wikidata

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@citation-js/plugin-wikidata - npm Package Compare versions

Comparing version 0.6.4 to 0.6.5

27

lib-mjs/entity.js

@@ -7,3 +7,2 @@ import { logger } from '@citation-js/core';

import ignoredProps from './ignoredProps.json';
function resolve(parts, {

@@ -13,7 +12,5 @@ claims

const [prop, qualifier] = parts[0].split('#');
if (!claims[prop] || !claims[prop].length) {
return;
}
if (parts.length === 1) {

@@ -26,12 +23,8 @@ if (qualifier) {

}
return;
}
return claims[prop];
}
return resolve(parts.slice(1), claims[prop][0].value);
}
function resolveProp(prop_, entity, unknown) {

@@ -42,3 +35,2 @@ const parts = prop_.split('.');

}
function prepareValue(statement, entity, unknown) {

@@ -49,5 +41,3 @@ if (typeof statement !== 'object') {

}
const values = [].concat(...statement.props.map(prop => resolveProp(prop, entity, unknown)).filter(Boolean));
if (statement.values === 'all') {

@@ -59,3 +49,2 @@ return values[0] && values;

}
export function parseEntity(entity) {

@@ -70,9 +59,6 @@ const data = {

const unknown = new Set(Object.keys(entity.claims));
for (const prop in props) {
const input = prepareValue(props[prop], entity, unknown);
if (input) {
const output = parseProp(prop, input, entity);
if (output) {

@@ -83,9 +69,6 @@ data[prop] = output;

}
for (const prop in customProps) {
const input = prepareValue(customProps[prop], entity, unknown);
if (input) {
const output = parseProp(prop, input, entity);
if (output) {

@@ -96,3 +79,2 @@ data.custom[prop] = output;

}
for (const prop of unknown) {

@@ -102,10 +84,7 @@ if (prop in ignoredProps) {

}
logger.unmapped('[plugin-wikidata]', 'property', prop);
}
if (!data.title) {
data.title = getLabel(entity);
}
if (data.type.slice(0, 6) === 'review') {

@@ -117,11 +96,8 @@ delete data.keyword;

}
if (data.recipient) {
data.type = 'personal_communication';
}
if (data['event-title']) {
data.type = 'paper-conference';
}
if (typeof data['part-number'] === 'number') {

@@ -132,11 +108,8 @@ delete data['part-title'];

}
if (data.type !== 'chapter' && data['chapter-number']) {
delete data['chapter-number'];
}
if (data['original-author'] && !data.author) {
data.author = data['original-author'];
}
return data;

@@ -143,0 +116,0 @@ }

2

lib-mjs/id.js
import wdk from 'wikidata-sdk';
import config from './config.json';
function parseWikidata(data, langs) {

@@ -8,3 +7,2 @@ const list = [].concat(data);

}
export { parseWikidata as parse, parseWikidata as default };

@@ -28,3 +28,2 @@ import { plugins } from '@citation-js/core';

},
parseType: {

@@ -88,3 +87,2 @@ dataType: 'String',

},
parseType: {

@@ -91,0 +89,0 @@ dataType: 'Array',

@@ -6,7 +6,5 @@ import { logger } from '@citation-js/core';

import types from './types.json';
function getStatedAs(qualifiers) {
return [].concat(...[qualifiers.P1932, qualifiers.P1810].filter(Boolean));
}
function parseName({

@@ -17,7 +15,5 @@ value,

let [name] = getStatedAs(qualifiers);
if (!name) {
name = typeof value === 'string' ? value : getLabel(value);
}
name = name ? parseNameString(name) : {

@@ -27,14 +23,10 @@ literal: name

const ordinal = qualifiers.P1545 ? parseInt(qualifiers.P1545[0]) : null;
if (ordinal !== null) {
name._ordinal = ordinal;
}
return name;
}
function parseNames(values) {
return values.map(parseName).sort((a, b) => a._ordinal - b._ordinal);
}
function getPlace(value) {

@@ -49,7 +41,5 @@ const country = value.claims.P17[0].value;

}
function getTitle(value) {
return value.claims.P1476 ? value.claims.P1476[0].value : getLabel(value);
}
function parseKeywords(values) {

@@ -60,3 +50,2 @@ return values.map(({

}
function parseDateRange(dates) {

@@ -67,3 +56,2 @@ return {

}
function parseVersion(version) {

@@ -73,18 +61,13 @@ const output = {

};
if (version.qualifiers.P577) {
output.issued = parseDate(version.qualifiers.P577[0]);
}
if (version.qualifiers.P356) {
output.DOI = version.qualifiers.P356[0];
}
if (version.qualifiers.P6138) {
output.SWHID = version.qualifiers.P6138[0];
}
return output;
}
export const TYPE_PRIORITIES = {

@@ -141,3 +124,2 @@ 'review-book': 10,

return parseType(value);
case 'author':

@@ -165,13 +147,9 @@ case 'chair':

return parseNames(value);
case 'issued':
case 'original-date':
return parseDate(value);
case 'event-date':
return parseDateRange(value);
case 'keyword':
return parseKeywords(value);
case 'container-title':

@@ -184,3 +162,2 @@ case 'collection-title':

return getTitle(value);
case 'event-place':

@@ -191,13 +168,9 @@ case 'jurisdiction':

return getPlace(value);
case 'chapter-number':
case 'collection-number':
return parseInt(value[0]);
case 'number-of-volumes':
return value.length;
case 'versions':
return value.map(parseVersion);
default:

@@ -210,3 +183,2 @@ return value;

const mapped = unmapped.map(type => types[type.value]).filter(Boolean);
if (!mapped.length) {

@@ -216,3 +188,2 @@ logger.unmapped('[plugin-wikidata]', 'publication type', type);

}
mapped.sort((a, b) => TYPE_PRIORITIES[b] - TYPE_PRIORITIES[a]);

@@ -225,3 +196,2 @@ return mapped[0];

}
const lang = config.langs.find(lang => entity.labels[lang]);

@@ -228,0 +198,0 @@ return entity.labels[lang];

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
import { simplify } from 'wikidata-sdk';

@@ -65,3 +64,2 @@ import { parse as fetch, parseAsync as fetchAsync } from './api.js';

};
function collectAdditionalIds(entity, needed) {

@@ -71,3 +69,2 @@ if (!needed) {

}
entity._needed = Object.assign(entity._needed || {}, needed);

@@ -78,10 +75,7 @@ return Object.keys(entity.claims).filter(prop => prop in needed).flatMap(prop => entity.claims[prop].map(({

}
function completeResponse(entities, old) {
if (!old) {
const allIds = [];
for (const id in entities) {
const ids = collectAdditionalIds(entities[id], FETCH_ADDITIONAL);
for (const id of ids) {

@@ -93,15 +87,10 @@ if (!allIds.includes(id)) {

}
return allIds;
}
const ids = [];
for (const id of old) {
const entity = entities[id];
if (!entity._needed) {
continue;
}
for (const prop in entity.claims) {

@@ -113,3 +102,2 @@ if (prop in entity._needed) {

}
claim.value = entities[claim.value];

@@ -120,15 +108,10 @@ ids.push(...collectAdditionalIds(claim.value, entity._needed[prop]));

}
delete entity._needed;
}
return ids;
}
function simplifyEntities(entities) {
const simplified = simplify.entities(entities, SIMPLIFY_OPTS);
for (const id in entities) {
const claims = entities[id].claims;
if (claims.P348) {

@@ -141,6 +124,4 @@ simplified[id].claims['P348:all'] = simplify.propertyClaims(claims.P348, _objectSpread(_objectSpread({}, SIMPLIFY_OPTS), {}, {

}
return simplified;
}
function initLoopState(entities, cache) {

@@ -152,3 +133,2 @@ return {

}
function filterIdsAndGetUrls(needed, cache) {

@@ -158,3 +138,2 @@ const shouldFetch = needed.filter((id, i) => !(id in cache) && needed.indexOf(id) === i);

}
function addItemsToCache(response, cache) {

@@ -166,3 +145,2 @@ const {

}
function updateLoopState(state, cache) {

@@ -174,11 +152,8 @@ return {

}
function finalizeItems(entities, cache) {
return Object.keys(entities).map(id => cache[id]);
}
export function fillCache(entities) {
const cache = simplifyEntities(entities);
let state = initLoopState(entities, cache);
while (state.needed.length) {

@@ -189,3 +164,2 @@ const urls = filterIdsAndGetUrls(state.needed, cache);

}
return cache;

@@ -200,3 +174,2 @@ }

let state = initLoopState(entities, cache);
while (state.needed.length) {

@@ -207,3 +180,2 @@ const urls = filterIdsAndGetUrls(state.needed, cache);

}
return cache;

@@ -210,0 +182,0 @@ }

@@ -8,5 +8,3 @@ "use strict";

exports.parseAsync = parseAsync;
var _core = require("@citation-js/core");
const {

@@ -16,9 +14,7 @@ fetchFile,

} = _core.util;
function parse(urls) {
return [].concat(urls).map(fetchFile);
}
function parseAsync(urls) {
return Promise.all([].concat(urls).map(fetchFileAsync));
}

@@ -9,21 +9,11 @@ "use strict";

exports.parseEntity = parseEntity;
var _core = require("@citation-js/core");
var response = _interopRequireWildcard(require("./response.js"));
var _prop = require("./prop.js");
var _props = _interopRequireDefault(require("./props.json"));
var _customProps = _interopRequireDefault(require("./customProps.json"));
var _ignoredProps = _interopRequireDefault(require("./ignoredProps.json"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function resolve(parts, {

@@ -33,7 +23,5 @@ claims

const [prop, qualifier] = parts[0].split('#');
if (!claims[prop] || !claims[prop].length) {
return;
}
if (parts.length === 1) {

@@ -46,12 +34,8 @@ if (qualifier) {

}
return;
}
return claims[prop];
}
return resolve(parts.slice(1), claims[prop][0].value);
}
function resolveProp(prop_, entity, unknown) {

@@ -62,3 +46,2 @@ const parts = prop_.split('.');

}
function prepareValue(statement, entity, unknown) {

@@ -69,5 +52,3 @@ if (typeof statement !== 'object') {

}
const values = [].concat(...statement.props.map(prop => resolveProp(prop, entity, unknown)).filter(Boolean));
if (statement.values === 'all') {

@@ -79,3 +60,2 @@ return values[0] && values;

}
function parseEntity(entity) {

@@ -90,9 +70,6 @@ const data = {

const unknown = new Set(Object.keys(entity.claims));
for (const prop in _props.default) {
const input = prepareValue(_props.default[prop], entity, unknown);
if (input) {
const output = (0, _prop.parseProp)(prop, input, entity);
if (output) {

@@ -103,9 +80,6 @@ data[prop] = output;

}
for (const prop in _customProps.default) {
const input = prepareValue(_customProps.default[prop], entity, unknown);
if (input) {
const output = (0, _prop.parseProp)(prop, input, entity);
if (output) {

@@ -116,3 +90,2 @@ data.custom[prop] = output;

}
for (const prop of unknown) {

@@ -122,10 +95,7 @@ if (prop in _ignoredProps.default) {

}
_core.logger.unmapped('[plugin-wikidata]', 'property', prop);
}
if (!data.title) {
data.title = (0, _prop.getLabel)(entity);
}
if (data.type.slice(0, 6) === 'review') {

@@ -137,11 +107,8 @@ delete data.keyword;

}
if (data.recipient) {
data.type = 'personal_communication';
}
if (data['event-title']) {
data.type = 'paper-conference';
}
if (typeof data['part-number'] === 'number') {

@@ -152,14 +119,10 @@ delete data['part-title'];

}
if (data.type !== 'chapter' && data['chapter-number']) {
delete data['chapter-number'];
}
if (data['original-author'] && !data.author) {
data.author = data['original-author'];
}
return data;
}
async function parseEntitiesAsync({

@@ -170,3 +133,2 @@ entities

}
function parseEntities({

@@ -173,0 +135,0 @@ entities

@@ -7,9 +7,5 @@ "use strict";

exports.default = exports.parse = parseWikidata;
var _wikidataSdk = _interopRequireDefault(require("wikidata-sdk"));
var _config = _interopRequireDefault(require("./config.json"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function parseWikidata(data, langs) {

@@ -16,0 +12,0 @@ const list = [].concat(data);

@@ -7,23 +7,12 @@ "use strict";

exports.ref = exports.parsers = exports.formats = void 0;
var _core = require("@citation-js/core");
var id = _interopRequireWildcard(require("./id.js"));
var entity = _interopRequireWildcard(require("./entity.js"));
var prop = _interopRequireWildcard(require("./prop.js"));
var url = _interopRequireWildcard(require("./url.js"));
var api = _interopRequireWildcard(require("./api.js"));
var _config = _interopRequireDefault(require("./config.json"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
const ref = '@wikidata';

@@ -51,3 +40,2 @@ exports.ref = ref;

},
parseType: {

@@ -111,3 +99,2 @@ dataType: 'String',

},
parseType: {

@@ -127,3 +114,2 @@ dataType: 'Array',

exports.formats = formats;
_core.plugins.add(ref, {

@@ -130,0 +116,0 @@ input: formats,

@@ -10,19 +10,11 @@ "use strict";

exports.parseType = parseType;
var _core = require("@citation-js/core");
var _name = require("@citation-js/name");
var _date = require("@citation-js/date");
var _config = _interopRequireDefault(require("./config.json"));
var _types = _interopRequireDefault(require("./types.json"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function getStatedAs(qualifiers) {
return [].concat(...[qualifiers.P1932, qualifiers.P1810].filter(Boolean));
}
function parseName({

@@ -33,7 +25,5 @@ value,

let [name] = getStatedAs(qualifiers);
if (!name) {
name = typeof value === 'string' ? value : getLabel(value);
}
name = name ? (0, _name.parse)(name) : {

@@ -43,14 +33,10 @@ literal: name

const ordinal = qualifiers.P1545 ? parseInt(qualifiers.P1545[0]) : null;
if (ordinal !== null) {
name._ordinal = ordinal;
}
return name;
}
function parseNames(values) {
return values.map(parseName).sort((a, b) => a._ordinal - b._ordinal);
}
function getPlace(value) {

@@ -65,7 +51,5 @@ const country = value.claims.P17[0].value;

}
function getTitle(value) {
return value.claims.P1476 ? value.claims.P1476[0].value : getLabel(value);
}
function parseKeywords(values) {

@@ -76,3 +60,2 @@ return values.map(({

}
function parseDateRange(dates) {

@@ -83,3 +66,2 @@ return {

}
function parseVersion(version) {

@@ -89,18 +71,13 @@ const output = {

};
if (version.qualifiers.P577) {
output.issued = (0, _date.parse)(version.qualifiers.P577[0]);
}
if (version.qualifiers.P356) {
output.DOI = version.qualifiers.P356[0];
}
if (version.qualifiers.P6138) {
output.SWHID = version.qualifiers.P6138[0];
}
return output;
}
const TYPE_PRIORITIES = {

@@ -154,3 +131,2 @@ 'review-book': 10,

exports.TYPE_PRIORITIES = TYPE_PRIORITIES;
function parseProp(prop, value, entity) {

@@ -160,3 +136,2 @@ switch (prop) {

return parseType(value);
case 'author':

@@ -184,13 +159,9 @@ case 'chair':

return parseNames(value);
case 'issued':
case 'original-date':
return (0, _date.parse)(value);
case 'event-date':
return parseDateRange(value);
case 'keyword':
return parseKeywords(value);
case 'container-title':

@@ -203,3 +174,2 @@ case 'collection-title':

return getTitle(value);
case 'event-place':

@@ -210,13 +180,9 @@ case 'jurisdiction':

return getPlace(value);
case 'chapter-number':
case 'collection-number':
return parseInt(value[0]);
case 'number-of-volumes':
return value.length;
case 'versions':
return value.map(parseVersion);
default:

@@ -226,17 +192,12 @@ return value;

}
function parseType(type) {
const unmapped = Array.isArray(type) ? type : [type];
const mapped = unmapped.map(type => _types.default[type.value]).filter(Boolean);
if (!mapped.length) {
_core.logger.unmapped('[plugin-wikidata]', 'publication type', type);
return 'document';
}
mapped.sort((a, b) => TYPE_PRIORITIES[b] - TYPE_PRIORITIES[a]);
return mapped[0];
}
function getLabel(entity) {

@@ -246,6 +207,4 @@ if (!entity) {

}
const lang = _config.default.langs.find(lang => entity.labels[lang]);
return entity.labels[lang];
}

@@ -10,15 +10,10 @@ "use strict";

exports.parseAsync = parseAsync;
var _wikidataSdk = require("wikidata-sdk");
var _api = require("./api.js");
var _id = require("./id.js");
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
const SIMPLIFY_OPTS = {

@@ -79,3 +74,2 @@ keepQualifiers: true,

};
function collectAdditionalIds(entity, needed) {

@@ -85,3 +79,2 @@ if (!needed) {

}
entity._needed = Object.assign(entity._needed || {}, needed);

@@ -92,10 +85,7 @@ return Object.keys(entity.claims).filter(prop => prop in needed).flatMap(prop => entity.claims[prop].map(({

}
function completeResponse(entities, old) {
if (!old) {
const allIds = [];
for (const id in entities) {
const ids = collectAdditionalIds(entities[id], FETCH_ADDITIONAL);
for (const id of ids) {

@@ -107,15 +97,10 @@ if (!allIds.includes(id)) {

}
return allIds;
}
const ids = [];
for (const id of old) {
const entity = entities[id];
if (!entity._needed) {
continue;
}
for (const prop in entity.claims) {

@@ -127,3 +112,2 @@ if (prop in entity._needed) {

}
claim.value = entities[claim.value];

@@ -134,15 +118,10 @@ ids.push(...collectAdditionalIds(claim.value, entity._needed[prop]));

}
delete entity._needed;
}
return ids;
}
function simplifyEntities(entities) {
const simplified = _wikidataSdk.simplify.entities(entities, SIMPLIFY_OPTS);
for (const id in entities) {
const claims = entities[id].claims;
if (claims.P348) {

@@ -155,6 +134,4 @@ simplified[id].claims['P348:all'] = _wikidataSdk.simplify.propertyClaims(claims.P348, _objectSpread(_objectSpread({}, SIMPLIFY_OPTS), {}, {

}
return simplified;
}
function initLoopState(entities, cache) {

@@ -166,3 +143,2 @@ return {

}
function filterIdsAndGetUrls(needed, cache) {

@@ -172,3 +148,2 @@ const shouldFetch = needed.filter((id, i) => !(id in cache) && needed.indexOf(id) === i);

}
function addItemsToCache(response, cache) {

@@ -180,3 +155,2 @@ const {

}
function updateLoopState(state, cache) {

@@ -188,11 +162,8 @@ return {

}
function finalizeItems(entities, cache) {
return Object.keys(entities).map(id => cache[id]);
}
function fillCache(entities) {
const cache = simplifyEntities(entities);
let state = initLoopState(entities, cache);
while (state.needed.length) {

@@ -203,6 +174,4 @@ const urls = filterIdsAndGetUrls(state.needed, cache);

}
return cache;
}
function parse(entities) {

@@ -212,7 +181,5 @@ const cache = fillCache(entities);

}
async function fillCacheAsync(entities) {
const cache = simplifyEntities(entities);
let state = initLoopState(entities, cache);
while (state.needed.length) {

@@ -223,6 +190,4 @@ const urls = filterIdsAndGetUrls(state.needed, cache);

}
return cache;
}
async function parseAsync(entities) {

@@ -229,0 +194,0 @@ const cache = await fillCacheAsync(entities);

@@ -7,5 +7,4 @@ "use strict";

exports.parse = parse;
function parse(input) {
return input.match(/\/(Q\d+)(?:[#?/]|\s*$)/)[1];
}

6

package.json
{
"name": "@citation-js/plugin-wikidata",
"version": "0.6.4",
"version": "0.6.5",
"description": "Plugin for Wikidata for Citation.js",

@@ -39,3 +39,3 @@ "keywords": [

"devDependencies": {
"@citation-js/core": "^0.6.1"
"@citation-js/core": "^0.6.5"
},

@@ -45,3 +45,3 @@ "peerDependencies": {

},
"gitHead": "cb7d479ef897d093606288bd31467b04779c550e"
"gitHead": "f68c6f690e573e3373fe0d9b91ca6ade0026555b"
}
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