@jiovan-labs/ts-multi-map 0.0.0-stage → 2.0.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.
Files changed (36) hide show
  1. package/LICENSE.txt +21 -0
  2. package/README.md +46 -2
  3. package/dist/cjs/index.d.ts +7 -0
  4. package/dist/cjs/index.js +47 -0
  5. package/dist/cjs/type/declaration.d.ts +10 -0
  6. package/dist/cjs/type/declaration.js +17 -0
  7. package/dist/cjs/util/MultiKeyMap.d.ts +34 -0
  8. package/dist/cjs/util/MultiKeyMap.js +530 -0
  9. package/dist/cjs/util/MultiValueMap.d.ts +35 -0
  10. package/dist/cjs/util/MultiValueMap.js +527 -0
  11. package/dist/cjs/util/RangeMap.d.ts +36 -0
  12. package/dist/cjs/util/RangeMap.js +584 -0
  13. package/dist/cjs/util/ReadonlyMultiKeyMap.d.ts +27 -0
  14. package/dist/cjs/util/ReadonlyMultiKeyMap.js +364 -0
  15. package/dist/cjs/util/ReadonlyMultiValueMap.d.ts +27 -0
  16. package/dist/cjs/util/ReadonlyMultiValueMap.js +365 -0
  17. package/dist/cjs/util/ReadonlyRangeMap.d.ts +27 -0
  18. package/dist/cjs/util/ReadonlyRangeMap.js +376 -0
  19. package/dist/esm/index.d.ts +7 -0
  20. package/dist/esm/index.js +7 -0
  21. package/dist/esm/type/declaration.d.ts +10 -0
  22. package/dist/esm/type/declaration.js +1 -0
  23. package/dist/esm/util/MultiKeyMap.d.ts +34 -0
  24. package/dist/esm/util/MultiKeyMap.js +318 -0
  25. package/dist/esm/util/MultiValueMap.d.ts +35 -0
  26. package/dist/esm/util/MultiValueMap.js +328 -0
  27. package/dist/esm/util/RangeMap.d.ts +36 -0
  28. package/dist/esm/util/RangeMap.js +358 -0
  29. package/dist/esm/util/ReadonlyMultiKeyMap.d.ts +27 -0
  30. package/dist/esm/util/ReadonlyMultiKeyMap.js +136 -0
  31. package/dist/esm/util/ReadonlyMultiValueMap.d.ts +27 -0
  32. package/dist/esm/util/ReadonlyMultiValueMap.js +136 -0
  33. package/dist/esm/util/ReadonlyRangeMap.d.ts +27 -0
  34. package/dist/esm/util/ReadonlyRangeMap.js +135 -0
  35. package/dist/umd/ts-multi-map.min.js +1 -0
  36. package/package.json +111 -5
package/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Jiovan Ltd. All rights reserved.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,47 @@
1
- # Temporary Holding Version
1
+ # @jiovan-labs/ts-multi-map
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![NPM version](https://img.shields.io/npm/v/@jiovan-labs/ts-multi-map.svg?style=flat)](https://npmjs.org/package/@jiovan-labs/ts-multi-map)
4
+ [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](LICENSE.txt)
5
+ [![NPM downloads](http://img.shields.io/npm/dm/@jiovan-labs/ts-multi-map.svg?style=flat)](https://npmjs.org/package/@jiovan-labs/ts-multi-map)
6
+
7
+ 🏅 Multiple key/value map & range map for typescript 👍
8
+
9
+ ## Features
10
+
11
+ ✅ Supports multiple keys/values, with readonly capability
12
+
13
+ ✅ Supports ranges, with readonly capability
14
+
15
+ ## Quickstart
16
+
17
+ You can install this package in your typescript project as follows:
18
+
19
+ ```bash
20
+ $ npm install @jiovan-labs/ts-multi-map --save
21
+ ```
22
+
23
+ Then, you may import components as follows:
24
+
25
+ ```jsx | pure
26
+ import { MultiKeyMap, ReadonlyMultiKeyMap } from '@jiovan-labs/ts-multi-map';
27
+ import { MultiValueMap, ReadonlyMultiValueMap } from '@jiovan-labs/ts-multi-map';
28
+ import { RangeMap, ReadonlyRangeMap } from '@jiovan-labs/ts-multi-map';
29
+ ```
30
+
31
+ Enjoy your coding journey with `ts-multi-map` ✌️
32
+
33
+ ## Document
34
+
35
+ - GitHub pages: [https://jiovan-labs.github.io/ts-multi-map](https://jiovan-labs.github.io/ts-multi-map)
36
+
37
+ ## License
38
+
39
+ This project is under the [MIT License](https://mit-license.org/).
40
+
41
+ ## Copyright
42
+
43
+ Beijing Jiovan Technology Ltd.
44
+
45
+ ## Website
46
+
47
+ - Jiovan: [https://joivan.com](https://joivan.com)
@@ -0,0 +1,7 @@
1
+ export { MultiKeyMap } from './util/MultiKeyMap';
2
+ export { MultiValueMap } from './util/MultiValueMap';
3
+ export { RangeMap } from './util/RangeMap';
4
+ export { ReadonlyMultiKeyMap } from './util/ReadonlyMultiKeyMap';
5
+ export { ReadonlyMultiValueMap } from './util/ReadonlyMultiValueMap';
6
+ export { ReadonlyRangeMap } from './util/ReadonlyRangeMap';
7
+ export * from './type/declaration';
@@ -0,0 +1,47 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ MultiKeyMap: () => import_MultiKeyMap.MultiKeyMap,
24
+ MultiValueMap: () => import_MultiValueMap.MultiValueMap,
25
+ RangeMap: () => import_RangeMap.RangeMap,
26
+ ReadonlyMultiKeyMap: () => import_ReadonlyMultiKeyMap.ReadonlyMultiKeyMap,
27
+ ReadonlyMultiValueMap: () => import_ReadonlyMultiValueMap.ReadonlyMultiValueMap,
28
+ ReadonlyRangeMap: () => import_ReadonlyRangeMap.ReadonlyRangeMap
29
+ });
30
+ module.exports = __toCommonJS(src_exports);
31
+ var import_MultiKeyMap = require("./util/MultiKeyMap");
32
+ var import_MultiValueMap = require("./util/MultiValueMap");
33
+ var import_RangeMap = require("./util/RangeMap");
34
+ var import_ReadonlyMultiKeyMap = require("./util/ReadonlyMultiKeyMap");
35
+ var import_ReadonlyMultiValueMap = require("./util/ReadonlyMultiValueMap");
36
+ var import_ReadonlyRangeMap = require("./util/ReadonlyRangeMap");
37
+ __reExport(src_exports, require("./type/declaration"), module.exports);
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {
40
+ MultiKeyMap,
41
+ MultiValueMap,
42
+ RangeMap,
43
+ ReadonlyMultiKeyMap,
44
+ ReadonlyMultiValueMap,
45
+ ReadonlyRangeMap,
46
+ ...require("./type/declaration")
47
+ });
@@ -0,0 +1,10 @@
1
+ export type MultiKeyMapEntry<K, V> = [K[], V];
2
+ export type MultiKeyMapEntries<K, V> = readonly (readonly [K[], V])[] | null;
3
+ export type MultiValueMapEntry<K, V> = [K, V[]];
4
+ export type MultiValueMapEntries<K, V> = readonly (readonly [K, V[]])[] | null;
5
+ export type RangeMapKey = {
6
+ start: number;
7
+ end: number;
8
+ startInclusive?: boolean;
9
+ endInclusive?: boolean;
10
+ };
@@ -0,0 +1,17 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+
15
+ // src/type/declaration.ts
16
+ var declaration_exports = {};
17
+ module.exports = __toCommonJS(declaration_exports);
@@ -0,0 +1,34 @@
1
+ import { type MultiKeyMapEntries } from "..";
2
+ export declare class MultiKeyMap<K, V> implements Omit<Map<K[], V>, 'delete' | 'forEach' | 'get' | 'has' | 'set' | 'entries' | 'keys' | 'values' | 'push'> {
3
+ private readonly keyMap;
4
+ private readonly valueMap;
5
+ static of<K, V>(entries?: MultiKeyMapEntries<K, V>): MultiKeyMap<K, V>;
6
+ constructor(entries?: MultiKeyMapEntries<K, V>);
7
+ get(keys: K[], defaults?: V): V | undefined;
8
+ set(keys: K[], value: V): void;
9
+ clear(): void;
10
+ keys(): K[][];
11
+ values(): V[];
12
+ entries(): [K[], V][];
13
+ deleteByKey(key: K[]): boolean;
14
+ deleteByKeys(keys: K[][]): boolean;
15
+ deleteByValue(value: V): boolean;
16
+ deleteByValues(values: V[]): boolean;
17
+ forEach(callback: (value?: V, keys?: K[]) => void, thisArg?: any): void;
18
+ forEachIndexing(callback: (value?: V, keys?: K[], index?: number) => void, thisArg?: any): void;
19
+ forEachBreakable(callback: (value?: V, keys?: K[]) => boolean, thisArg?: any): void;
20
+ hasKey(keys: K[], exact?: boolean): boolean;
21
+ hasKeyValue(keys: K[], value: V): boolean;
22
+ hasAnyKeys(keys: K[][], exact?: boolean): boolean;
23
+ hasAllKeys(keys: K[][], exact?: boolean): boolean;
24
+ hasValue(value: V): boolean;
25
+ hasAnyValues(values: V[]): boolean;
26
+ hasAllValues(values: V[]): boolean;
27
+ isEmpty(): boolean;
28
+ isNotEmpty(): boolean;
29
+ getKey(value: V, defaults?: K[]): K[] | undefined;
30
+ [Symbol.iterator](): IterableIterator<[K[], V]>;
31
+ get size(): number;
32
+ get [Symbol.toStringTag](): string;
33
+ toString(): string;
34
+ }