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
type FIBONACCI< | |
C extends Byte, | |
A extends Byte = ONE_BYTE, | |
B extends Byte = ONE_BYTE | |
> = ONE_BYTE extends C | |
? A | |
: AddOne<ONE_BYTE> extends C | |
? A | |
: FIBONACCI<SubtractOne<C>, Add<A, B>, A>; |
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
type LTPartial<LHS extends Bit[], RHS extends Bit[]> = LHS extends [infer LHSU extends Bit, ...infer LHSR extends Bit[]] | |
? RHS extends [infer RHSU extends Bit, ...infer RHSR extends Bit[]] | |
? true extends BitLTB<LHSU, RHSU> | |
? true | |
: false extends BitLTB<LHSU, RHSU> | |
? false | |
: "undecided" extends BitLTB<LHSU, RHSU> | |
? LTPartial<LHSR, RHSR> | |
: false | |
: false |
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
type PartialAdd< | |
LHS extends Bit[], | |
RHS extends Bit[], | |
CF extends CarryFlag = Zero | |
> = LHS extends [...infer LHSU extends Bit[], infer LHSR extends Bit] | |
? RHS extends [...infer RHSU extends Bit[], infer RHSR extends Bit] | |
? [ | |
...PartialAdd<LHSU, RHSU, AddBitsWithCarry<LHSR, RHSR, CF>["cf"]>, | |
AddBitsWithCarry<LHSR, RHSR, CF>["value"] | |
] |
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
type PartialAddOne<T extends Bit[]> = T extends [ | |
...infer U extends Bit[], | |
infer R extends Bit | |
] | |
? R extends One | |
? [...PartialAddOne<U>, Zero] | |
: [...U, One] | |
: []; | |
type AddOne<T extends Byte> = T extends [ | |
...infer U extends Bit[], |
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
type PartialByteXOR<LHS extends Bit[], RHS extends Bit[]> = LHS extends [ | |
infer LHSU extends Bit, | |
...infer LHSR extends Bit[] | |
] | |
? RHS extends [infer RHSU extends Bit, ...infer RHSR extends Bit[]] | |
? [BitXor<LHSU, RHSU>, ...PartialByteXOR<LHSR, RHSR>] | |
: [] | |
: []; | |
type ByteXOR<LHS extends Byte, RHS extends Byte> = LHS extends [ | |
infer LHSU extends Bit, |
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
type PartialByteNot<T extends Bit[]> = T extends [ | |
infer U extends Bit, | |
...infer R extends Bit[] | |
] | |
? [BitNot<U>, ...PartialByteNot<R>] | |
: []; | |
type ByteNot<T extends Byte> = T extends [ | |
infer U extends Bit, | |
...infer R extends Bit[] | |
] |
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
type ShiftLeft<T extends Byte> = T extends [ | |
infer U extends Bit, | |
...infer R extends Bit[] | |
] | |
? [...R, Zero] | |
: never; | |
type ShiftRight<T extends Byte> = T extends [ | |
...infer U extends Bit[], | |
infer R extends Bit | |
] |
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
type BitNot<T extends Bit> = T extends Zero ? One : Zero; | |
type BitAnd<LHS extends Bit, RHS extends Bit> = LHS extends One | |
? RHS extends One | |
? One | |
: Zero | |
: Zero; | |
type BitOr<LHS extends Bit, RHS extends Bit> = LHS extends Zero | |
? RHS extends Zero | |
? Zero | |
: One |
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
type Zero = { | |
__type: 'zero', | |
} | |
type One = { | |
__type: 'one' | |
} | |
type Bit = Zero | One; |
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
import { GetSignedUrlConfig, Storage } from '@google-cloud/storage' | |
const storage = new Storage() | |
// this comes from the front end | |
const input = { | |
contentType: 'application/jpeg', | |
contentLength: 10000 // size in bytes | |
} |
NewerOlder