Commit 554496fc authored by Diegodlh's avatar Diegodlh
Browse files

support node 12 and newer

parent 85356ad7
engine-strict=true
......@@ -19,6 +19,7 @@
"@types/jest": "^27.4.0",
"@types/jsdom": "^16.2.14",
"@types/minimatch": "^3.0.5",
"@types/node": "^12.20.46",
"@types/node-fetch": "^2.5.12",
"@typescript-eslint/eslint-plugin": "^5.9.0",
"@typescript-eslint/parser": "^5.9.0",
......@@ -30,6 +31,9 @@
"prettier": "^2.5.1",
"ts-jest": "^27.1.2",
"typescript": "^4.5.4"
},
"engines": {
"node": "> 12"
}
},
"node_modules/@babel/code-frame": {
......@@ -1135,9 +1139,9 @@
"dev": true
},
"node_modules/@types/node": {
"version": "17.0.8",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.8.tgz",
"integrity": "sha512-YofkM6fGv4gDJq78g4j0mMuGMkZVxZDgtU0JRdx6FgiJDG+0fY0GKVolOV8WqVmEhLCXkQRjwDdKyPxJp/uucg==",
"version": "12.20.46",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.46.tgz",
"integrity": "sha512-cPjLXj8d6anFPzFvOPxS3fvly3Shm5nTfl6g8X5smexixbuGUf7hfr21J5tX9JW+UPStp/5P5R8qrKL5IyVJ+A==",
"dev": true
},
"node_modules/@types/node-fetch": {
......@@ -6805,9 +6809,9 @@
"dev": true
},
"@types/node": {
"version": "17.0.8",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.8.tgz",
"integrity": "sha512-YofkM6fGv4gDJq78g4j0mMuGMkZVxZDgtU0JRdx6FgiJDG+0fY0GKVolOV8WqVmEhLCXkQRjwDdKyPxJp/uucg==",
"version": "12.20.46",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.46.tgz",
"integrity": "sha512-cPjLXj8d6anFPzFvOPxS3fvly3Shm5nTfl6g8X5smexixbuGUf7hfr21J5tX9JW+UPStp/5P5R8qrKL5IyVJ+A==",
"dev": true
},
"@types/node-fetch": {
......
......@@ -27,7 +27,7 @@ export class TranslationProcedure {
const selectionOutput = Array.prototype.concat(...selections);
const transformations = await this.transform(selectionOutput);
const transformationOutput = transformations.at(-1) ?? [];
const transformationOutput = transformations.slice(-1).pop() ?? [];
const procedureOutput = transformations.length
? transformationOutput
......
......@@ -62,7 +62,7 @@ export abstract class BaseTranslationTemplate {
if (field.name === name) indices.push(index);
return indices;
}, []);
const index = indices.at(order ?? -1);
const index = indices[order === undefined ? indices.length - 1 : order];
if (index !== undefined) this._fields.splice(index, 1);
}
......
......@@ -135,7 +135,7 @@ export function outputToCitation(
authorLast &&
authorLast.reduce((author: MediaWikiCreator[], lastName, index) => {
// replace missing first names with ""
const firstName = authorFirst?.at(index) ?? "";
const firstName = authorFirst?.[index] ?? "";
author.push([firstName, lastName]);
return author;
}, []);
......@@ -146,21 +146,21 @@ export function outputToCitation(
// consider fixing by having separate field subclasses,
// each with a specific output type: string | string[] | ItemType | etc
const itemType = fields.get("itemType")?.at(0);
const itemType = fields.get("itemType")?.[0];
if (itemType !== undefined && !isItemType(itemType)) {
throw new Error(`${itemType} is not a valid value for field "itemType"`);
}
return {
itemType,
author,
title: fields.get("title")?.at(0),
date: fields.get("date")?.at(0),
language: fields.get("language")?.at(0),
title: fields.get("title")?.[0],
date: fields.get("date")?.[0],
language: fields.get("language")?.[0],
// CSL container-title fields
publicationTitle: fields.get("publishedIn")?.at(0),
code: fields.get("publishedIn")?.at(0),
reporter: fields.get("publishedIn")?.at(0),
publicationTitle: fields.get("publishedIn")?.[0],
code: fields.get("publishedIn")?.[0],
reporter: fields.get("publishedIn")?.[0],
// CSL publisher field
publisher: fields.get("publishedBy")?.at(0),
publisher: fields.get("publishedBy")?.[0],
};
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment