Skip to content

feat(Tuples): Add Tuples.Flatten#130

Closed
airismadeupofair wants to merge 312 commits into
gvergnaud:mainfrom
airismadeupofair:feat/tuples-flatten
Closed

feat(Tuples): Add Tuples.Flatten#130
airismadeupofair wants to merge 312 commits into
gvergnaud:mainfrom
airismadeupofair:feat/tuples-flatten

Conversation

@airismadeupofair
Copy link
Copy Markdown

Hello,

Firstly thank you for this very powerful library 👍.
but i found a small limitation within the Tuples namespace
there was no flatten. so i made one.

it can handle depths way over 20. and can handle over 1000 items at once.
it can even handle spreads properly including the array of a tuple spread case.

these are some of the test cases that passed on github actions.

// hundred brackets
    type res1 = Call<Tuples.Flatten, [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[1]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[...string[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], 100>
    //   ^?
    type res2 = Call<Tuples.Flatten,[[1, 2],[[[3]]],[],[4,[5,[6,[...string[],7]]]],[[8],9],...[10, 11][]],4>;
    //   ^?

    type tes1 = Expect<Equal<res1, [1, ...string[]]>>
    
    type tes2 = Expect<Equal<res2, [1, 2, 3, 4, 5, 6, ...(string | 7 | 8 | 9 | 10 | 11)[]]>>

note:

the implementation is 94 KB. it is large but almost 84KB is generated by scripts. however this is the cost for optimisation as standard recursion for the main utilites that are used by the Flatten caused the instantiation count to explode.

gvergnaud and others added 30 commits February 14, 2023 09:57
fix(strings): fix string case and add more tests
fix(equality): improve equality for numbers and strings
feat(tuples): make sort generic
docs: add initial docusaurus sub-project
This optimization makes use of a self-memoizing cache in the string
length algorithm which allows it to run on a logarithmic time scale.
This allows us to get the length of strings that are up to 9999
characters long performantly without freezing the language server.
core: try a slightly different function encoding
gvergnaud and others added 5 commits May 28, 2026 16:58
add flatten's impl with its doc, and exports with doc
peel type didnt properly unflatten variadadic tuples with rest element at the start
@airismadeupofair airismadeupofair force-pushed the feat/tuples-flatten branch 2 times, most recently from 003c189 to 316f8c6 Compare May 28, 2026 16:11
@airismadeupofair airismadeupofair closed this by deleting the head repository May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.