Conversation
MathieuPOUX reviewed Apr 8, 2025
| error = await response.text(); | ||
| } | ||
| throw (error || response.statusText || response.status).toString(); | ||
| const response = await globalThis.fetch(input, init); |
Collaborator
There was a problem hiding this comment.
Contributor Author
There was a problem hiding this comment.
@MathieuPOUX We can simply include a polyfill during the build, there's no need for us to maintain support for older browsers manually ourselves :)
Contributor Author
There was a problem hiding this comment.
I can add it to this PR!
Contributor Author
There was a problem hiding this comment.
Also it'll simplify some stuff like trimStart trimEnd
MathieuPOUX reviewed Apr 10, 2025
a8e9a91 to eb61d4c Compare …ed by stricter settings
Contributor Author
| closing this PR and leaving it as a reference for cherry-picking. |
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Changes:
General:
==,!=).lengthandcharAt/ index access, as this will not work for characters outside the BMP, because they are represented by two code units (JavaScript strings are UCS-2), use String iterator instead.any.Stuff we should remove:
FixMap(tested): while the helpers save two lines of code, they add complexity of abstraction, and make the code unfamiliar to new developers.BinaryWriter: It ignores offset and length if provided with a binary array, has a capacity doesn't handle overflow, the behavior isn't well defined, Can't we just useDataViewand native binary arrays?iterableEntriesWe can use a polyfill instead (I'll do this in another PR)!Queues:
Numbers:
NaNinternally but we return 0 to keep the behavior (I think we should returnNaNorinfinity/-infinity).BitReader.ts
BitRate:
Utils.ts:
Bug fixes:
fetch: always useawait text()to get the response body, to make sure the block is consistent (always async).timeOrigin: Correctly calculate and hold the time origin, instead of returing a new value every time!Improvements:
Fetch: use globalThis.fetch instead of self.fetch.Fetch: Check for response.ok instead ofresponse.status >= 300to better communicate the intent of resolving ready responses.Fetch: throw Error instead of strings.Major Refactor:
equal: Reworked the function to fix some issues and improve readability:NaNwas not compared correctly.lengthandSymbol.iteratoron the same time.sameValueZeroalgorithmhttps://tc39.es/ecma262/multipage/abstract-operations.html#sec-samevaluenonnumber
safePromise:ReturnType<typeof setTimeout>instead ofNodeJS.Timeout.Promise<T>to the function signature to make it more explicit.asyncto make it easier to read.trim,trimStart,trimEnd:String.prototype.trim,String.prototype.trimStart,String.prototype.trimEndIf available, and if no custom characters are provided.whitespacecharacters andline terminatorsby default instead of just ASCII characters (0x20) to match the behavior ofString.prototype.trim.Logs
future planning: