@vope/utils 1.4.27 → 1.4.28

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/cjs/index.js CHANGED
@@ -5484,6 +5484,16 @@ var MemoryBasic = class {
5484
5484
  });
5485
5485
  return this;
5486
5486
  }
5487
+ /**
5488
+ * 返回位于指定索引处的项
5489
+ */
5490
+ at(index) {
5491
+ const { list } = this;
5492
+ if (index < 0) {
5493
+ index += list.length;
5494
+ }
5495
+ return this.list.at(index);
5496
+ }
5487
5497
  /**
5488
5498
  * 遍历所有存储数据(按入栈顺序)
5489
5499
  */
@@ -5664,6 +5674,12 @@ var MemorySimple = class {
5664
5674
  const key2 = this.#key;
5665
5675
  return typeof key2 === "function" ? key2(data) : data[key2];
5666
5676
  }
5677
+ /**
5678
+ * 返回位于指定索引处的项
5679
+ */
5680
+ at(index) {
5681
+ return this.#memory.at(index);
5682
+ }
5667
5683
  push(...list) {
5668
5684
  const memory = this.#memory;
5669
5685
  list.forEach((data) => {
@@ -34,6 +34,16 @@ class MemoryBasic {
34
34
  });
35
35
  return this;
36
36
  }
37
+ /**
38
+ * 返回位于指定索引处的项
39
+ */
40
+ at(index) {
41
+ const { list } = this;
42
+ if (index < 0) {
43
+ index += list.length;
44
+ }
45
+ return this.list.at(index);
46
+ }
37
47
  /**
38
48
  * 遍历所有存储数据(按入栈顺序)
39
49
  */
@@ -16,6 +16,12 @@ class MemorySimple {
16
16
  const key = this.#key;
17
17
  return typeof key === "function" ? key(data) : data[key];
18
18
  }
19
+ /**
20
+ * 返回位于指定索引处的项
21
+ */
22
+ at(index) {
23
+ return this.#memory.at(index);
24
+ }
19
25
  push(...list) {
20
26
  const memory = this.#memory;
21
27
  list.forEach((data) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vope/utils",
3
- "version": "1.4.27",
3
+ "version": "1.4.28",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -31,6 +31,10 @@ export declare class MemoryBasic<T, Reactor, Type extends Memory.Type> {
31
31
  constructor(key: Memory.Pitch<T, Type>, config: Config<Reactor>);
32
32
  protected getType(data: T): Type;
33
33
  push(...list: T[]): this;
34
+ /**
35
+ * 返回位于指定索引处的项
36
+ */
37
+ at(index: number): T | undefined;
34
38
  /**
35
39
  * 遍历所有存储数据(按入栈顺序)
36
40
  */
@@ -6,6 +6,7 @@ type Transform<T, V> = {
6
6
  };
7
7
  type Basic<T, V, Type extends Memory.Type> = Assign<Transform<Omit<MemoryBasic<T, V, Type>, 'forType'>, MemorySimple<T, Type>>, {
8
8
  get(type: Type): T | null;
9
+ at(index: number): T | undefined;
9
10
  }>;
10
11
  /**
11
12
  * 简易存储(不分类)
@@ -14,6 +15,10 @@ export declare class MemorySimple<T, Type extends Memory.Type> implements Basic<
14
15
  #private;
15
16
  get size(): number;
16
17
  constructor(key: Memory.Pitch<T, Type>);
18
+ /**
19
+ * 返回位于指定索引处的项
20
+ */
21
+ at(index: number): T | undefined;
17
22
  push(...list: T[]): this;
18
23
  /**
19
24
  * 获取指定类型存储数据