-
Notifications
You must be signed in to change notification settings - Fork 13k
Add type definitions for Uint8Array
to/from base64 methods
#61696
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
Changes from 17 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
2471626
Add type definitions for `Uint8Array` to/from base64 methods
dontwanttothink 09db85c
Update baselines
dontwanttothink d5f1e1c
Update script target features
dontwanttothink f720939
Add tests
dontwanttothink ed6539c
Fix typo
dontwanttothink 3f18d3c
Use method definitions and narrow down type
dontwanttothink a5df42d
Update baselines
dontwanttothink 7289362
Merge branch 'main' into main
dontwanttothink 5e714bc
Merge branch 'main' into main
dontwanttothink f4aff51
Merge branch 'microsoft:main' into main
dontwanttothink 8b057c9
Move into `esnext.typedarrays.d.ts`
dontwanttothink fb157d2
Update baselines
dontwanttothink 44b7036
Fix line endings
dontwanttothink f28291d
Allow passing `undefined` wherever appropriate
dontwanttothink 9e959c6
Update baselines
dontwanttothink 70bdae0
Update tests to contemplate setting options to 'undefined'
dontwanttothink 29409fa
Again, update baselines
dontwanttothink ea58c9b
Remove redundant `undefined`s
dontwanttothink 621e973
Again, again update baselines
dontwanttothink 5176640
Remove the test
dontwanttothink b24705d
Update baselines
dontwanttothink 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
interface Uint8Array<TArrayBuffer extends ArrayBufferLike> { | ||
/** | ||
* Converts the `Uint8Array` to a base64-encoded string. | ||
* @param options If provided, sets the alphabet and padding behavior used. | ||
* @returns A base64-encoded string. | ||
*/ | ||
toBase64( | ||
options?: { | ||
alphabet?: "base64" | "base64url" | undefined; | ||
omitPadding?: boolean | undefined; | ||
} | undefined, | ||
): string; | ||
|
||
/** | ||
* Sets the `Uint8Array` from a base64-encoded string. | ||
* @param string The base64-encoded string. | ||
* @param options If provided, specifies the alphabet and handling of the last chunk. | ||
* @returns An object containing the number of bytes read and written. | ||
* @throws {SyntaxError} If the input string contains characters outside the specified alphabet, or if the last | ||
* chunk is inconsistent with the `lastChunkHandling` option. | ||
*/ | ||
setFromBase64( | ||
string: string, | ||
options?: { | ||
alphabet?: "base64" | "base64url" | undefined; | ||
lastChunkHandling?: "loose" | "strict" | "stop-before-partial" | undefined; | ||
} | undefined, | ||
): { | ||
read: number; | ||
written: number; | ||
}; | ||
|
||
/** | ||
* Converts the `Uint8Array` to a base16-encoded string. | ||
* @returns A base16-encoded string. | ||
*/ | ||
toHex(): string; | ||
|
||
/** | ||
* Sets the `Uint8Array` from a base16-encoded string. | ||
* @param string The base16-encoded string. | ||
* @returns An object containing the number of bytes read and written. | ||
*/ | ||
setFromHex(string: string): { | ||
read: number; | ||
written: number; | ||
}; | ||
} | ||
|
||
interface Uint8ArrayConstructor { | ||
/** | ||
* Creates a new `Uint8Array` from a base64-encoded string. | ||
* @param string The base64-encoded string. | ||
* @param options If provided, specifies the alphabet and handling of the last chunk. | ||
* @returns A new `Uint8Array` instance. | ||
* @throws {SyntaxError} If the input string contains characters outside the specified alphabet, or if the last | ||
* chunk is inconsistent with the `lastChunkHandling` option. | ||
*/ | ||
fromBase64( | ||
string: string, | ||
options?: { | ||
alphabet?: "base64" | "base64url" | undefined; | ||
lastChunkHandling?: "loose" | "strict" | "stop-before-partial" | undefined; | ||
} | undefined, | ||
): Uint8Array<ArrayBuffer>; | ||
|
||
/** | ||
* Creates a new `Uint8Array` from a base16-encoded string. | ||
* @returns A new `Uint8Array` instance. | ||
*/ | ||
fromHex( | ||
string: string, | ||
): Uint8Array<ArrayBuffer>; | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...ference/config/commandLineParsing/parseCommandLine/Parse --lib option with extra comma.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...onfig/commandLineParsing/parseCommandLine/Parse --lib option with trailing white-space.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...rence/config/commandLineParsing/parseCommandLine/Parse invalid option of library flags.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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.
Uh oh!
There was an error while loading. Please reload this page.