@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Refine Partition
2
2
 
3
- Simple refine partition implementation
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 to it new candidates for refinement.
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 '../src';
24
+ import refiner from "../src";
25
25
 
26
26
  const refineNext = refiner();
27
- refineNext(['a', 'b', 'c']);
28
- refineNext(['b', 'c', 'e']);
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
@@ -0,0 +1,8 @@
1
+ {
2
+ "version": 3,
3
+ "file": "index.d.ts",
4
+ "names": [],
5
+ "sources": [],
6
+ "sourcesContent": [],
7
+ "mappings": ""
8
+ }
@@ -1,9 +1,5 @@
1
- /**
2
- * @template T
3
- * @returns {(newPartitionCandidate?: Iterable<T>) => Iterable<Iterable<T>>}
4
- */
5
1
  export default function () {
6
- /** @type {Set<Set<T>>} */
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
- // Remove intersection elements from remaining candidate elements
12
+
17
13
  remainingElements = remainingElements.difference(intersection);
18
- // Only modify processed if partition is partially consumed
14
+
19
15
  if (intersection.size < partitionItem.size) {
20
- // Partial overlap - split partition into remainder and intersection
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
- // If intersection.size === partitionItem.size, partition is fully consumed
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 /** @type {Iterable<Iterable<T>>} */ (processed);
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.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": "./types/index.d.ts",
11
- "default": "./src/index.js"
10
+ "types": "./index.d.ts",
11
+ "default": "./index.js"
12
12
  },
13
13
  "./package.json": "./package.json"
14
14
  },
15
- "types": "./types/index.d.ts",
16
- "files": [
17
- "src",
18
- "types"
19
- ],
15
+ "types": "./index.d.ts",
20
16
  "engines": {
21
17
  "node": ">=22"
22
18
  },
@@ -1,8 +0,0 @@
1
- {
2
- "version": 3,
3
- "file": "index.d.ts",
4
- "names": [],
5
- "sources": [],
6
- "sourcesContent": [],
7
- "mappings": ""
8
- }
File without changes