Skip to content

Commit 3e3cf72

Browse files
committed
docs(patterns): Update containerHasSplit for docs.endojs.org
1 parent d309dc1 commit 3e3cf72

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

packages/patterns/src/patterns/patternMatchers.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,16 +1413,28 @@ const makePatternKit = () => {
14131413
};
14141414

14151415
/**
1416+
* Confirms that `specimen` contains at least `bound` instances of an element
1417+
* matched by `elementPatt`, optionally returning those bounded matches and/or
1418+
* their complement as specified by `needInResults` and `needOutResults`
1419+
* (ensuring for CopyBags that at most one Key is split across both, but
1420+
* otherwise making no guarantee regarding the order in which elements are
1421+
* considered beyond a best-effort attempt to align with intuition).
1422+
* If the specimen does not contain enough matching instances, this function
1423+
* terminates as directed by `reject` (i.e., either returning `false` or
1424+
* throwing an exception).
1425+
*
14161426
* @typedef {CopyArray | CopySet | CopyBag} Container
14171427
* @param {Container} specimen
14181428
* @param {Pattern} elementPatt
14191429
* @param {bigint} bound Must be >= 1n
14201430
* @param {Rejector} reject
1421-
* @param {boolean} [needInResults]
1422-
* @param {boolean} [needOutResults]
1423-
* @returns {[Container | undefined, Container | undefined] | false}
1431+
* @param {boolean} [needInResults] collect and return matches inside a
1432+
* container of the same shape as `specimen`
1433+
* @param {boolean} [needOutResults] collect and return rejects inside a
1434+
* container of the same shape as `specimen`
1435+
* @returns {[matches: Container | undefined, discards: Container | undefined] | false}
14241436
*/
1425-
const confirmContainerHasSplit = (
1437+
const containerHasSplit = (
14261438
specimen,
14271439
elementPatt,
14281440
bound,
@@ -1507,14 +1519,7 @@ const makePatternKit = () => {
15071519
) {
15081520
return false;
15091521
}
1510-
return !!confirmContainerHasSplit(
1511-
specimen,
1512-
elementPatt,
1513-
bound,
1514-
reject,
1515-
false,
1516-
false,
1517-
);
1522+
return !!containerHasSplit(specimen, elementPatt, bound, reject);
15181523
},
15191524

15201525
confirmIsWellFormed: (payload, reject) =>
@@ -2048,7 +2053,7 @@ const makePatternKit = () => {
20482053
getRankCover,
20492054
M,
20502055
kindOf,
2051-
containerHasSplit: confirmContainerHasSplit,
2056+
containerHasSplit,
20522057
});
20532058
};
20542059

0 commit comments

Comments
 (0)