gvergnaud / hotscript

A library of composable functions for the type-level! Transform your TypeScript types in any way you want using functions you already know.
3.52k stars 58 forks source link

feat: implement base64 encoding #29

Closed sno2 closed 1 year ago

sno2 commented 1 year ago

These are mostly primitive implementations for bitwise AND/OR/XOR. Proper handling still needs to be done for negative numbers but I want to work on something with these operators for only unsigned data for the moment. Also, we could do a binary search on the Pow2 with the N1/N2 to find out the needed power map with log(highest_power). It sadly iterates through all of them currently.

sno2 commented 1 year ago

Is anyone else able to look at my work? For some reason, I'm getting "this type is possibly infinite" errors. However, when you hover over the following type in the IDE, it shows the correct value:

import { Call, E } from ".";

type A = Call<E.Btoa, "Hello">;
//   ^? "SGVsbG8="
sno2 commented 1 year ago

Hmm, I think I have an idea to circumvent this, but it's going to be ugly.

sno2 commented 1 year ago

Regarding the needed optimization for the bitwise operators and finding the correct starting point on the power table. We should be able to implement a fast Log2 type that uses a precomputed table for the most common powers (e.g. 1-32). I'll work on that tomorrow.

gvergnaud commented 1 year ago

This is mindblowing. You should join our discord! https://discord.gg/kaegdW3z

perrystan1489 commented 1 year ago

It says I’m at the server limit! Do I need to leave some

Get Outlook for iOShttps://aka.ms/o0ukef


From: Gabriel Vergnaud @.> Sent: Thursday, February 16, 2023 7:31:51 AM To: gvergnaud/hotscript @.> Cc: perrystan1489 @.>; Comment @.> Subject: Re: [gvergnaud/hotscript] feat: implement base64 (PR #29)

You should join the discord: https://discord.gg/kaegdW3z

— Reply to this email directly, view it on GitHubhttps://github.com/gvergnaud/hotscript/pull/29#issuecomment-1433017357, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AYQTQ65LFNKZ2BRN3X6MCMLWXYM3PANCNFSM6AAAAAAU5RRHRY. You are receiving this because you commented.Message ID: @.***>

sno2 commented 1 year ago

Alright, this is ready for review. I did not add on the Log2 optimization I was talking about for the bitwise operators yet because I think we should be able to make a Tuples.BinarySearch implementation with sorters that would automatically do it for us.

ecyrbe commented 1 year ago

I'm closing this. It's an howesome algorithm achievement, but it's a really narrowed use case that does not fit the purpose of this library in being a collection of building blocks to create higher end algorithms.