@slimlib/refine-partition 2.0.0 → 2.0.2
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 +6 -6
- package/index.d.ts.map +8 -0
- package/{src/index.js → index.js} +6 -12
- package/package.json +4 -8
- package/types/index.d.ts.map +0 -8
- /package/{types/index.d.ts → index.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Refine Partition
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A simple partition refinement implementation.
|
|
4
4
|
|
|
5
5
|
https://en.wikipedia.org/wiki/Partition_refinement
|
|
6
6
|
|
|
@@ -14,18 +14,18 @@ https://en.wikipedia.org/wiki/Partition_refinement
|
|
|
14
14
|
|
|
15
15
|
Creates a refiner function.
|
|
16
16
|
|
|
17
|
-
Pass
|
|
17
|
+
Pass new candidates for refinement to it.
|
|
18
18
|
|
|
19
|
-
Returns refined partition.
|
|
19
|
+
Returns the refined partition.
|
|
20
20
|
|
|
21
21
|
### Example
|
|
22
22
|
|
|
23
23
|
```typescript
|
|
24
|
-
import refiner from
|
|
24
|
+
import refiner from "../src";
|
|
25
25
|
|
|
26
26
|
const refineNext = refiner();
|
|
27
|
-
refineNext([
|
|
28
|
-
refineNext([
|
|
27
|
+
refineNext(["a", "b", "c"]);
|
|
28
|
+
refineNext(["b", "c", "e"]);
|
|
29
29
|
console.log(refineNext()); // Iterable of Iterables: ((a), (b, c), (e))
|
|
30
30
|
```
|
|
31
31
|
|
package/index.d.ts.map
ADDED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @template T
|
|
3
|
-
* @returns {(newPartitionCandidate?: Iterable<T>) => Iterable<Iterable<T>>}
|
|
4
|
-
*/
|
|
5
1
|
export default function () {
|
|
6
|
-
|
|
2
|
+
|
|
7
3
|
const processed = new Set();
|
|
8
4
|
|
|
9
5
|
return newPartitionCandidate => {
|
|
@@ -13,26 +9,24 @@ export default function () {
|
|
|
13
9
|
for (const partitionItem of [...processed]) {
|
|
14
10
|
const intersection = partitionItem.intersection(remainingElements);
|
|
15
11
|
if (intersection.size > 0) {
|
|
16
|
-
|
|
12
|
+
|
|
17
13
|
remainingElements = remainingElements.difference(intersection);
|
|
18
|
-
|
|
14
|
+
|
|
19
15
|
if (intersection.size < partitionItem.size) {
|
|
20
|
-
|
|
16
|
+
|
|
21
17
|
processed.delete(partitionItem);
|
|
22
18
|
const remainder = partitionItem.difference(intersection);
|
|
23
19
|
processed.add(remainder);
|
|
24
20
|
processed.add(intersection);
|
|
25
21
|
}
|
|
26
|
-
|
|
27
|
-
// No need to delete/add since partitionItem already contains all intersection elements
|
|
22
|
+
|
|
28
23
|
}
|
|
29
24
|
}
|
|
30
25
|
|
|
31
|
-
// Add elements that didn't intersect with any existing partition
|
|
32
26
|
if (remainingElements.size > 0) {
|
|
33
27
|
processed.add(remainingElements);
|
|
34
28
|
}
|
|
35
29
|
}
|
|
36
|
-
return
|
|
30
|
+
return (processed);
|
|
37
31
|
};
|
|
38
32
|
}
|
package/package.json
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"name": "@slimlib/refine-partition",
|
|
5
5
|
"description": "Simple refine partition implementation",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Konstantin Shutkin",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"types": "./
|
|
11
|
-
"default": "./
|
|
10
|
+
"types": "./index.d.ts",
|
|
11
|
+
"default": "./index.js"
|
|
12
12
|
},
|
|
13
13
|
"./package.json": "./package.json"
|
|
14
14
|
},
|
|
15
|
-
"types": "./
|
|
16
|
-
"files": [
|
|
17
|
-
"src",
|
|
18
|
-
"types"
|
|
19
|
-
],
|
|
15
|
+
"types": "./index.d.ts",
|
|
20
16
|
"engines": {
|
|
21
17
|
"node": ">=22"
|
|
22
18
|
},
|
package/types/index.d.ts.map
DELETED
|
File without changes
|