aboutsummaryrefslogtreecommitdiffstats
path: root/node_modules/yallist
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/yallist')
-rw-r--r--node_modules/yallist/LICENSE.md63
-rw-r--r--node_modules/yallist/README.md205
-rw-r--r--node_modules/yallist/dist/commonjs/index.d.ts39
-rw-r--r--node_modules/yallist/dist/commonjs/index.js384
-rw-r--r--node_modules/yallist/dist/commonjs/package.json3
-rw-r--r--node_modules/yallist/dist/esm/index.d.ts39
-rw-r--r--node_modules/yallist/dist/esm/index.js379
-rw-r--r--node_modules/yallist/dist/esm/package.json3
-rw-r--r--node_modules/yallist/package.json68
9 files changed, 1183 insertions, 0 deletions
diff --git a/node_modules/yallist/LICENSE.md b/node_modules/yallist/LICENSE.md
new file mode 100644
index 0000000..881248b
--- /dev/null
+++ b/node_modules/yallist/LICENSE.md
@@ -0,0 +1,63 @@
+All packages under `src/` are licensed according to the terms in
+their respective `LICENSE` or `LICENSE.md` files.
+
+The remainder of this project is licensed under the Blue Oak
+Model License, as follows:
+
+-----
+
+# Blue Oak Model License
+
+Version 1.0.0
+
+## Purpose
+
+This license gives everyone as much permission to work with
+this software as possible, while protecting contributors
+from liability.
+
+## Acceptance
+
+In order to receive this license, you must agree to its
+rules. The rules of this license are both obligations
+under that agreement and conditions to your license.
+You must not do anything with this software that triggers
+a rule that you cannot or will not follow.
+
+## Copyright
+
+Each contributor licenses you to do everything with this
+software that would otherwise infringe that contributor's
+copyright in it.
+
+## Notices
+
+You must ensure that everyone who gets a copy of
+any part of this software from you, with or without
+changes, also gets the text of this license or a link to
+<https://blueoakcouncil.org/license/1.0.0>.
+
+## Excuse
+
+If anyone notifies you in writing that you have not
+complied with [Notices](#notices), you can keep your
+license by taking all practical steps to comply within 30
+days after the notice. If you do not do so, your license
+ends immediately.
+
+## Patent
+
+Each contributor licenses you to do everything with this
+software that would otherwise infringe any patent claims
+they can license or become able to license.
+
+## Reliability
+
+No contributor can revoke this license.
+
+## No Liability
+
+***As far as the law allows, this software comes as is,
+without any warranty or condition, and no contributor
+will be liable to anyone for any damages related to this
+software or this license, under any kind of legal claim.***
diff --git a/node_modules/yallist/README.md b/node_modules/yallist/README.md
new file mode 100644
index 0000000..68f6162
--- /dev/null
+++ b/node_modules/yallist/README.md
@@ -0,0 +1,205 @@
+# yallist
+
+Yet Another Linked List
+
+There are many doubly-linked list implementations like it, but this
+one is mine.
+
+For when an array would be too big, and a Map can't be iterated in
+reverse order.
+
+## basic usage
+
+```js
+import { Yallist } from 'yallist'
+var myList = new Yallist([1, 2, 3])
+myList.push('foo')
+myList.unshift('bar')
+// of course pop() and shift() are there, too
+console.log(myList.toArray()) // ['bar', 1, 2, 3, 'foo']
+myList.forEach(function (k) {
+ // walk the list head to tail
+})
+myList.forEachReverse(function (k, index, list) {
+ // walk the list tail to head
+})
+var myDoubledList = myList.map(function (k) {
+ return k + k
+})
+// now myDoubledList contains ['barbar', 2, 4, 6, 'foofoo']
+// mapReverse is also a thing
+var myDoubledListReverse = myList.mapReverse(function (k) {
+ return k + k
+}) // ['foofoo', 6, 4, 2, 'barbar']
+
+var reduced = myList.reduce(function (set, entry) {
+ set += entry
+ return set
+}, 'start')
+console.log(reduced) // 'startfoo123bar'
+```
+
+## api
+
+The whole API is considered "public".
+
+Functions with the same name as an Array method work more or less the
+same way.
+
+There's reverse versions of most things because that's the point.
+
+### Yallist
+
+Default export, the class that holds and manages a list.
+
+Call it with either a forEach-able (like an array) or a set of
+arguments, to initialize the list.
+
+The Array-ish methods all act like you'd expect. No magic length,
+though, so if you change that it won't automatically prune or add
+empty spots.
+
+### Yallist.create(..)
+
+Alias for Yallist function. Some people like factories.
+
+#### yallist.head
+
+The first node in the list
+
+#### yallist.tail
+
+The last node in the list
+
+#### yallist.length
+
+The number of nodes in the list. (Change this at your peril. It is
+not magic like Array length.)
+
+#### yallist.toArray()
+
+Convert the list to an array.
+
+#### yallist.forEach(fn, [thisp])
+
+Call a function on each item in the list.
+
+#### yallist.forEachReverse(fn, [thisp])
+
+Call a function on each item in the list, in reverse order.
+
+#### yallist.get(n)
+
+Get the data at position `n` in the list. If you use this a lot,
+probably better off just using an Array.
+
+#### yallist.getReverse(n)
+
+Get the data at position `n`, counting from the tail.
+
+#### yallist.map(fn, thisp)
+
+Create a new Yallist with the result of calling the function on each
+item.
+
+#### yallist.mapReverse(fn, thisp)
+
+Same as `map`, but in reverse.
+
+#### yallist.pop()
+
+Get the data from the list tail, and remove the tail from the list.
+
+#### yallist.push(item, ...)
+
+Insert one or more items to the tail of the list.
+
+#### yallist.reduce(fn, initialValue)
+
+Like Array.reduce.
+
+#### yallist.reduceReverse
+
+Like Array.reduce, but in reverse.
+
+#### yallist.reverse
+
+Reverse the list in place.
+
+#### yallist.shift()
+
+Get the data from the list head, and remove the head from the list.
+
+#### yallist.slice([from], [to])
+
+Just like Array.slice, but returns a new Yallist.
+
+#### yallist.sliceReverse([from], [to])
+
+Just like yallist.slice, but the result is returned in reverse.
+
+#### yallist.splice(start, deleteCount, ...)
+
+Like Array.splice.
+
+#### yallist.toArray()
+
+Create an array representation of the list.
+
+#### yallist.toArrayReverse()
+
+Create a reversed array representation of the list.
+
+#### yallist.unshift(item, ...)
+
+Insert one or more items to the head of the list.
+
+#### yallist.unshiftNode(node)
+
+Move a Node object to the front of the list. (That is, pull it out of
+wherever it lives, and make it the new head.)
+
+If the node belongs to a different list, then that list will remove it
+first.
+
+#### yallist.pushNode(node)
+
+Move a Node object to the end of the list. (That is, pull it out of
+wherever it lives, and make it the new tail.)
+
+If the node belongs to a list already, then that list will remove it
+first.
+
+#### yallist.removeNode(node)
+
+Remove a node from the list, preserving referential integrity of head
+and tail and other nodes.
+
+Will throw an error if you try to have a list remove a node that
+doesn't belong to it.
+
+### Yallist.Node
+
+The class that holds the data and is actually the list.
+
+Call with `const n = new Node(value, previousNode, nextNode)`
+
+Note that if you do direct operations on Nodes themselves, it's very
+easy to get into weird states where the list is broken. Be careful :)
+
+#### node.next
+
+The next node in the list.
+
+#### node.prev
+
+The previous node in the list.
+
+#### node.value
+
+The data the node contains.
+
+#### node.list
+
+The list to which this node belongs. (Null if it does not belong to
+any list.)
diff --git a/node_modules/yallist/dist/commonjs/index.d.ts b/node_modules/yallist/dist/commonjs/index.d.ts
new file mode 100644
index 0000000..044a1d7
--- /dev/null
+++ b/node_modules/yallist/dist/commonjs/index.d.ts
@@ -0,0 +1,39 @@
+export declare class Yallist<T = unknown> {
+ tail?: Node<T>;
+ head?: Node<T>;
+ length: number;
+ static create<T = unknown>(list?: Iterable<T>): Yallist<T>;
+ constructor(list?: Iterable<T>);
+ [Symbol.iterator](): Generator<T, void, unknown>;
+ removeNode(node: Node<T>): Node<T> | undefined;
+ unshiftNode(node: Node<T>): void;
+ pushNode(node: Node<T>): void;
+ push(...args: T[]): number;
+ unshift(...args: T[]): number;
+ pop(): T | undefined;
+ shift(): T | undefined;
+ forEach(fn: (value: T, i: number, list: Yallist<T>) => any, thisp?: any): void;
+ forEachReverse(fn: (value: T, i: number, list: Yallist<T>) => any, thisp?: any): void;
+ get(n: number): T | undefined;
+ getReverse(n: number): T | undefined;
+ map<R = any>(fn: (value: T, list: Yallist<T>) => R, thisp?: any): Yallist<R>;
+ mapReverse<R = any>(fn: (value: T, list: Yallist<T>) => R, thisp?: any): Yallist<R>;
+ reduce(fn: (left: T, right: T, i: number) => T): T;
+ reduce<R = any>(fn: (acc: R, next: T, i: number) => R, initial: R): R;
+ reduceReverse(fn: (left: T, right: T, i: number) => T): T;
+ reduceReverse<R = any>(fn: (acc: R, next: T, i: number) => R, initial: R): R;
+ toArray(): any[];
+ toArrayReverse(): any[];
+ slice(from?: number, to?: number): Yallist<unknown>;
+ sliceReverse(from?: number, to?: number): Yallist<unknown>;
+ splice(start: number, deleteCount?: number, ...nodes: T[]): T[];
+ reverse(): this;
+}
+export declare class Node<T = unknown> {
+ list?: Yallist<T>;
+ next?: Node<T>;
+ prev?: Node<T>;
+ value: T;
+ constructor(value: T, prev?: Node<T> | undefined, next?: Node<T> | undefined, list?: Yallist<T> | undefined);
+}
+//# sourceMappingURL=index.d.ts.map \ No newline at end of file
diff --git a/node_modules/yallist/dist/commonjs/index.js b/node_modules/yallist/dist/commonjs/index.js
new file mode 100644
index 0000000..c1e1e47
--- /dev/null
+++ b/node_modules/yallist/dist/commonjs/index.js
@@ -0,0 +1,384 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.Node = exports.Yallist = void 0;
+class Yallist {
+ tail;
+ head;
+ length = 0;
+ static create(list = []) {
+ return new Yallist(list);
+ }
+ constructor(list = []) {
+ for (const item of list) {
+ this.push(item);
+ }
+ }
+ *[Symbol.iterator]() {
+ for (let walker = this.head; walker; walker = walker.next) {
+ yield walker.value;
+ }
+ }
+ removeNode(node) {
+ if (node.list !== this) {
+ throw new Error('removing node which does not belong to this list');
+ }
+ const next = node.next;
+ const prev = node.prev;
+ if (next) {
+ next.prev = prev;
+ }
+ if (prev) {
+ prev.next = next;
+ }
+ if (node === this.head) {
+ this.head = next;
+ }
+ if (node === this.tail) {
+ this.tail = prev;
+ }
+ this.length--;
+ node.next = undefined;
+ node.prev = undefined;
+ node.list = undefined;
+ return next;
+ }
+ unshiftNode(node) {
+ if (node === this.head) {
+ return;
+ }
+ if (node.list) {
+ node.list.removeNode(node);
+ }
+ const head = this.head;
+ node.list = this;
+ node.next = head;
+ if (head) {
+ head.prev = node;
+ }
+ this.head = node;
+ if (!this.tail) {
+ this.tail = node;
+ }
+ this.length++;
+ }
+ pushNode(node) {
+ if (node === this.tail) {
+ return;
+ }
+ if (node.list) {
+ node.list.removeNode(node);
+ }
+ const tail = this.tail;
+ node.list = this;
+ node.prev = tail;
+ if (tail) {
+ tail.next = node;
+ }
+ this.tail = node;
+ if (!this.head) {
+ this.head = node;
+ }
+ this.length++;
+ }
+ push(...args) {
+ for (let i = 0, l = args.length; i < l; i++) {
+ push(this, args[i]);
+ }
+ return this.length;
+ }
+ unshift(...args) {
+ for (var i = 0, l = args.length; i < l; i++) {
+ unshift(this, args[i]);
+ }
+ return this.length;
+ }
+ pop() {
+ if (!this.tail) {
+ return undefined;
+ }
+ const res = this.tail.value;
+ const t = this.tail;
+ this.tail = this.tail.prev;
+ if (this.tail) {
+ this.tail.next = undefined;
+ }
+ else {
+ this.head = undefined;
+ }
+ t.list = undefined;
+ this.length--;
+ return res;
+ }
+ shift() {
+ if (!this.head) {
+ return undefined;
+ }
+ const res = this.head.value;
+ const h = this.head;
+ this.head = this.head.next;
+ if (this.head) {
+ this.head.prev = undefined;
+ }
+ else {
+ this.tail = undefined;
+ }
+ h.list = undefined;
+ this.length--;
+ return res;
+ }
+ forEach(fn, thisp) {
+ thisp = thisp || this;
+ for (let walker = this.head, i = 0; !!walker; i++) {
+ fn.call(thisp, walker.value, i, this);
+ walker = walker.next;
+ }
+ }
+ forEachReverse(fn, thisp) {
+ thisp = thisp || this;
+ for (let walker = this.tail, i = this.length - 1; !!walker; i--) {
+ fn.call(thisp, walker.value, i, this);
+ walker = walker.prev;
+ }
+ }
+ get(n) {
+ let i = 0;
+ let walker = this.head;
+ for (; !!walker && i < n; i++) {
+ walker = walker.next;
+ }
+ if (i === n && !!walker) {
+ return walker.value;
+ }
+ }
+ getReverse(n) {
+ let i = 0;
+ let walker = this.tail;
+ for (; !!walker && i < n; i++) {
+ // abort out of the list early if we hit a cycle
+ walker = walker.prev;
+ }
+ if (i === n && !!walker) {
+ return walker.value;
+ }
+ }
+ map(fn, thisp) {
+ thisp = thisp || this;
+ const res = new Yallist();
+ for (let walker = this.head; !!walker;) {
+ res.push(fn.call(thisp, walker.value, this));
+ walker = walker.next;
+ }
+ return res;
+ }
+ mapReverse(fn, thisp) {
+ thisp = thisp || this;
+ var res = new Yallist();
+ for (let walker = this.tail; !!walker;) {
+ res.push(fn.call(thisp, walker.value, this));
+ walker = walker.prev;
+ }
+ return res;
+ }
+ reduce(fn, initial) {
+ let acc;
+ let walker = this.head;
+ if (arguments.length > 1) {
+ acc = initial;
+ }
+ else if (this.head) {
+ walker = this.head.next;
+ acc = this.head.value;
+ }
+ else {
+ throw new TypeError('Reduce of empty list with no initial value');
+ }
+ for (var i = 0; !!walker; i++) {
+ acc = fn(acc, walker.value, i);
+ walker = walker.next;
+ }
+ return acc;
+ }
+ reduceReverse(fn, initial) {
+ let acc;
+ let walker = this.tail;
+ if (arguments.length > 1) {
+ acc = initial;
+ }
+ else if (this.tail) {
+ walker = this.tail.prev;
+ acc = this.tail.value;
+ }
+ else {
+ throw new TypeError('Reduce of empty list with no initial value');
+ }
+ for (let i = this.length - 1; !!walker; i--) {
+ acc = fn(acc, walker.value, i);
+ walker = walker.prev;
+ }
+ return acc;
+ }
+ toArray() {
+ const arr = new Array(this.length);
+ for (let i = 0, walker = this.head; !!walker; i++) {
+ arr[i] = walker.value;
+ walker = walker.next;
+ }
+ return arr;
+ }
+ toArrayReverse() {
+ const arr = new Array(this.length);
+ for (let i = 0, walker = this.tail; !!walker; i++) {
+ arr[i] = walker.value;
+ walker = walker.prev;
+ }
+ return arr;
+ }
+ slice(from = 0, to = this.length) {
+ if (to < 0) {
+ to += this.length;
+ }
+ if (from < 0) {
+ from += this.length;
+ }
+ const ret = new Yallist();
+ if (to < from || to < 0) {
+ return ret;
+ }
+ if (from < 0) {
+ from = 0;
+ }
+ if (to > this.length) {
+ to = this.length;
+ }
+ let walker = this.head;
+ let i = 0;
+ for (i = 0; !!walker && i < from; i++) {
+ walker = walker.next;
+ }
+ for (; !!walker && i < to; i++, walker = walker.next) {
+ ret.push(walker.value);
+ }
+ return ret;
+ }
+ sliceReverse(from = 0, to = this.length) {
+ if (to < 0) {
+ to += this.length;
+ }
+ if (from < 0) {
+ from += this.length;
+ }
+ const ret = new Yallist();
+ if (to < from || to < 0) {
+ return ret;
+ }
+ if (from < 0) {
+ from = 0;
+ }
+ if (to > this.length) {
+ to = this.length;
+ }
+ let i = this.length;
+ let walker = this.tail;
+ for (; !!walker && i > to; i--) {
+ walker = walker.prev;
+ }
+ for (; !!walker && i > from; i--, walker = walker.prev) {
+ ret.push(walker.value);
+ }
+ return ret;
+ }
+ splice(start, deleteCount = 0, ...nodes) {
+ if (start > this.length) {
+ start = this.length - 1;
+ }
+ if (start < 0) {
+ start = this.length + start;
+ }
+ let walker = this.head;
+ for (let i = 0; !!walker && i < start; i++) {
+ walker = walker.next;
+ }
+ const ret = [];
+ for (let i = 0; !!walker && i < deleteCount; i++) {
+ ret.push(walker.value);
+ walker = this.removeNode(walker);
+ }
+ if (!walker) {
+ walker = this.tail;
+ }
+ else if (walker !== this.tail) {
+ walker = walker.prev;
+ }
+ for (const v of nodes) {
+ walker = insertAfter(this, walker, v);
+ }
+ return ret;
+ }
+ reverse() {
+ const head = this.head;
+ const tail = this.tail;
+ for (let walker = head; !!walker; walker = walker.prev) {
+ const p = walker.prev;
+ walker.prev = walker.next;
+ walker.next = p;
+ }
+ this.head = tail;
+ this.tail = head;
+ return this;
+ }
+}
+exports.Yallist = Yallist;
+// insertAfter undefined means "make the node the new head of list"
+function insertAfter(self, node, value) {
+ const prev = node;
+ const next = node ? node.next : self.head;
+ const inserted = new Node(value, prev, next, self);
+ if (inserted.next === undefined) {
+ self.tail = inserted;
+ }
+ if (inserted.prev === undefined) {
+ self.head = inserted;
+ }
+ self.length++;
+ return inserted;
+}
+function push(self, item) {
+ self.tail = new Node(item, self.tail, undefined, self);
+ if (!self.head) {
+ self.head = self.tail;
+ }
+ self.length++;
+}
+function unshift(self, item) {
+ self.head = new Node(item, undefined, self.head, self);
+ if (!self.tail) {
+ self.tail = self.head;
+ }
+ self.length++;
+}
+class Node {
+ list;
+ next;
+ prev;
+ value;
+ constructor(value, prev, next, list) {
+ this.list = list;
+ this.value = value;
+ if (prev) {
+ prev.next = this;
+ this.prev = prev;
+ }
+ else {
+ this.prev = undefined;
+ }
+ if (next) {
+ next.prev = this;
+ this.next = next;
+ }
+ else {
+ this.next = undefined;
+ }
+ }
+}
+exports.Node = Node;
+//# sourceMappingURL=index.js.map \ No newline at end of file
diff --git a/node_modules/yallist/dist/commonjs/package.json b/node_modules/yallist/dist/commonjs/package.json
new file mode 100644
index 0000000..5bbefff
--- /dev/null
+++ b/node_modules/yallist/dist/commonjs/package.json
@@ -0,0 +1,3 @@
+{
+ "type": "commonjs"
+}
diff --git a/node_modules/yallist/dist/esm/index.d.ts b/node_modules/yallist/dist/esm/index.d.ts
new file mode 100644
index 0000000..044a1d7
--- /dev/null
+++ b/node_modules/yallist/dist/esm/index.d.ts
@@ -0,0 +1,39 @@
+export declare class Yallist<T = unknown> {
+ tail?: Node<T>;
+ head?: Node<T>;
+ length: number;
+ static create<T = unknown>(list?: Iterable<T>): Yallist<T>;
+ constructor(list?: Iterable<T>);
+ [Symbol.iterator](): Generator<T, void, unknown>;
+ removeNode(node: Node<T>): Node<T> | undefined;
+ unshiftNode(node: Node<T>): void;
+ pushNode(node: Node<T>): void;
+ push(...args: T[]): number;
+ unshift(...args: T[]): number;
+ pop(): T | undefined;
+ shift(): T | undefined;
+ forEach(fn: (value: T, i: number, list: Yallist<T>) => any, thisp?: any): void;
+ forEachReverse(fn: (value: T, i: number, list: Yallist<T>) => any, thisp?: any): void;
+ get(n: number): T | undefined;
+ getReverse(n: number): T | undefined;
+ map<R = any>(fn: (value: T, list: Yallist<T>) => R, thisp?: any): Yallist<R>;
+ mapReverse<R = any>(fn: (value: T, list: Yallist<T>) => R, thisp?: any): Yallist<R>;
+ reduce(fn: (left: T, right: T, i: number) => T): T;
+ reduce<R = any>(fn: (acc: R, next: T, i: number) => R, initial: R): R;
+ reduceReverse(fn: (left: T, right: T, i: number) => T): T;
+ reduceReverse<R = any>(fn: (acc: R, next: T, i: number) => R, initial: R): R;
+ toArray(): any[];
+ toArrayReverse(): any[];
+ slice(from?: number, to?: number): Yallist<unknown>;
+ sliceReverse(from?: number, to?: number): Yallist<unknown>;
+ splice(start: number, deleteCount?: number, ...nodes: T[]): T[];
+ reverse(): this;
+}
+export declare class Node<T = unknown> {
+ list?: Yallist<T>;
+ next?: Node<T>;
+ prev?: Node<T>;
+ value: T;
+ constructor(value: T, prev?: Node<T> | undefined, next?: Node<T> | undefined, list?: Yallist<T> | undefined);
+}
+//# sourceMappingURL=index.d.ts.map \ No newline at end of file
diff --git a/node_modules/yallist/dist/esm/index.js b/node_modules/yallist/dist/esm/index.js
new file mode 100644
index 0000000..3d81c51
--- /dev/null
+++ b/node_modules/yallist/dist/esm/index.js
@@ -0,0 +1,379 @@
+export class Yallist {
+ tail;
+ head;
+ length = 0;
+ static create(list = []) {
+ return new Yallist(list);
+ }
+ constructor(list = []) {
+ for (const item of list) {
+ this.push(item);
+ }
+ }
+ *[Symbol.iterator]() {
+ for (let walker = this.head; walker; walker = walker.next) {
+ yield walker.value;
+ }
+ }
+ removeNode(node) {
+ if (node.list !== this) {
+ throw new Error('removing node which does not belong to this list');
+ }
+ const next = node.next;
+ const prev = node.prev;
+ if (next) {
+ next.prev = prev;
+ }
+ if (prev) {
+ prev.next = next;
+ }
+ if (node === this.head) {
+ this.head = next;
+ }
+ if (node === this.tail) {
+ this.tail = prev;
+ }
+ this.length--;
+ node.next = undefined;
+ node.prev = undefined;
+ node.list = undefined;
+ return next;
+ }
+ unshiftNode(node) {
+ if (node === this.head) {
+ return;
+ }
+ if (node.list) {
+ node.list.removeNode(node);
+ }
+ const head = this.head;
+ node.list = this;
+ node.next = head;
+ if (head) {
+ head.prev = node;
+ }
+ this.head = node;
+ if (!this.tail) {
+ this.tail = node;
+ }
+ this.length++;
+ }
+ pushNode(node) {
+ if (node === this.tail) {
+ return;
+ }
+ if (node.list) {
+ node.list.removeNode(node);
+ }
+ const tail = this.tail;
+ node.list = this;
+ node.prev = tail;
+ if (tail) {
+ tail.next = node;
+ }
+ this.tail = node;
+ if (!this.head) {
+ this.head = node;
+ }
+ this.length++;
+ }
+ push(...args) {
+ for (let i = 0, l = args.length; i < l; i++) {
+ push(this, args[i]);
+ }
+ return this.length;
+ }
+ unshift(...args) {
+ for (var i = 0, l = args.length; i < l; i++) {
+ unshift(this, args[i]);
+ }
+ return this.length;
+ }
+ pop() {
+ if (!this.tail) {
+ return undefined;
+ }
+ const res = this.tail.value;
+ const t = this.tail;
+ this.tail = this.tail.prev;
+ if (this.tail) {
+ this.tail.next = undefined;
+ }
+ else {
+ this.head = undefined;
+ }
+ t.list = undefined;
+ this.length--;
+ return res;
+ }
+ shift() {
+ if (!this.head) {
+ return undefined;
+ }
+ const res = this.head.value;
+ const h = this.head;
+ this.head = this.head.next;
+ if (this.head) {
+ this.head.prev = undefined;
+ }
+ else {
+ this.tail = undefined;
+ }
+ h.list = undefined;
+ this.length--;
+ return res;
+ }
+ forEach(fn, thisp) {
+ thisp = thisp || this;
+ for (let walker = this.head, i = 0; !!walker; i++) {
+ fn.call(thisp, walker.value, i, this);
+ walker = walker.next;
+ }
+ }
+ forEachReverse(fn, thisp) {
+ thisp = thisp || this;
+ for (let walker = this.tail, i = this.length - 1; !!walker; i--) {
+ fn.call(thisp, walker.value, i, this);
+ walker = walker.prev;
+ }
+ }
+ get(n) {
+ let i = 0;
+ let walker = this.head;
+ for (; !!walker && i < n; i++) {
+ walker = walker.next;
+ }
+ if (i === n && !!walker) {
+ return walker.value;
+ }
+ }
+ getReverse(n) {
+ let i = 0;
+ let walker = this.tail;
+ for (; !!walker && i < n; i++) {
+ // abort out of the list early if we hit a cycle
+ walker = walker.prev;
+ }
+ if (i === n && !!walker) {
+ return walker.value;
+ }
+ }
+ map(fn, thisp) {
+ thisp = thisp || this;
+ const res = new Yallist();
+ for (let walker = this.head; !!walker;) {
+ res.push(fn.call(thisp, walker.value, this));
+ walker = walker.next;
+ }
+ return res;
+ }
+ mapReverse(fn, thisp) {
+ thisp = thisp || this;
+ var res = new Yallist();
+ for (let walker = this.tail; !!walker;) {
+ res.push(fn.call(thisp, walker.value, this));
+ walker = walker.prev;
+ }
+ return res;
+ }
+ reduce(fn, initial) {
+ let acc;
+ let walker = this.head;
+ if (arguments.length > 1) {
+ acc = initial;
+ }
+ else if (this.head) {
+ walker = this.head.next;
+ acc = this.head.value;
+ }
+ else {
+ throw new TypeError('Reduce of empty list with no initial value');
+ }
+ for (var i = 0; !!walker; i++) {
+ acc = fn(acc, walker.value, i);
+ walker = walker.next;
+ }
+ return acc;
+ }
+ reduceReverse(fn, initial) {
+ let acc;
+ let walker = this.tail;
+ if (arguments.length > 1) {
+ acc = initial;
+ }
+ else if (this.tail) {
+ walker = this.tail.prev;
+ acc = this.tail.value;
+ }
+ else {
+ throw new TypeError('Reduce of empty list with no initial value');
+ }
+ for (let i = this.length - 1; !!walker; i--) {
+ acc = fn(acc, walker.value, i);
+ walker = walker.prev;
+ }
+ return acc;
+ }
+ toArray() {
+ const arr = new Array(this.length);
+ for (let i = 0, walker = this.head; !!walker; i++) {
+ arr[i] = walker.value;
+ walker = walker.next;
+ }
+ return arr;
+ }
+ toArrayReverse() {
+ const arr = new Array(this.length);
+ for (let i = 0, walker = this.tail; !!walker; i++) {
+ arr[i] = walker.value;
+ walker = walker.prev;
+ }
+ return arr;
+ }
+ slice(from = 0, to = this.length) {
+ if (to < 0) {
+ to += this.length;
+ }
+ if (from < 0) {
+ from += this.length;
+ }
+ const ret = new Yallist();
+ if (to < from || to < 0) {
+ return ret;
+ }
+ if (from < 0) {
+ from = 0;
+ }
+ if (to > this.length) {
+ to = this.length;
+ }
+ let walker = this.head;
+ let i = 0;
+ for (i = 0; !!walker && i < from; i++) {
+ walker = walker.next;
+ }
+ for (; !!walker && i < to; i++, walker = walker.next) {
+ ret.push(walker.value);
+ }
+ return ret;
+ }
+ sliceReverse(from = 0, to = this.length) {
+ if (to < 0) {
+ to += this.length;
+ }
+ if (from < 0) {
+ from += this.length;
+ }
+ const ret = new Yallist();
+ if (to < from || to < 0) {
+ return ret;
+ }
+ if (from < 0) {
+ from = 0;
+ }
+ if (to > this.length) {
+ to = this.length;
+ }
+ let i = this.length;
+ let walker = this.tail;
+ for (; !!walker && i > to; i--) {
+ walker = walker.prev;
+ }
+ for (; !!walker && i > from; i--, walker = walker.prev) {
+ ret.push(walker.value);
+ }
+ return ret;
+ }
+ splice(start, deleteCount = 0, ...nodes) {
+ if (start > this.length) {
+ start = this.length - 1;
+ }
+ if (start < 0) {
+ start = this.length + start;
+ }
+ let walker = this.head;
+ for (let i = 0; !!walker && i < start; i++) {
+ walker = walker.next;
+ }
+ const ret = [];
+ for (let i = 0; !!walker && i < deleteCount; i++) {
+ ret.push(walker.value);
+ walker = this.removeNode(walker);
+ }
+ if (!walker) {
+ walker = this.tail;
+ }
+ else if (walker !== this.tail) {
+ walker = walker.prev;
+ }
+ for (const v of nodes) {
+ walker = insertAfter(this, walker, v);
+ }
+ return ret;
+ }
+ reverse() {
+ const head = this.head;
+ const tail = this.tail;
+ for (let walker = head; !!walker; walker = walker.prev) {
+ const p = walker.prev;
+ walker.prev = walker.next;
+ walker.next = p;
+ }
+ this.head = tail;
+ this.tail = head;
+ return this;
+ }
+}
+// insertAfter undefined means "make the node the new head of list"
+function insertAfter(self, node, value) {
+ const prev = node;
+ const next = node ? node.next : self.head;
+ const inserted = new Node(value, prev, next, self);
+ if (inserted.next === undefined) {
+ self.tail = inserted;
+ }
+ if (inserted.prev === undefined) {
+ self.head = inserted;
+ }
+ self.length++;
+ return inserted;
+}
+function push(self, item) {
+ self.tail = new Node(item, self.tail, undefined, self);
+ if (!self.head) {
+ self.head = self.tail;
+ }
+ self.length++;
+}
+function unshift(self, item) {
+ self.head = new Node(item, undefined, self.head, self);
+ if (!self.tail) {
+ self.tail = self.head;
+ }
+ self.length++;
+}
+export class Node {
+ list;
+ next;
+ prev;
+ value;
+ constructor(value, prev, next, list) {
+ this.list = list;
+ this.value = value;
+ if (prev) {
+ prev.next = this;
+ this.prev = prev;
+ }
+ else {
+ this.prev = undefined;
+ }
+ if (next) {
+ next.prev = this;
+ this.next = next;
+ }
+ else {
+ this.next = undefined;
+ }
+ }
+}
+//# sourceMappingURL=index.js.map \ No newline at end of file
diff --git a/node_modules/yallist/dist/esm/package.json b/node_modules/yallist/dist/esm/package.json
new file mode 100644
index 0000000..3dbc1ca
--- /dev/null
+++ b/node_modules/yallist/dist/esm/package.json
@@ -0,0 +1,3 @@
+{
+ "type": "module"
+}
diff --git a/node_modules/yallist/package.json b/node_modules/yallist/package.json
new file mode 100644
index 0000000..2f52478
--- /dev/null
+++ b/node_modules/yallist/package.json
@@ -0,0 +1,68 @@
+{
+ "name": "yallist",
+ "version": "5.0.0",
+ "description": "Yet Another Linked List",
+ "files": [
+ "dist"
+ ],
+ "devDependencies": {
+ "prettier": "^3.2.5",
+ "tap": "^18.7.2",
+ "tshy": "^1.13.1",
+ "typedoc": "^0.25.13"
+ },
+ "scripts": {
+ "preversion": "npm test",
+ "postversion": "npm publish",
+ "prepublishOnly": "git push origin --follow-tags",
+ "prepare": "tshy",
+ "pretest": "npm run prepare",
+ "presnap": "npm run prepare",
+ "test": "tap",
+ "snap": "tap",
+ "format": "prettier --write . --loglevel warn --ignore-path ../../.prettierignore --cache",
+ "typedoc": "typedoc"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/isaacs/yallist.git"
+ },
+ "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
+ "license": "BlueOak-1.0.0",
+ "tshy": {
+ "exports": {
+ "./package.json": "./package.json",
+ ".": "./src/index.ts"
+ }
+ },
+ "exports": {
+ "./package.json": "./package.json",
+ ".": {
+ "import": {
+ "types": "./dist/esm/index.d.ts",
+ "default": "./dist/esm/index.js"
+ },
+ "require": {
+ "types": "./dist/commonjs/index.d.ts",
+ "default": "./dist/commonjs/index.js"
+ }
+ }
+ },
+ "main": "./dist/commonjs/index.js",
+ "types": "./dist/commonjs/index.d.ts",
+ "type": "module",
+ "prettier": {
+ "semi": false,
+ "printWidth": 70,
+ "tabWidth": 2,
+ "useTabs": false,
+ "singleQuote": true,
+ "jsxSingleQuote": false,
+ "bracketSameLine": true,
+ "arrowParens": "avoid",
+ "endOfLine": "lf"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+}