@zoodogood/utils 4.2.0-change.3344 → 4.2.1-change.3358

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.
@@ -39,6 +39,7 @@ export declare class LazySortEntry<T> extends Array {
39
39
  set length(value: number);
40
40
  [Symbol.iterator](): Generator<WithValue<T>>;
41
41
  toArray(): WithValue<T>[];
42
+ at(at: number): WithValue<T> | undefined;
42
43
  positive_at(at: number): (WithValue<T> | undefined);
43
44
  find(predicate: Predicate<WithValue<T>>): WithValue<T> | undefined;
44
45
  findIndex(predicate: Predicate<WithValue<T>>): number;
@@ -116,6 +116,9 @@ export class LazySortEntry extends Array {
116
116
  }
117
117
  return __classPrivateFieldGet(this, _LazySortEntry_source, "f").chunks.map($5 => $5.entry().toArray()).flat();
118
118
  }
119
+ at(at) {
120
+ return at < 0 ? this.positive_at(__classPrivateFieldGet(this, _LazySortEntry_source, "f").length - at) : this.positive_at(at);
121
+ }
119
122
  positive_at(at) {
120
123
  if (__classPrivateFieldGet(this, _LazySortEntry_source, "f").is_atomic) {
121
124
  return __classPrivateFieldGet(this, _LazySortEntry_source, "f").atomic_chunk_arr[at];
@@ -1,10 +1,12 @@
1
+ export * from "./BusyNumeric.js";
1
2
  export * from "./CustomCollector.js";
2
- export * from "./GlitchText.js";
3
- export * from "./getRandomNumberInRange.js";
4
- export * from "./rangeToArray.js";
5
- export * from "./getRandomElementFromArray.js";
6
3
  export * from "./DotNotatedInterface.js";
7
4
  export * from "./ExtendedEnum/mod.js";
5
+ export * from "./getRandomElementFromArray.js";
6
+ export * from "./getRandomNumberInRange.js";
7
+ export * from "./GlitchText.js";
8
+ export * from "./LazySort/LazySort.build.js";
9
+ export * from "./rangeToArray.js";
8
10
  declare function omit(object: object, filter: CallableFunction): {
9
11
  [k: string]: any;
10
12
  };
@@ -1,10 +1,12 @@
1
+ export * from "./BusyNumeric.js";
1
2
  export * from "./CustomCollector.js";
2
- export * from "./GlitchText.js";
3
- export * from "./getRandomNumberInRange.js";
4
- export * from "./rangeToArray.js";
5
- export * from "./getRandomElementFromArray.js";
6
3
  export * from "./DotNotatedInterface.js";
7
4
  export * from "./ExtendedEnum/mod.js";
5
+ export * from "./getRandomElementFromArray.js";
6
+ export * from "./getRandomNumberInRange.js";
7
+ export * from "./GlitchText.js";
8
+ export * from "./LazySort/LazySort.build.js";
9
+ export * from "./rangeToArray.js";
8
10
  function omit(object, filter) {
9
11
  const entries = Object.entries(object).filter(([key, value], i) => filter(key, value, i));
10
12
  return Object.fromEntries(entries);
@@ -1,6 +1,9 @@
1
- export * from "./TextTableBuilder.js";
1
+ export * from "./binary_search.js";
2
2
  export * from "./BracketsParser.js";
3
3
  export { CliParser } from "./CliParser.js";
4
+ export * from "./createDefaultPreventable.js";
5
+ export * from "./normalize.js";
6
+ export * from "./TextTableBuilder.js";
4
7
  interface IEndingOptions {
5
8
  unite?: (quantity: number, word: string) => string;
6
9
  }
@@ -1,6 +1,9 @@
1
- export * from "./TextTableBuilder.js";
1
+ export * from "./binary_search.js";
2
2
  export * from "./BracketsParser.js";
3
3
  export { CliParser } from "./CliParser.js";
4
+ export * from "./createDefaultPreventable.js";
5
+ export * from "./normalize.js";
6
+ export * from "./TextTableBuilder.js";
4
7
  function ending(quantity = 0, base, multiple, alone, double, options = {}) {
5
8
  if (isNaN(quantity))
6
9
  return NaN;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zoodogood/utils",
3
3
  "type": "module",
4
- "version": "4.2.0-change.3344",
4
+ "version": "4.2.1-change.3358",
5
5
  "description": "",
6
6
  "main": "lib/index.js",
7
7
  "homepage": "https://zoodogood.github.io/utils",
@@ -1,69 +0,0 @@
1
- import { LazySort } from "./LazySort.build.js";
2
- import { describe, expect, test } from "vitest";
3
- describe("LazySortEntry.splice", () => {
4
- test("Splice removes and inserts elements correctly", () => {
5
- const source = LazySort.ofNumbers([
6
- 5, 1, 3, 4, 2, 17, 11, 10, 9, 15, 14, 16, 13, 12, 7, 8, 6, 199,
7
- ]);
8
- const entry = source.entry();
9
- // Проверка начального состояния
10
- expect(source.length).toBe(18);
11
- expect(entry.toArray().map(([value]) => value)).toEqual([
12
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 199,
13
- ]);
14
- // Удаление элементов
15
- const removed = entry.splice(5, 3); // Удаляем элементы с 6-й по 8-й (0-индексация)
16
- expect(removed.map(([value]) => value)).toEqual([6, 7, 8]);
17
- // Проверяем обновленное состояние
18
- expect(source.length).toBe(15);
19
- expect(entry.toArray().map(([value]) => value)).toEqual([
20
- 1, 2, 3, 4, 5, 9, 10, 11, 12, 13, 14, 15, 16, 17, 199,
21
- ]);
22
- // Вставка элементов
23
- entry.splice(2, 0, [99, 99], [98, 98]); // Вставляем два элемента после второго
24
- expect(source.length).toBe(17);
25
- expect(entry.toArray().map(([value]) => value)).toEqual([
26
- 1, 2, 99, 98, 3, 4, 5, 9, 10, 11, 12, 13, 14, 15, 16, 17, 199,
27
- ]);
28
- // Удаление и замена
29
- // 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
30
- const replaced = entry.splice(9, 2, [77, 77]);
31
- expect(replaced.map(([value]) => value)).toEqual([11, 12]);
32
- expect(source.length).toBe(16);
33
- expect(entry.toArray().map(([value]) => value)).toEqual([
34
- 1, 2, 99, 98, 3, 4, 5, 9, 10, 77, 13, 14, 15, 16, 17, 199,
35
- ]);
36
- });
37
- test("Chunk with 199 remains unchanged", () => {
38
- const source = LazySort.ofNumbers([
39
- 5, 1, 3, 4, 2, 17, 11, 10, 9, 15, 14, 16, 13, 12, 7, 8, 6, 199,
40
- ]);
41
- const entry = source.entry();
42
- // Проверяем, что чанк с элементом 199 еще не был просчитан
43
- const chunkWith199Index = source.chunks.findIndex((chunk) => chunk.iterable.some(([value]) => value === 199));
44
- expect(chunkWith199Index).not.toBe(-1); // Чанк должен существовать
45
- const chunkWith199 = source.chunks[chunkWith199Index];
46
- // Убеждаемся, что чанк не просчитан
47
- expect(chunkWith199.calculated).toBe(false);
48
- // Выполняем операцию, которая не должна затрагивать чанк с 199
49
- entry.splice(5, 3);
50
- // Убедимся, что чанк с 199 остался непросчитанным
51
- expect(chunkWith199.calculated).toBe(false);
52
- // Проверяем, что сам чанк не изменился
53
- expect(chunkWith199.iterable.some(([value]) => value === 199)).toBe(true);
54
- entry.splice(-1, 0, [200, 200]);
55
- expect(chunkWith199.calculated).toBe(true);
56
- });
57
- test("Reverse", () => {
58
- const iterable = [
59
- 5, 1, 3, 4, 2, 17, 11, 10, 9, 15, 14, 16, 13, 12, 7, 8, 6, 199,
60
- ].map(($) => [$, $]);
61
- const source = new LazySort(iterable, {
62
- revert: true,
63
- });
64
- const result = source.entry().toArray();
65
- expect(result.map(([value]) => value)).toEqual([
66
- 199, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,
67
- ]);
68
- });
69
- });