Skip to content

Commit

Permalink
refactor: use Array.prototype.at (#3208)
Browse files Browse the repository at this point in the history
  • Loading branch information
char0n authored Oct 2, 2023
1 parent 64bc1d5 commit 376530f
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
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[ancestors.length - 1]; // @ts-ignore
const ancestor = ancestors.at(-1);
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[ancestors.length - 1];
const ancestor = ancestors.at(-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 @@ -192,7 +192,7 @@ const plugin = () => () => {
if (!isEmptyElement(element.value)) return undefined;

const [, , , ancestors] = rest;
const ancestor = ancestors[ancestors.length - 1]; // @ts-ignore
const ancestor = ancestors.at(-1);
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[ancestors.length - 1];
const ancestor = ancestors.at(-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 @@ -206,7 +206,7 @@ const plugin = () => () => {
if (!isEmptyElement(element.value)) return undefined;

const [, , , ancestors] = rest;
const ancestor = ancestors[ancestors.length - 1]; // @ts-ignore
const ancestor = ancestors.at(-1);
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[ancestors.length - 1];
const ancestor = ancestors.at(-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[ancestors.length - 1]; // @ts-ignore
const ancestor = ancestors.at(-1);
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[ancestors.length - 1];
const ancestor = ancestors.at(-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 @@ -618,7 +618,7 @@ const plugin = () => () => {
if (!isEmptyElement(element.value)) return undefined;

const [, , , ancestors] = rest;
const ancestor = ancestors[ancestors.length - 1]; // @ts-ignore
const ancestor = ancestors.at(-1);
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[ancestors.length - 1];
const ancestor = ancestors.at(-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 @@ -687,7 +687,7 @@ const plugin =
if (!isEmptyElement(element.value)) return undefined;

const [, , , ancestors] = rest;
const ancestor = ancestors[ancestors.length - 1]; // @ts-ignore
const ancestor = ancestors.at(-1);
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[ancestors.length - 1];
const ancestor = ancestors.at(-1);

// we're only interested in empty elements in ArrayElements
if (!predicates.isArrayElement(ancestor)) return undefined;
Expand Down

0 comments on commit 376530f

Please sign in to comment.