@monstermann/set 0.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.
- package/LICENSE +21 -0
- package/README.md +9 -0
- package/dist/Set/add.d.ts +28 -0
- package/dist/Set/add.js +32 -0
- package/dist/Set/addAll.d.ts +28 -0
- package/dist/Set/addAll.js +35 -0
- package/dist/Set/addOr.d.ts +26 -0
- package/dist/Set/addOr.js +32 -0
- package/dist/Set/addOrElse.d.ts +33 -0
- package/dist/Set/addOrElse.js +39 -0
- package/dist/Set/addOrThrow.d.ts +26 -0
- package/dist/Set/addOrThrow.js +32 -0
- package/dist/Set/clone.d.ts +26 -0
- package/dist/Set/clone.js +27 -0
- package/dist/Set/compact.d.ts +31 -0
- package/dist/Set/compact.js +33 -0
- package/dist/Set/difference.d.ts +26 -0
- package/dist/Set/difference.js +37 -0
- package/dist/Set/forEach.d.ts +29 -0
- package/dist/Set/forEach.js +30 -0
- package/dist/Set/has.d.ts +26 -0
- package/dist/Set/has.js +28 -0
- package/dist/Set/hasAll.d.ts +26 -0
- package/dist/Set/hasAll.js +29 -0
- package/dist/Set/hasAny.d.ts +26 -0
- package/dist/Set/hasAny.js +29 -0
- package/dist/Set/hasNone.d.ts +26 -0
- package/dist/Set/hasNone.js +29 -0
- package/dist/Set/index.d.ts +38 -0
- package/dist/Set/index.js +67 -0
- package/dist/Set/internals/types.d.ts +4 -0
- package/dist/Set/intersection.d.ts +26 -0
- package/dist/Set/intersection.js +38 -0
- package/dist/Set/isDisjointFrom.d.ts +26 -0
- package/dist/Set/isDisjointFrom.js +29 -0
- package/dist/Set/isEmpty.d.ts +26 -0
- package/dist/Set/isEmpty.js +28 -0
- package/dist/Set/isSet.d.ts +28 -0
- package/dist/Set/isSet.js +30 -0
- package/dist/Set/isShallowEqual.d.ts +26 -0
- package/dist/Set/isShallowEqual.js +31 -0
- package/dist/Set/isSubsetOf.d.ts +26 -0
- package/dist/Set/isSubsetOf.js +30 -0
- package/dist/Set/isSupersetOf.d.ts +26 -0
- package/dist/Set/isSupersetOf.js +30 -0
- package/dist/Set/mapEach.d.ts +35 -0
- package/dist/Set/mapEach.js +42 -0
- package/dist/Set/remove.d.ts +28 -0
- package/dist/Set/remove.js +32 -0
- package/dist/Set/removeAll.d.ts +28 -0
- package/dist/Set/removeAll.js +35 -0
- package/dist/Set/removeOr.d.ts +26 -0
- package/dist/Set/removeOr.js +32 -0
- package/dist/Set/removeOrElse.d.ts +33 -0
- package/dist/Set/removeOrElse.js +39 -0
- package/dist/Set/removeOrThrow.d.ts +26 -0
- package/dist/Set/removeOrThrow.js +32 -0
- package/dist/Set/size.d.ts +26 -0
- package/dist/Set/size.js +28 -0
- package/dist/Set/symmetricDifference.d.ts +26 -0
- package/dist/Set/symmetricDifference.js +45 -0
- package/dist/Set/toArray.d.ts +26 -0
- package/dist/Set/toArray.js +28 -0
- package/dist/Set/union.d.ts +26 -0
- package/dist/Set/union.js +36 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/package.json +38 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { dfdlT } from "@monstermann/dfdl";
|
|
2
|
+
|
|
3
|
+
//#region src/Set/hasAll.ts
|
|
4
|
+
/**
|
|
5
|
+
* ```ts
|
|
6
|
+
* function Set.hasAll(target, values)
|
|
7
|
+
* ```
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { Set } from "@monstermann/set";
|
|
11
|
+
*
|
|
12
|
+
* Set.hasAll(Set.create([1, 2, 3]), [1, 2]); // true
|
|
13
|
+
* Set.hasAll(Set.create([1, 2, 3]), [1, 4]); // false
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { Set } from "@monstermann/set";
|
|
18
|
+
*
|
|
19
|
+
* pipe(Set.create([1, 2, 3]), Set.hasAll([1, 2])); // true
|
|
20
|
+
* pipe(Set.create([1, 2, 3]), Set.hasAll([1, 4])); // false
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
const hasAll = dfdlT((target, values) => {
|
|
24
|
+
for (const value of values) if (!target.has(value)) return false;
|
|
25
|
+
return true;
|
|
26
|
+
}, 2);
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { hasAll };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/Set/hasAny.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* ```ts
|
|
4
|
+
* function Set.hasAny(target, values)
|
|
5
|
+
* ```
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { Set } from "@monstermann/set";
|
|
9
|
+
*
|
|
10
|
+
* Set.hasAny(Set.create([1, 2, 3]), [3, 4]); // true
|
|
11
|
+
* Set.hasAny(Set.create([1, 2, 3]), [4, 5]); // false
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { Set } from "@monstermann/set";
|
|
16
|
+
*
|
|
17
|
+
* pipe(Set.create([1, 2, 3]), Set.hasAny([3, 4])); // true
|
|
18
|
+
* pipe(Set.create([1, 2, 3]), Set.hasAny([4, 5])); // false
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare const hasAny: {
|
|
22
|
+
<T>(values: Iterable<NoInfer<T>>): (target: ReadonlySet<T>) => boolean;
|
|
23
|
+
<T>(target: ReadonlySet<T>, values: Iterable<NoInfer<T>>): boolean;
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { hasAny };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { dfdlT } from "@monstermann/dfdl";
|
|
2
|
+
|
|
3
|
+
//#region src/Set/hasAny.ts
|
|
4
|
+
/**
|
|
5
|
+
* ```ts
|
|
6
|
+
* function Set.hasAny(target, values)
|
|
7
|
+
* ```
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { Set } from "@monstermann/set";
|
|
11
|
+
*
|
|
12
|
+
* Set.hasAny(Set.create([1, 2, 3]), [3, 4]); // true
|
|
13
|
+
* Set.hasAny(Set.create([1, 2, 3]), [4, 5]); // false
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { Set } from "@monstermann/set";
|
|
18
|
+
*
|
|
19
|
+
* pipe(Set.create([1, 2, 3]), Set.hasAny([3, 4])); // true
|
|
20
|
+
* pipe(Set.create([1, 2, 3]), Set.hasAny([4, 5])); // false
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
const hasAny = dfdlT((target, values) => {
|
|
24
|
+
for (const value of values) if (target.has(value)) return true;
|
|
25
|
+
return false;
|
|
26
|
+
}, 2);
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { hasAny };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/Set/hasNone.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* ```ts
|
|
4
|
+
* function Set.hasNone(target, values)
|
|
5
|
+
* ```
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { Set } from "@monstermann/set";
|
|
9
|
+
*
|
|
10
|
+
* Set.hasNone(Set.create([1, 2, 3]), [4, 5]); // true
|
|
11
|
+
* Set.hasNone(Set.create([1, 2, 3]), [3, 4]); // false
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { Set } from "@monstermann/set";
|
|
16
|
+
*
|
|
17
|
+
* pipe(Set.create([1, 2, 3]), Set.hasNone([4, 5])); // true
|
|
18
|
+
* pipe(Set.create([1, 2, 3]), Set.hasNone([3, 4])); // false
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare const hasNone: {
|
|
22
|
+
<T>(values: Iterable<NoInfer<T>>): (target: ReadonlySet<T>) => boolean;
|
|
23
|
+
<T>(target: ReadonlySet<T>, values: Iterable<NoInfer<T>>): boolean;
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { hasNone };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { dfdlT } from "@monstermann/dfdl";
|
|
2
|
+
|
|
3
|
+
//#region src/Set/hasNone.ts
|
|
4
|
+
/**
|
|
5
|
+
* ```ts
|
|
6
|
+
* function Set.hasNone(target, values)
|
|
7
|
+
* ```
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { Set } from "@monstermann/set";
|
|
11
|
+
*
|
|
12
|
+
* Set.hasNone(Set.create([1, 2, 3]), [4, 5]); // true
|
|
13
|
+
* Set.hasNone(Set.create([1, 2, 3]), [3, 4]); // false
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { Set } from "@monstermann/set";
|
|
18
|
+
*
|
|
19
|
+
* pipe(Set.create([1, 2, 3]), Set.hasNone([4, 5])); // true
|
|
20
|
+
* pipe(Set.create([1, 2, 3]), Set.hasNone([3, 4])); // false
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
const hasNone = dfdlT((target, values) => {
|
|
24
|
+
for (const value of values) if (target.has(value)) return false;
|
|
25
|
+
return true;
|
|
26
|
+
}, 2);
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { hasNone };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { add } from "./add.js";
|
|
2
|
+
import { addAll } from "./addAll.js";
|
|
3
|
+
import { addOr } from "./addOr.js";
|
|
4
|
+
import { addOrElse } from "./addOrElse.js";
|
|
5
|
+
import { addOrThrow } from "./addOrThrow.js";
|
|
6
|
+
import { clone } from "./clone.js";
|
|
7
|
+
import { compact } from "./compact.js";
|
|
8
|
+
import { difference } from "./difference.js";
|
|
9
|
+
import { forEach } from "./forEach.js";
|
|
10
|
+
import { has } from "./has.js";
|
|
11
|
+
import { hasAll } from "./hasAll.js";
|
|
12
|
+
import { hasAny } from "./hasAny.js";
|
|
13
|
+
import { hasNone } from "./hasNone.js";
|
|
14
|
+
import { intersection } from "./intersection.js";
|
|
15
|
+
import { isDisjointFrom } from "./isDisjointFrom.js";
|
|
16
|
+
import { isEmpty } from "./isEmpty.js";
|
|
17
|
+
import { isSet } from "./isSet.js";
|
|
18
|
+
import { isShallowEqual } from "./isShallowEqual.js";
|
|
19
|
+
import { isSubsetOf } from "./isSubsetOf.js";
|
|
20
|
+
import { isSupersetOf } from "./isSupersetOf.js";
|
|
21
|
+
import { mapEach } from "./mapEach.js";
|
|
22
|
+
import { remove } from "./remove.js";
|
|
23
|
+
import { removeAll } from "./removeAll.js";
|
|
24
|
+
import { removeOr } from "./removeOr.js";
|
|
25
|
+
import { removeOrElse } from "./removeOrElse.js";
|
|
26
|
+
import { removeOrThrow } from "./removeOrThrow.js";
|
|
27
|
+
import { size } from "./size.js";
|
|
28
|
+
import { symmetricDifference } from "./symmetricDifference.js";
|
|
29
|
+
import { toArray } from "./toArray.js";
|
|
30
|
+
import { union } from "./union.js";
|
|
31
|
+
|
|
32
|
+
//#region src/Set/index.d.ts
|
|
33
|
+
|
|
34
|
+
declare namespace Set {
|
|
35
|
+
export { add, addAll, addOr, addOrElse, addOrThrow, clone, compact, difference, forEach, has, hasAll, hasAny, hasNone, intersection, isDisjointFrom, isEmpty, isSet, isShallowEqual, isSubsetOf, isSupersetOf, mapEach, remove, removeAll, removeOr, removeOrElse, removeOrThrow, size, symmetricDifference, toArray, union };
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { Set };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { add } from "./add.js";
|
|
2
|
+
import { addAll } from "./addAll.js";
|
|
3
|
+
import { addOr } from "./addOr.js";
|
|
4
|
+
import { addOrElse } from "./addOrElse.js";
|
|
5
|
+
import { addOrThrow } from "./addOrThrow.js";
|
|
6
|
+
import { clone } from "./clone.js";
|
|
7
|
+
import { compact } from "./compact.js";
|
|
8
|
+
import { difference } from "./difference.js";
|
|
9
|
+
import { forEach } from "./forEach.js";
|
|
10
|
+
import { has } from "./has.js";
|
|
11
|
+
import { hasAll } from "./hasAll.js";
|
|
12
|
+
import { hasAny } from "./hasAny.js";
|
|
13
|
+
import { hasNone } from "./hasNone.js";
|
|
14
|
+
import { intersection } from "./intersection.js";
|
|
15
|
+
import { isDisjointFrom } from "./isDisjointFrom.js";
|
|
16
|
+
import { isEmpty } from "./isEmpty.js";
|
|
17
|
+
import { isSet } from "./isSet.js";
|
|
18
|
+
import { isShallowEqual } from "./isShallowEqual.js";
|
|
19
|
+
import { isSubsetOf } from "./isSubsetOf.js";
|
|
20
|
+
import { isSupersetOf } from "./isSupersetOf.js";
|
|
21
|
+
import { mapEach } from "./mapEach.js";
|
|
22
|
+
import { remove } from "./remove.js";
|
|
23
|
+
import { removeAll } from "./removeAll.js";
|
|
24
|
+
import { removeOr } from "./removeOr.js";
|
|
25
|
+
import { removeOrElse } from "./removeOrElse.js";
|
|
26
|
+
import { removeOrThrow } from "./removeOrThrow.js";
|
|
27
|
+
import { size } from "./size.js";
|
|
28
|
+
import { symmetricDifference } from "./symmetricDifference.js";
|
|
29
|
+
import { toArray } from "./toArray.js";
|
|
30
|
+
import { union } from "./union.js";
|
|
31
|
+
|
|
32
|
+
//#region src/Set/index.js
|
|
33
|
+
const Set = {
|
|
34
|
+
add,
|
|
35
|
+
addAll,
|
|
36
|
+
addOr,
|
|
37
|
+
addOrElse,
|
|
38
|
+
addOrThrow,
|
|
39
|
+
clone,
|
|
40
|
+
compact,
|
|
41
|
+
difference,
|
|
42
|
+
forEach,
|
|
43
|
+
has,
|
|
44
|
+
hasAll,
|
|
45
|
+
hasAny,
|
|
46
|
+
hasNone,
|
|
47
|
+
intersection,
|
|
48
|
+
isDisjointFrom,
|
|
49
|
+
isEmpty,
|
|
50
|
+
isSet,
|
|
51
|
+
isShallowEqual,
|
|
52
|
+
isSubsetOf,
|
|
53
|
+
isSupersetOf,
|
|
54
|
+
mapEach,
|
|
55
|
+
remove,
|
|
56
|
+
removeAll,
|
|
57
|
+
removeOr,
|
|
58
|
+
removeOrElse,
|
|
59
|
+
removeOrThrow,
|
|
60
|
+
size,
|
|
61
|
+
symmetricDifference,
|
|
62
|
+
toArray,
|
|
63
|
+
union
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
//#endregion
|
|
67
|
+
export { Set };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/Set/intersection.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* ```ts
|
|
4
|
+
* function Set.intersection(target, source)
|
|
5
|
+
* ```
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { Set } from "@monstermann/set";
|
|
9
|
+
*
|
|
10
|
+
* Set.intersection(Set.create([1, 2, 3]), Set.create([2, 3, 4])); // Set([2, 3])
|
|
11
|
+
* Set.intersection(Set.create([1, 2]), Set.create([3, 4])); // Set([])
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { Set } from "@monstermann/set";
|
|
16
|
+
*
|
|
17
|
+
* pipe(Set.create([1, 2, 3]), Set.intersection(Set.create([2, 3, 4]))); // Set([2, 3])
|
|
18
|
+
* pipe(Set.create([1, 2]), Set.intersection(Set.create([3, 4]))); // Set([])
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare const intersection: {
|
|
22
|
+
<T, U>(source: Set<U>): (target: Set<T>) => Set<T | U>;
|
|
23
|
+
<T, U>(target: Set<T>, source: Set<U>): Set<T | U>;
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { intersection };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { dfdlT } from "@monstermann/dfdl";
|
|
2
|
+
|
|
3
|
+
//#region src/Set/intersection.ts
|
|
4
|
+
/**
|
|
5
|
+
* ```ts
|
|
6
|
+
* function Set.intersection(target, source)
|
|
7
|
+
* ```
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { Set } from "@monstermann/set";
|
|
11
|
+
*
|
|
12
|
+
* Set.intersection(Set.create([1, 2, 3]), Set.create([2, 3, 4])); // Set([2, 3])
|
|
13
|
+
* Set.intersection(Set.create([1, 2]), Set.create([3, 4])); // Set([])
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { Set } from "@monstermann/set";
|
|
18
|
+
*
|
|
19
|
+
* pipe(Set.create([1, 2, 3]), Set.intersection(Set.create([2, 3, 4]))); // Set([2, 3])
|
|
20
|
+
* pipe(Set.create([1, 2]), Set.intersection(Set.create([3, 4]))); // Set([])
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
const intersection = dfdlT((target, source) => {
|
|
24
|
+
if (target.size === 0) return target;
|
|
25
|
+
if (source.size === 0) return source;
|
|
26
|
+
for (const value of target) if (!source.has(value)) {
|
|
27
|
+
const result = /* @__PURE__ */ new Set();
|
|
28
|
+
for (const value$1 of target) {
|
|
29
|
+
if (!source.has(value$1)) continue;
|
|
30
|
+
result.add(value$1);
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
return target;
|
|
35
|
+
}, 2);
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
export { intersection };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/Set/isDisjointFrom.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* ```ts
|
|
4
|
+
* function Set.isDisjointFrom(target, source)
|
|
5
|
+
* ```
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { Set } from "@monstermann/set";
|
|
9
|
+
*
|
|
10
|
+
* Set.isDisjointFrom(Set.create([1, 2]), Set.create([3, 4])); // true
|
|
11
|
+
* Set.isDisjointFrom(Set.create([1, 2]), Set.create([2, 3])); // false
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { Set } from "@monstermann/set";
|
|
16
|
+
*
|
|
17
|
+
* pipe(Set.create([1, 2]), Set.isDisjointFrom(Set.create([3, 4]))); // true
|
|
18
|
+
* pipe(Set.create([1, 2]), Set.isDisjointFrom(Set.create([2, 3]))); // false
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare const isDisjointFrom: {
|
|
22
|
+
<T>(source: ReadonlySet<NoInfer<T>>): (target: ReadonlySet<T>) => boolean;
|
|
23
|
+
<T>(target: ReadonlySet<T>, source: ReadonlySet<NoInfer<T>>): boolean;
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { isDisjointFrom };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { dfdlT } from "@monstermann/dfdl";
|
|
2
|
+
|
|
3
|
+
//#region src/Set/isDisjointFrom.ts
|
|
4
|
+
/**
|
|
5
|
+
* ```ts
|
|
6
|
+
* function Set.isDisjointFrom(target, source)
|
|
7
|
+
* ```
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { Set } from "@monstermann/set";
|
|
11
|
+
*
|
|
12
|
+
* Set.isDisjointFrom(Set.create([1, 2]), Set.create([3, 4])); // true
|
|
13
|
+
* Set.isDisjointFrom(Set.create([1, 2]), Set.create([2, 3])); // false
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { Set } from "@monstermann/set";
|
|
18
|
+
*
|
|
19
|
+
* pipe(Set.create([1, 2]), Set.isDisjointFrom(Set.create([3, 4]))); // true
|
|
20
|
+
* pipe(Set.create([1, 2]), Set.isDisjointFrom(Set.create([2, 3]))); // false
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
const isDisjointFrom = dfdlT((target, source) => {
|
|
24
|
+
for (const value of target) if (source.has(value)) return false;
|
|
25
|
+
return true;
|
|
26
|
+
}, 2);
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { isDisjointFrom };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/Set/isEmpty.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* ```ts
|
|
4
|
+
* function Set.isEmpty(target)
|
|
5
|
+
* ```
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { Set } from "@monstermann/set";
|
|
9
|
+
*
|
|
10
|
+
* Set.isEmpty(Set.create()); // true
|
|
11
|
+
* Set.isEmpty(Set.create([1, 2, 3])); // false
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { Set } from "@monstermann/set";
|
|
16
|
+
*
|
|
17
|
+
* pipe(Set.create(), Set.isEmpty()); // true
|
|
18
|
+
* pipe(Set.create([1, 2, 3]), Set.isEmpty()); // false
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare const isEmpty: {
|
|
22
|
+
(): <T extends ReadonlySet<unknown>>(target: T) => boolean;
|
|
23
|
+
<T extends ReadonlySet<unknown>>(target: T): boolean;
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { isEmpty };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { dfdlT } from "@monstermann/dfdl";
|
|
2
|
+
|
|
3
|
+
//#region src/Set/isEmpty.ts
|
|
4
|
+
/**
|
|
5
|
+
* ```ts
|
|
6
|
+
* function Set.isEmpty(target)
|
|
7
|
+
* ```
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { Set } from "@monstermann/set";
|
|
11
|
+
*
|
|
12
|
+
* Set.isEmpty(Set.create()); // true
|
|
13
|
+
* Set.isEmpty(Set.create([1, 2, 3])); // false
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { Set } from "@monstermann/set";
|
|
18
|
+
*
|
|
19
|
+
* pipe(Set.create(), Set.isEmpty()); // true
|
|
20
|
+
* pipe(Set.create([1, 2, 3]), Set.isEmpty()); // false
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
const isEmpty = dfdlT((target) => {
|
|
24
|
+
return target.size === 0;
|
|
25
|
+
}, 1);
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { isEmpty };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/Set/isSet.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* ```ts
|
|
4
|
+
* function Set.isSet(target)
|
|
5
|
+
* ```
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { Set } from "@monstermann/set";
|
|
9
|
+
*
|
|
10
|
+
* Set.isSet(Set.create([1, 2, 3])); // true
|
|
11
|
+
* Set.isSet([1, 2, 3]); // false
|
|
12
|
+
* Set.isSet({}); // false
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { Set } from "@monstermann/set";
|
|
17
|
+
*
|
|
18
|
+
* pipe(Set.create([1, 2, 3]), Set.isSet()); // true
|
|
19
|
+
* pipe([1, 2, 3], Set.isSet()); // false
|
|
20
|
+
* pipe({}, Set.isSet()); // false
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
declare const isSet: {
|
|
24
|
+
(): (target: unknown) => target is Set<unknown>;
|
|
25
|
+
(target: unknown): target is Set<unknown>;
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
28
|
+
export { isSet };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { dfdlT } from "@monstermann/dfdl";
|
|
2
|
+
|
|
3
|
+
//#region src/Set/isSet.ts
|
|
4
|
+
/**
|
|
5
|
+
* ```ts
|
|
6
|
+
* function Set.isSet(target)
|
|
7
|
+
* ```
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { Set } from "@monstermann/set";
|
|
11
|
+
*
|
|
12
|
+
* Set.isSet(Set.create([1, 2, 3])); // true
|
|
13
|
+
* Set.isSet([1, 2, 3]); // false
|
|
14
|
+
* Set.isSet({}); // false
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { Set } from "@monstermann/set";
|
|
19
|
+
*
|
|
20
|
+
* pipe(Set.create([1, 2, 3]), Set.isSet()); // true
|
|
21
|
+
* pipe([1, 2, 3], Set.isSet()); // false
|
|
22
|
+
* pipe({}, Set.isSet()); // false
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
const isSet = dfdlT((target) => {
|
|
26
|
+
return target instanceof Set;
|
|
27
|
+
}, 1);
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { isSet };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/Set/isShallowEqual.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* ```ts
|
|
4
|
+
* function Set.isShallowEqual(target, source)
|
|
5
|
+
* ```
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { Set } from "@monstermann/set";
|
|
9
|
+
*
|
|
10
|
+
* Set.isShallowEqual(Set.create([1, 2, 3]), Set.create([3, 2, 1])); // true
|
|
11
|
+
* Set.isShallowEqual(Set.create([1, 2]), Set.create([1, 2, 3])); // false
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { Set } from "@monstermann/set";
|
|
16
|
+
*
|
|
17
|
+
* pipe(Set.create([1, 2, 3]), Set.isShallowEqual(Set.create([3, 2, 1]))); // true
|
|
18
|
+
* pipe(Set.create([1, 2]), Set.isShallowEqual(Set.create([1, 2, 3]))); // false
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare const isShallowEqual: {
|
|
22
|
+
<T>(source: ReadonlySet<NoInfer<T>>): (target: ReadonlySet<T>) => boolean;
|
|
23
|
+
<T>(target: ReadonlySet<T>, source: ReadonlySet<NoInfer<T>>): boolean;
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { isShallowEqual };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { dfdlT } from "@monstermann/dfdl";
|
|
2
|
+
|
|
3
|
+
//#region src/Set/isShallowEqual.ts
|
|
4
|
+
/**
|
|
5
|
+
* ```ts
|
|
6
|
+
* function Set.isShallowEqual(target, source)
|
|
7
|
+
* ```
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { Set } from "@monstermann/set";
|
|
11
|
+
*
|
|
12
|
+
* Set.isShallowEqual(Set.create([1, 2, 3]), Set.create([3, 2, 1])); // true
|
|
13
|
+
* Set.isShallowEqual(Set.create([1, 2]), Set.create([1, 2, 3])); // false
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { Set } from "@monstermann/set";
|
|
18
|
+
*
|
|
19
|
+
* pipe(Set.create([1, 2, 3]), Set.isShallowEqual(Set.create([3, 2, 1]))); // true
|
|
20
|
+
* pipe(Set.create([1, 2]), Set.isShallowEqual(Set.create([1, 2, 3]))); // false
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
const isShallowEqual = dfdlT((target, source) => {
|
|
24
|
+
if (target.size !== source.size) return false;
|
|
25
|
+
for (const a of target) if (!source.has(a)) return false;
|
|
26
|
+
for (const b of source) if (!target.has(b)) return false;
|
|
27
|
+
return true;
|
|
28
|
+
}, 2);
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { isShallowEqual };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/Set/isSubsetOf.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* ```ts
|
|
4
|
+
* function Set.isSubsetOf(target, source)
|
|
5
|
+
* ```
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { Set } from "@monstermann/set";
|
|
9
|
+
*
|
|
10
|
+
* Set.isSubsetOf(Set.create([1, 2]), Set.create([1, 2, 3])); // true
|
|
11
|
+
* Set.isSubsetOf(Set.create([1, 4]), Set.create([1, 2, 3])); // false
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { Set } from "@monstermann/set";
|
|
16
|
+
*
|
|
17
|
+
* pipe(Set.create([1, 2]), Set.isSubsetOf(Set.create([1, 2, 3]))); // true
|
|
18
|
+
* pipe(Set.create([1, 4]), Set.isSubsetOf(Set.create([1, 2, 3]))); // false
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare const isSubsetOf: {
|
|
22
|
+
<T>(source: ReadonlySet<NoInfer<T>>): (target: ReadonlySet<T>) => boolean;
|
|
23
|
+
<T>(target: ReadonlySet<T>, source: ReadonlySet<NoInfer<T>>): boolean;
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { isSubsetOf };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { dfdlT } from "@monstermann/dfdl";
|
|
2
|
+
|
|
3
|
+
//#region src/Set/isSubsetOf.ts
|
|
4
|
+
/**
|
|
5
|
+
* ```ts
|
|
6
|
+
* function Set.isSubsetOf(target, source)
|
|
7
|
+
* ```
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { Set } from "@monstermann/set";
|
|
11
|
+
*
|
|
12
|
+
* Set.isSubsetOf(Set.create([1, 2]), Set.create([1, 2, 3])); // true
|
|
13
|
+
* Set.isSubsetOf(Set.create([1, 4]), Set.create([1, 2, 3])); // false
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { Set } from "@monstermann/set";
|
|
18
|
+
*
|
|
19
|
+
* pipe(Set.create([1, 2]), Set.isSubsetOf(Set.create([1, 2, 3]))); // true
|
|
20
|
+
* pipe(Set.create([1, 4]), Set.isSubsetOf(Set.create([1, 2, 3]))); // false
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
const isSubsetOf = dfdlT((target, source) => {
|
|
24
|
+
if (target.size > source.size) return false;
|
|
25
|
+
for (const value of target) if (!source.has(value)) return false;
|
|
26
|
+
return true;
|
|
27
|
+
}, 2);
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { isSubsetOf };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/Set/isSupersetOf.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* ```ts
|
|
4
|
+
* function Set.isSupersetOf(target, source)
|
|
5
|
+
* ```
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { Set } from "@monstermann/set";
|
|
9
|
+
*
|
|
10
|
+
* Set.isSupersetOf(Set.create([1, 2, 3]), Set.create([1, 2])); // true
|
|
11
|
+
* Set.isSupersetOf(Set.create([1, 2, 3]), Set.create([1, 4])); // false
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { Set } from "@monstermann/set";
|
|
16
|
+
*
|
|
17
|
+
* pipe(Set.create([1, 2, 3]), Set.isSupersetOf(Set.create([1, 2]))); // true
|
|
18
|
+
* pipe(Set.create([1, 2, 3]), Set.isSupersetOf(Set.create([1, 4]))); // false
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare const isSupersetOf: {
|
|
22
|
+
<T>(source: ReadonlySet<NoInfer<T>>): (target: ReadonlySet<T>) => boolean;
|
|
23
|
+
<T>(target: ReadonlySet<T>, source: ReadonlySet<NoInfer<T>>): boolean;
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { isSupersetOf };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { dfdlT } from "@monstermann/dfdl";
|
|
2
|
+
|
|
3
|
+
//#region src/Set/isSupersetOf.ts
|
|
4
|
+
/**
|
|
5
|
+
* ```ts
|
|
6
|
+
* function Set.isSupersetOf(target, source)
|
|
7
|
+
* ```
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { Set } from "@monstermann/set";
|
|
11
|
+
*
|
|
12
|
+
* Set.isSupersetOf(Set.create([1, 2, 3]), Set.create([1, 2])); // true
|
|
13
|
+
* Set.isSupersetOf(Set.create([1, 2, 3]), Set.create([1, 4])); // false
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { Set } from "@monstermann/set";
|
|
18
|
+
*
|
|
19
|
+
* pipe(Set.create([1, 2, 3]), Set.isSupersetOf(Set.create([1, 2]))); // true
|
|
20
|
+
* pipe(Set.create([1, 2, 3]), Set.isSupersetOf(Set.create([1, 4]))); // false
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
const isSupersetOf = dfdlT((target, source) => {
|
|
24
|
+
if (target.size < source.size) return false;
|
|
25
|
+
for (const value of source) if (!target.has(value)) return false;
|
|
26
|
+
return true;
|
|
27
|
+
}, 2);
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { isSupersetOf };
|