-
-
Notifications
You must be signed in to change notification settings - Fork 6
TS => MJS. Iteration 4 #1456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
TS => MJS. Iteration 4 #1456
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6a54cfc
compare
sergey-shandar 0d28a42
CHANGELOG: fjs/types/function/compare TS => MJS
sergey-shandar 37d8f1f
fjs\types\function\operator\module.f.mjs
sergey-shandar 9076ca8
changelog
sergey-shandar d002dc1
Fix stale .f.ts doc references and record the sweep as a task
sergey-shandar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| /** | ||
| * Comparison function types and helpers. | ||
| * | ||
| * @module | ||
| */ | ||
| /** @import { Index, Tuple } from '../../array/module.f.mjs' */ | ||
|
|
||
| /** @typedef {-1 | 0 | 1} Sign */ | ||
|
|
||
| /** | ||
| * @template T | ||
| * @typedef {(_: T) => Sign} Compare | ||
| */ | ||
|
|
||
| /** | ||
| * @template T | ||
| * @typedef {(a: T) => Compare<T>} Cmp | ||
| */ | ||
|
|
||
| /** @type {<T>(cmp: Compare<T>) => (value: T) => Index<3>} */ | ||
| export const index3 | ||
| = cmp => value => /** @type {Index<3>} */(cmp(value) + 1) | ||
|
|
||
| /** @type {<T>(cmp: Compare<T>) => (v2: Tuple<2, T>) => Index<5>} */ | ||
| export const index5 = cmp => ([v0, v1]) => { | ||
| const _0 = cmp(v0) | ||
| return /** @type {Index<5>} */(_0 <= 0 ? _0 + 1 : cmp(v1) + 3) | ||
| } | ||
|
|
||
| /** @typedef {boolean | string | number | bigint} Cmp1 */ | ||
|
|
||
| /** | ||
| * @template A | ||
| * @template B | ||
| * @typedef {[A, B] extends [boolean, boolean] ? boolean : | ||
| * [A, B] extends [string, string] ? string : | ||
| * [A, B] extends [number, number] ? number : | ||
| * [A, B] extends [bigint, bigint] ? bigint : | ||
| * never | ||
| * } Cmp2 | ||
| */ | ||
|
|
||
| /** @type {<A extends Cmp1>(a: A) => <B extends Cmp2<A, B>>(b: B) => Sign} */ | ||
| export const cmp = a => b => | ||
| /** @type {any} */(a) < b ? -1 : /** @type {any} */(a) > b ? 1 : 0 | ||
|
|
||
| /** | ||
| * Returns the smaller of two comparable values. The `Cmp2<A, B>` constraint | ||
| * is the same one `cmp` uses: it rejects calls that mix incompatible primitive | ||
| * types (e.g. `min(1)("a")`) at compile time. | ||
| * | ||
| * @type {<A extends Cmp1>(a: A) => <B extends Cmp2<A, B>>(b: B) => A | B} | ||
| */ | ||
| export const min = a => b => cmp(a)(b) < 0 ? a : b | ||
|
|
||
| /** | ||
| * Returns the larger of two comparable values. The `Cmp2<A, B>` constraint | ||
| * is the same one `cmp` uses: it rejects calls that mix incompatible primitive | ||
| * types (e.g. `max(1)("a")`) at compile time. | ||
| * | ||
| * @type {<A extends Cmp1>(a: A) => <B extends Cmp2<A, B>>(b: B) => A | B} | ||
| */ | ||
| export const max = a => b => cmp(a)(b) > 0 ? a : b | ||
|
|
||
| /** | ||
| * Binary search over `[0, len)`. `probe(mid)` returns the sign of the search | ||
| * key relative to the element at `mid` (`-1` before, `0` at, `1` after). On a | ||
| * hit it returns the matching index; on a miss it returns the converged lower | ||
| * bound `b` (the insertion point), which may equal `len`. | ||
| * | ||
| * `probe` must be monotonic over `[0, len)`: scanning indices left to right its | ||
| * result is non-increasing — a run of `1`s, then `0`s, then `-1`s. A | ||
| * non-monotonic probe yields an undefined position. | ||
| * | ||
| * @type {(len: number) => (probe: (mid: number) => Sign) => number} | ||
| */ | ||
| export const bsearch = len => probe => { | ||
| let b = 0 | ||
| let e = len - 1 | ||
| while (true) { | ||
| if (e < b) { return b } | ||
| const mid = b + (e - b >> 1) | ||
| switch (probe(mid)) { | ||
| case -1: { | ||
| e = mid - 1 | ||
| break | ||
| } | ||
| case 0: { return mid } | ||
| case 1: { | ||
| b = mid + 1 | ||
| break | ||
| } | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After this rename, a repo-wide search still finds
todo/flow.md:241linking to the deletedfjs/types/function/operator/module.f.tsandfjs/types/function/todo/uncurry-accumulator-types.md:13directing readers to that old path. Following the canonical todo documentation now produces a broken link or points contributors at a nonexistent source file, so these references should be updated to.f.mjswith the other importers.AGENTS.md reference: AGENTS.md:L10-L11
Useful? React with 👍 / 👎.