wiki-entity 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +1 -21
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -29,30 +29,10 @@ var simplify_entity_1 = require("./wikidata/simplify_entity");
|
|
|
29
29
|
Object.defineProperty(exports, "simplifyEntity", { enumerable: true, get: function () { return simplify_entity_1.simplifyEntity; } });
|
|
30
30
|
__exportStar(require("./simpleEntity"), exports);
|
|
31
31
|
__exportStar(require("./types"), exports);
|
|
32
|
-
const getAllEntities = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
-
const entities = yield (0, wikidata_1.getEntities)(params);
|
|
34
|
-
const titles = params.titles || [];
|
|
35
|
-
if (params.redirect === "no" || !titles.length || params.ids)
|
|
36
|
-
return entities;
|
|
37
|
-
const lang = params.language || "en";
|
|
38
|
-
const notFoundTitle = titles.find((title) => !Object.entries(entities).find(([, entity]) => {
|
|
39
|
-
return (!entity.sitelinks ||
|
|
40
|
-
!entity.sitelinks[lang] ||
|
|
41
|
-
entity.sitelinks[lang] !== title);
|
|
42
|
-
}));
|
|
43
|
-
if (notFoundTitle.length === 0)
|
|
44
|
-
return entities;
|
|
45
|
-
const redirects = yield mapRedirects(titles, lang);
|
|
46
|
-
const redirectTitles = [...new Set(Object.values(redirects))];
|
|
47
|
-
if (redirectTitles.length === 0)
|
|
48
|
-
return entities;
|
|
49
|
-
const redirectEntities = yield (0, wikidata_1.getEntities)(Object.assign(Object.assign({}, params), { ids: undefined, titles: redirectTitles }));
|
|
50
|
-
return Object.assign(Object.assign({}, entities), redirectEntities);
|
|
51
|
-
});
|
|
52
32
|
function getEntities(params) {
|
|
53
33
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
34
|
const lang = params.language || "en";
|
|
55
|
-
const entities = yield
|
|
35
|
+
const entities = yield (0, wikidata_1.getEntities)(params);
|
|
56
36
|
const ids = Object.keys(entities).filter((id) => (0, utils_1.isValidWikiId)(id));
|
|
57
37
|
if (ids.length === 0)
|
|
58
38
|
return [];
|