Skip to content

Commit

Permalink
fix: return support for Node.js >=12.20.0 (#3356)
Browse files Browse the repository at this point in the history
  • Loading branch information
char0n committed Nov 3, 2023
1 parent 94999a0 commit 75528ec
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 20 deletions.
4 changes: 2 additions & 2 deletions packages/apidom-ast/src/traversal/visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ export const visit = (
} while (stack !== undefined);

if (edits.length !== 0) {
return edits.at(-1)[1];
return edits[edits.length - 1][1]; // @TODO(vladimir.gorej@gmail.com): can be replaced by Array.prototype.at in future
}

return root;
Expand Down Expand Up @@ -501,7 +501,7 @@ visit[Symbol.for('nodejs.util.promisify.custom')] = async (
} while (stack !== undefined);

if (edits.length !== 0) {
return edits.at(-1)[1];
return edits[edits.length - 1][1]; // @TODO(vladimir.gorej@gmail.com): can be replaced by Array.prototype.at in future
}

return root;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ const plugin = () => () => {
if (!isEmptyElement(element.value)) return undefined;

const [, , , ancestors] = rest;
const ancestor = ancestors.at(-1);
const ancestor = ancestors[ancestors.length - 1]; // @TODO(vladimir.gorej@gmail.com): can be replaced by Array.prototype.at in future
const elementFactory = findElementFactory(ancestor, toValue(element.key));

// no element factory found
Expand All @@ -1069,7 +1069,7 @@ const plugin = () => () => {
if (!isEmptyElement(element)) return undefined;

const [, , , ancestors] = rest;
const ancestor = ancestors.at(-1);
const ancestor = ancestors[ancestors.length - 1]; // @TODO(vladimir.gorej@gmail.com): can be replaced by Array.prototype.at in future

// we're only interested in empty elements in ArrayElements
if (!isArrayElement(ancestor)) return undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ const plugin = () => () => {
if (!isEmptyElement(element.value)) return undefined;

const [, , , ancestors] = rest;
const ancestor = ancestors.at(-1);
const ancestor = ancestors[ancestors.length - 1]; // @TODO(vladimir.gorej@gmail.com): can be replaced by Array.prototype.at in future
const elementFactory = findElementFactory(ancestor, toValue(element.key));

// no element factory found
Expand All @@ -217,7 +217,7 @@ const plugin = () => () => {
if (!isEmptyElement(element)) return undefined;

const [, , , ancestors] = rest;
const ancestor = ancestors.at(-1);
const ancestor = ancestors[ancestors.length - 1]; // @TODO(vladimir.gorej@gmail.com): can be replaced by Array.prototype.at in future

// we're only interested in empty elements in ArrayElements
if (!isArrayElement(ancestor)) return undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ const plugin = () => () => {
if (!isEmptyElement(element.value)) return undefined;

const [, , , ancestors] = rest;
const ancestor = ancestors.at(-1);
const ancestor = ancestors[ancestors.length - 1]; // @TODO(vladimir.gorej@gmail.com): can be replaced by Array.prototype.at in future
const elementFactory = findElementFactory(ancestor, toValue(element.key));

// no element factory found
Expand All @@ -231,7 +231,7 @@ const plugin = () => () => {
if (!isEmptyElement(element)) return undefined;

const [, , , ancestors] = rest;
const ancestor = ancestors.at(-1);
const ancestor = ancestors[ancestors.length - 1];

// we're only interested in empty elements in ArrayElements
if (!isArrayElement(ancestor)) return undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ const plugin = () => () => {
if (!isEmptyElement(element.value)) return undefined;

const [, , , ancestors] = rest;
const ancestor = ancestors.at(-1);
const ancestor = ancestors[ancestors.length - 1]; // @TODO(vladimir.gorej@gmail.com): can be replaced by Array.prototype.at in future
const elementFactory = findElementFactory(ancestor, toValue(element.key));

// no element factory found
Expand All @@ -245,7 +245,7 @@ const plugin = () => () => {
if (!isEmptyElement(element)) return undefined;

const [, , , ancestors] = rest;
const ancestor = ancestors.at(-1);
const ancestor = ancestors[ancestors.length - 1]; // @TODO(vladimir.gorej@gmail.com): can be replaced by Array.prototype.at in future

// we're only interested in empty elements in ArrayElements
if (!isArrayElement(ancestor)) return undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ const plugin = () => () => {
if (!isEmptyElement(element.value)) return undefined;

const [, , , ancestors] = rest;
const ancestor = ancestors.at(-1);
const ancestor = ancestors[ancestors.length - 1]; // @TODO(vladimir.gorej@gmail.com): can be replaced by Array.prototype.at in future
const elementFactory = findElementFactory(ancestor, toValue(element.key));

// no element factory found
Expand All @@ -374,7 +374,7 @@ const plugin = () => () => {
if (!isEmptyElement(element)) return undefined;

const [, , , ancestors] = rest;
const ancestor = ancestors.at(-1);
const ancestor = ancestors[ancestors.length - 1]; // @TODO(vladimir.gorej@gmail.com): can be replaced by Array.prototype.at in future

// we're only interested in empty elements in ArrayElements
if (!isArrayElement(ancestor)) return undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ const plugin = () => () => {
if (!isEmptyElement(element.value)) return undefined;

const [, , , ancestors] = rest;
const ancestor = ancestors.at(-1);
const ancestor = ancestors[ancestors.length - 1]; // @TODO(vladimir.gorej@gmail.com): can be replaced by Array.prototype.at in future
const elementFactory = findElementFactory(ancestor, toValue(element.key));

// no element factory found
Expand All @@ -643,7 +643,7 @@ const plugin = () => () => {
if (!isEmptyElement(element)) return undefined;

const [, , , ancestors] = rest;
const ancestor = ancestors.at(-1);
const ancestor = ancestors[ancestors.length - 1]; // @TODO(vladimir.gorej@gmail.com): can be replaced by Array.prototype.at in future

// we're only interested in empty elements in ArrayElements
if (!isArrayElement(ancestor)) return undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ const plugin =
if (ancestors.some(predicates.isComponentsElement)) return;
if (!ancestors.some(predicates.isOpenApi3_1Element)) return;

const parentPathItemElement = ancestors.findLast(predicates.isPathItemElement);
// @TODO(vladimir.gorej@gmail.com): can be replaced by Array.prototype.findLast in future
const parentPathItemElement = [...ancestors].reverse().find(predicates.isPathItemElement);
const isServersUndefined = typeof operationElement.servers === 'undefined';
const isServersArrayElement = predicates.isArrayElement(operationElement.servers);
const isServersEmpty = isServersArrayElement && operationElement.servers!.length === 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ const plugin =
if (!isEmptyElement(element.value)) return undefined;

const [, , , ancestors] = rest;
const ancestor = ancestors.at(-1);
const ancestor = ancestors[ancestors.length - 1]; // @TODO(vladimir.gorej@gmail.com): can be replaced by Array.prototype.at in future
const elementFactory = findElementFactory(ancestor, toValue(element.key));

// no element factory found
Expand All @@ -712,7 +712,7 @@ const plugin =
if (!isEmptyElement(element)) return undefined;

const [, , , ancestors] = rest;
const ancestor = ancestors.at(-1);
const ancestor = ancestors[ancestors.length - 1]; // @TODO(vladimir.gorej@gmail.com): can be replaced by Array.prototype.at in future

// we're only interested in empty elements in ArrayElements
if (!predicates.isArrayElement(ancestor)) return undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const analyze = (cst: NodeTree | WebTree, { sourceMap = false } = {}): ParseResu
const visitor = CstVisitor();
const cursor = cst.walk();
const iterator = new TreeCursorIterator(cursor);
const rootNode = [...iterator].at(0) as TreeCursorSyntaxNode;
const rootNode = [...iterator][0] as TreeCursorSyntaxNode;

return visit(rootNode, visitor, {
// @ts-ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type Tree = WebTree | NodeTree;
const analyze = (cst: Tree, { sourceMap = false } = {}): ParseResultElement => {
const cursor = cst.walk();
const iterator = new TreeCursorIterator(cursor);
const rootNode = [...iterator].at(0) as TreeCursorSyntaxNode;
const rootNode = [...iterator][0] as TreeCursorSyntaxNode;
const cstVisitor = CstVisitor();
const astVisitor = JsonAstVisitor();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Tree = WebTree | NodeTree;
const analyze = (cst: Tree, { sourceMap = false } = {}): ParseResultElement => {
const cursor = cst.walk();
const iterator = new TreeCursorIterator(cursor);
const rootNode = [...iterator].at(0) as TreeCursorSyntaxNode;
const rootNode = [...iterator][0] as TreeCursorSyntaxNode;
const cstVisitor = CstVisitor();
const astVisitor = YamlAstVisitor();
const schema = JsonSchema();
Expand Down

0 comments on commit 75528ec

Please sign in to comment.