@tramvai/core 7.5.1 → 7.7.0

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.d.ts CHANGED
@@ -5,5 +5,5 @@ export * from './actions/declareAction';
5
5
  export * from '@tramvai/tokens-core';
6
6
  export { DI_TOKEN, IS_DI_CHILD_CONTAINER_TOKEN, Scope, Provider, createToken, provide, optional, ExtractTokenType, ExtractDependencyType, Module, MODULE_PARAMETERS, getModuleParameters, walkOfModules, isExtendedModule, ModuleType, ExtendedModule, declareModule, } from '@tinkoff/dippy';
7
7
  export { Deferred } from './utils/deferred.inline';
8
- export { DoubleLinkedList } from './utils/doubleLinkedList';
8
+ export { DoubleLinkedList, ListNode } from './utils/doubleLinkedList';
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -3,7 +3,7 @@
3
3
  * @interface
4
4
  * @template Value
5
5
  */
6
- interface ListNode<Value> {
6
+ export interface ListNode<Value> {
7
7
  /** Reference to next node */
8
8
  next: ListNode<Value> | null;
9
9
  /** Reference to previous node */
@@ -45,7 +45,14 @@ export declare class DoubleLinkedList<Value> {
45
45
  * @example
46
46
  * list.push(42);
47
47
  */
48
- push(value: Value): void;
48
+ push(value: Value): ListNode<Value>;
49
+ /**
50
+ * Adds a value to the start of the list
51
+ * @param {Value} value The value to add
52
+ * @example
53
+ * list.unshift(42);
54
+ */
55
+ unshift(value: Value): ListNode<Value>;
49
56
  /**
50
57
  * Removes and returns the last value from the list
51
58
  * @returns {Value | null} The removed value or null if list is empty
@@ -91,5 +98,4 @@ export declare class DoubleLinkedList<Value> {
91
98
  */
92
99
  [Symbol.iterator](): Generator<Value, void, unknown>;
93
100
  }
94
- export {};
95
101
  //# sourceMappingURL=doubleLinkedList.d.ts.map
@@ -51,7 +51,7 @@ class DoubleLinkedList {
51
51
  if (this.start === null) {
52
52
  this.start = newNode;
53
53
  this.end = newNode;
54
- return;
54
+ return newNode;
55
55
  }
56
56
  const currentEnd = this.end;
57
57
  this.end = newNode;
@@ -59,6 +59,33 @@ class DoubleLinkedList {
59
59
  if (currentEnd !== null) {
60
60
  currentEnd.next = this.end;
61
61
  }
62
+ return newNode;
63
+ }
64
+ /**
65
+ * Adds a value to the start of the list
66
+ * @param {Value} value The value to add
67
+ * @example
68
+ * list.unshift(42);
69
+ */
70
+ unshift(value) {
71
+ const newNode = {
72
+ value,
73
+ next: null,
74
+ prev: null,
75
+ };
76
+ this.length++;
77
+ if (this.start === null) {
78
+ this.start = newNode;
79
+ this.end = newNode;
80
+ return newNode;
81
+ }
82
+ const currentStart = this.start;
83
+ this.start = newNode;
84
+ this.start.next = currentStart;
85
+ if (currentStart !== null) {
86
+ currentStart.prev = this.start;
87
+ }
88
+ return newNode;
62
89
  }
63
90
  /**
64
91
  * Removes and returns the last value from the list
@@ -55,7 +55,7 @@ class DoubleLinkedList {
55
55
  if (this.start === null) {
56
56
  this.start = newNode;
57
57
  this.end = newNode;
58
- return;
58
+ return newNode;
59
59
  }
60
60
  const currentEnd = this.end;
61
61
  this.end = newNode;
@@ -63,6 +63,33 @@ class DoubleLinkedList {
63
63
  if (currentEnd !== null) {
64
64
  currentEnd.next = this.end;
65
65
  }
66
+ return newNode;
67
+ }
68
+ /**
69
+ * Adds a value to the start of the list
70
+ * @param {Value} value The value to add
71
+ * @example
72
+ * list.unshift(42);
73
+ */
74
+ unshift(value) {
75
+ const newNode = {
76
+ value,
77
+ next: null,
78
+ prev: null,
79
+ };
80
+ this.length++;
81
+ if (this.start === null) {
82
+ this.start = newNode;
83
+ this.end = newNode;
84
+ return newNode;
85
+ }
86
+ const currentStart = this.start;
87
+ this.start = newNode;
88
+ this.start.next = currentStart;
89
+ if (currentStart !== null) {
90
+ currentStart.prev = this.start;
91
+ }
92
+ return newNode;
66
93
  }
67
94
  /**
68
95
  * Removes and returns the last value from the list
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/core",
3
- "version": "7.5.1",
3
+ "version": "7.7.0",
4
4
  "description": "",
5
5
  "engines": {
6
6
  "node": ">=20.18.1"
@@ -23,9 +23,9 @@
23
23
  "dependencies": {
24
24
  "@tinkoff/dippy": "0.13.2",
25
25
  "@tinkoff/utils": "^2.1.2",
26
- "@tramvai/tokens-common": "7.5.1",
27
- "@tramvai/tokens-core": "7.5.1",
28
- "@tramvai/types-actions-state-context": "7.5.1",
26
+ "@tramvai/tokens-common": "7.7.0",
27
+ "@tramvai/tokens-core": "7.7.0",
28
+ "@tramvai/types-actions-state-context": "7.7.0",
29
29
  "tslib": "^2.4.0"
30
30
  },
31
31
  "peerDependencies": {