data-structure-typed 1.18.8 → 1.19.1
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/README.md +169 -168
- package/dist/data-structures/binary-tree/abstract-binary-tree.d.ts +182 -148
- package/dist/data-structures/binary-tree/abstract-binary-tree.js +288 -316
- package/dist/data-structures/binary-tree/avl-tree.d.ts +22 -14
- package/dist/data-structures/binary-tree/avl-tree.js +23 -17
- package/dist/data-structures/binary-tree/binary-tree.d.ts +12 -26
- package/dist/data-structures/binary-tree/binary-tree.js +11 -26
- package/dist/data-structures/binary-tree/bst.d.ts +62 -74
- package/dist/data-structures/binary-tree/bst.js +72 -96
- package/dist/data-structures/binary-tree/rb-tree.d.ts +3 -14
- package/dist/data-structures/binary-tree/rb-tree.js +5 -17
- package/dist/data-structures/binary-tree/tree-multiset.d.ts +186 -17
- package/dist/data-structures/binary-tree/tree-multiset.js +712 -28
- package/dist/data-structures/graph/abstract-graph.d.ts +107 -49
- package/dist/data-structures/graph/abstract-graph.js +104 -55
- package/dist/data-structures/graph/directed-graph.d.ts +95 -94
- package/dist/data-structures/graph/directed-graph.js +95 -95
- package/dist/data-structures/graph/undirected-graph.d.ts +62 -61
- package/dist/data-structures/graph/undirected-graph.js +62 -61
- package/dist/data-structures/interfaces/abstract-binary-tree.d.ts +10 -15
- package/dist/data-structures/interfaces/avl-tree.d.ts +2 -2
- package/dist/data-structures/interfaces/binary-tree.d.ts +1 -1
- package/dist/data-structures/interfaces/bst.d.ts +3 -4
- package/dist/data-structures/interfaces/rb-tree.d.ts +1 -2
- package/dist/data-structures/interfaces/tree-multiset.d.ts +3 -3
- package/dist/data-structures/types/abstract-binary-tree.d.ts +1 -1
- package/dist/data-structures/types/tree-multiset.d.ts +3 -3
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/types/index.d.ts +1 -0
- package/dist/utils/types/index.js +1 -0
- package/dist/utils/types/utils.d.ts +0 -18
- package/dist/utils/types/validate-type.d.ts +19 -0
- package/dist/utils/types/validate-type.js +2 -0
- package/dist/utils/utils.d.ts +3 -8
- package/dist/utils/utils.js +1 -83
- package/dist/utils/validate-type.d.ts +45 -0
- package/dist/utils/validate-type.js +58 -0
- package/package.json +6 -2
- package/tsconfig.json +0 -17
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isNumber = exports.isObjectWithNumberId = exports.isObjectWithNonNumberId = exports.isObjectWithoutId = exports.isNonNumberNonObjectButDefined = exports.parseBySchema = exports.binaryTreeNodeValWithId = exports.objectWithNumberIdSchema = exports.objectWithNonNumberIdSchema = exports.keyValueObjectWithIdSchema = exports.objectWithoutIdSchema = exports.keyValueObjectSchema = exports.nonNumberNonObjectButDefinedSchema = void 0;
|
|
4
|
+
var zod_1 = require("zod");
|
|
5
|
+
exports.nonNumberNonObjectButDefinedSchema = zod_1.z.union([zod_1.z.string(),
|
|
6
|
+
zod_1.z.boolean(), zod_1.z.any()])
|
|
7
|
+
.nullable();
|
|
8
|
+
exports.keyValueObjectSchema = zod_1.z.record(zod_1.z.unknown());
|
|
9
|
+
exports.objectWithoutIdSchema = exports.keyValueObjectSchema.refine(function (obj) { return !('id' in obj); }, {
|
|
10
|
+
message: 'Object cannot contain the \'id\' field',
|
|
11
|
+
});
|
|
12
|
+
exports.keyValueObjectWithIdSchema = zod_1.z.record(zod_1.z.any()).and(zod_1.z.object({
|
|
13
|
+
id: zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.any()])
|
|
14
|
+
}));
|
|
15
|
+
exports.objectWithNonNumberIdSchema = zod_1.z.record(zod_1.z.any()).and(zod_1.z.object({
|
|
16
|
+
id: zod_1.z
|
|
17
|
+
.union([zod_1.z.string(), zod_1.z.boolean(), zod_1.z.any(), zod_1.z.any(), zod_1.z.undefined()])
|
|
18
|
+
.nullable()
|
|
19
|
+
}));
|
|
20
|
+
exports.objectWithNumberIdSchema = zod_1.z.record(zod_1.z.any()).and(zod_1.z.object({
|
|
21
|
+
id: zod_1.z.number()
|
|
22
|
+
}));
|
|
23
|
+
exports.binaryTreeNodeValWithId = zod_1.z.union([
|
|
24
|
+
exports.nonNumberNonObjectButDefinedSchema,
|
|
25
|
+
exports.objectWithoutIdSchema,
|
|
26
|
+
exports.objectWithNonNumberIdSchema,
|
|
27
|
+
exports.objectWithNumberIdSchema
|
|
28
|
+
]);
|
|
29
|
+
function parseBySchema(schema, val) {
|
|
30
|
+
try {
|
|
31
|
+
schema.parse(val);
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.parseBySchema = parseBySchema;
|
|
39
|
+
function isNonNumberNonObjectButDefined(val) {
|
|
40
|
+
return parseBySchema(exports.nonNumberNonObjectButDefinedSchema, val);
|
|
41
|
+
}
|
|
42
|
+
exports.isNonNumberNonObjectButDefined = isNonNumberNonObjectButDefined;
|
|
43
|
+
function isObjectWithoutId(val) {
|
|
44
|
+
return parseBySchema(exports.objectWithoutIdSchema, val);
|
|
45
|
+
}
|
|
46
|
+
exports.isObjectWithoutId = isObjectWithoutId;
|
|
47
|
+
function isObjectWithNonNumberId(val) {
|
|
48
|
+
return parseBySchema(exports.objectWithNonNumberIdSchema, val);
|
|
49
|
+
}
|
|
50
|
+
exports.isObjectWithNonNumberId = isObjectWithNonNumberId;
|
|
51
|
+
function isObjectWithNumberId(val) {
|
|
52
|
+
return parseBySchema(exports.objectWithNonNumberIdSchema, val);
|
|
53
|
+
}
|
|
54
|
+
exports.isObjectWithNumberId = isObjectWithNumberId;
|
|
55
|
+
function isNumber(val) {
|
|
56
|
+
return typeof val === 'number';
|
|
57
|
+
}
|
|
58
|
+
exports.isNumber = isNumber;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "data-structure-typed",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.19.1",
|
|
4
|
+
"description": "Javascript & TypeScript Data Structure Library, meticulously crafted to empower developers with a versatile set of essential data structures. Our library includes a wide range of data structures, such as Binary Tree, AVL Tree, Binary Search Tree (BST), Tree Multiset, Segment Tree, Binary Indexed Tree, Graph, Directed Graph, Undirected Graph, Singly Linked List, Hash, CoordinateSet, CoordinateMap, Heap, Doubly Linked List, Priority Queue, Max Priority Queue, Min Priority Queue, Queue, ObjectDeque, ArrayDeque, Stack, and Trie. Each data structure is thoughtfully designed and implemented using TypeScript to provide efficient, reliable, and easy-to-use solutions for your programming needs. Whether you're optimizing algorithms, managing data, or enhancing performance, our TypeScript Data Structure Library is your go-to resource. Elevate your coding experience with these fundamental building blocks for software development.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "rm -rf dist && npx tsc",
|
|
@@ -63,5 +63,9 @@
|
|
|
63
63
|
"ts-jest": "^29.1.1",
|
|
64
64
|
"typedoc": "^0.24.8",
|
|
65
65
|
"typescript": "^4.9.5"
|
|
66
|
+
},
|
|
67
|
+
"dependencies": {
|
|
68
|
+
"bst-typed": "^1.19.0",
|
|
69
|
+
"zod": "^3.22.2"
|
|
66
70
|
}
|
|
67
71
|
}
|
package/tsconfig.json
CHANGED
|
@@ -37,20 +37,3 @@
|
|
|
37
37
|
]
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
//{
|
|
42
|
-
// "compilerOptions": {
|
|
43
|
-
// "declaration": true,
|
|
44
|
-
// "outDir": "./dist",
|
|
45
|
-
// "module": "commonjs",
|
|
46
|
-
// "target": "es5",
|
|
47
|
-
// "lib": ["es6", "dom"],
|
|
48
|
-
// "strict": true,
|
|
49
|
-
// "esModuleInterop": true,
|
|
50
|
-
// "moduleResolution": "node",
|
|
51
|
-
// "declarationDir": "./dist/types",
|
|
52
|
-
// "skipLibCheck": true
|
|
53
|
-
// },
|
|
54
|
-
// "include": ["src"],
|
|
55
|
-
// "exclude": ["node_modules", "dist"]
|
|
56
|
-
//}
|