@tstdl/base 0.83.7 → 0.83.8

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/.eslintrc.cjs CHANGED
@@ -66,7 +66,7 @@ module.exports = {
66
66
 
67
67
  /** import */
68
68
  'import/no-duplicates': ['warn', { 'prefer-inline': true }],
69
- 'import/no-cycle': ['error', { ignoreExternal: true }],
69
+ 'import/no-cycle': ['off', { ignoreExternal: true }],
70
70
  'import/no-self-import': ['error'],
71
71
  'import/no-extraneous-dependencies': ['error', { devDependencies: false, includeTypes: true }],
72
72
  'import/no-empty-named-blocks': ['error'],
@@ -1,4 +1,4 @@
1
- import { Collection } from './collection.js';
1
+ import { Dictionary } from './dictionary.js';
2
2
  type Node = {
3
3
  nodeKey: any;
4
4
  parentNode: Node | undefined;
@@ -8,24 +8,26 @@ type Node = {
8
8
  value: any;
9
9
  };
10
10
  type NewMapProvider = () => Map<any, Node>;
11
- export declare class MultiKeyMap<K extends any[], T> extends Collection<[K, T], MultiKeyMap<K, T>> implements Map<K, T> {
11
+ export declare class MultiKeyMap<K extends any[], V> extends Dictionary<K, V, MultiKeyMap<K, V>> {
12
12
  private readonly newMapProvider;
13
13
  private rootNode;
14
14
  readonly [Symbol.toStringTag]: string;
15
15
  constructor(newMapProvider?: NewMapProvider);
16
- includes([key, value]: [K, T]): boolean;
17
- add(value: [K, T]): void;
18
- addMany(values: Iterable<[K, T]>): void;
19
- set(key: K, value: T): this;
16
+ includes([key, value]: [K, V]): boolean;
17
+ add(value: [K, V]): void;
18
+ addMany(values: Iterable<[K, V]>): void;
19
+ setFlat(...keyAndValue: [...key: K, value: V]): void;
20
+ set(key: K, value: V): void;
21
+ hasFlat(...key: K): boolean;
20
22
  has(key: K): boolean;
21
- get(key: K): T | undefined;
23
+ getFlat(...key: K): V | undefined;
24
+ get(key: K): V | undefined;
25
+ deleteFlat(...key: K): boolean;
22
26
  delete(key: K): boolean;
23
- clone(): MultiKeyMap<K, T>;
24
- forEach(callback: (value: T, key: K, map: MultiKeyMap<K, T>) => void, thisArg?: any): void;
25
- entries(): IterableIterator<[K, T]>;
27
+ clone(): MultiKeyMap<K, V>;
26
28
  keys(): IterableIterator<K>;
27
- values(): IterableIterator<T>;
28
- items(): IterableIterator<[K, T]>;
29
+ values(): IterableIterator<V>;
30
+ items(): IterableIterator<[K, V]>;
29
31
  protected _clear(): void;
30
32
  private getNode;
31
33
  private deleteNodeIfEmpty;
@@ -24,8 +24,8 @@ module.exports = __toCommonJS(multi_key_map_exports);
24
24
  var import_lazy_property = require("../utils/object/lazy-property.js");
25
25
  var import_type_guards = require("../utils/type-guards.js");
26
26
  var import_circular_buffer = require("./circular-buffer.js");
27
- var import_collection = require("./collection.js");
28
- class MultiKeyMap extends import_collection.Collection {
27
+ var import_dictionary = require("./dictionary.js");
28
+ class MultiKeyMap extends import_dictionary.Dictionary {
29
29
  newMapProvider;
30
30
  rootNode;
31
31
  [Symbol.toStringTag] = "MultiKeyMap";
@@ -48,6 +48,10 @@ class MultiKeyMap extends import_collection.Collection {
48
48
  this.set(value[0], value[1]);
49
49
  }
50
50
  }
51
+ setFlat(...keyAndValue) {
52
+ const key = keyAndValue.slice(0, -1);
53
+ this.set(key, keyAndValue[keyAndValue.length - 1]);
54
+ }
51
55
  set(key, value) {
52
56
  const node = this.getNode(key, true);
53
57
  const hasValue = node.hasValue;
@@ -56,12 +60,17 @@ class MultiKeyMap extends import_collection.Collection {
56
60
  if (!hasValue) {
57
61
  this.incrementSize();
58
62
  }
59
- return this;
63
+ }
64
+ hasFlat(...key) {
65
+ return this.has(key);
60
66
  }
61
67
  has(key) {
62
68
  const node = this.getNode(key, false);
63
69
  return (0, import_type_guards.isDefined)(node) && node.hasValue;
64
70
  }
71
+ getFlat(...key) {
72
+ return this.get(key);
73
+ }
65
74
  get(key) {
66
75
  const node = this.getNode(key, false);
67
76
  if ((0, import_type_guards.isUndefined)(node)) {
@@ -69,6 +78,9 @@ class MultiKeyMap extends import_collection.Collection {
69
78
  }
70
79
  return node.value;
71
80
  }
81
+ deleteFlat(...key) {
82
+ return this.delete(key);
83
+ }
72
84
  delete(key) {
73
85
  const node = this.getNode(key, false);
74
86
  if ((0, import_type_guards.isUndefined)(node)) {
@@ -88,15 +100,6 @@ class MultiKeyMap extends import_collection.Collection {
88
100
  clone.addMany(this);
89
101
  return clone;
90
102
  }
91
- forEach(callback, thisArg) {
92
- const boundCallback = callback.bind(thisArg);
93
- for (const item of this) {
94
- boundCallback(item[1], item[0], this);
95
- }
96
- }
97
- entries() {
98
- return this.items();
99
- }
100
103
  *keys() {
101
104
  for (const item of this) {
102
105
  yield item[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.83.7",
3
+ "version": "0.83.8",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"