You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains 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
Most APIs which accept binary data need to ensure that the data is not modified while they read from it. (Without loss of generality, let's only analyze ArrayBuffer instances for now.) Modifications can come about due to the API processing the data asynchronously, or due to the API processing the data on some other thread which runs in parallel to the main thread. (E.g., an OS API which reads from the provided ArrayBuffer and writes it to a file.)
On the web platform, APIs generally solve this by immediately making a copy of the incoming data. The code is essentially:
functionsomeAPI(arrayBuffer){arrayBuffer=arrayBuffer.slice();// make a copy
This file contains 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 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
I am posting this as a gist because I am too lazy to figure out my blog. TODO: move it to https://domenic.me/ one day.
A lot of specifications use the ToString() abstract operation. (What's an abstract operation?) For example, any web specification which uses Web IDL's DOMString type (i.e., its basic string type) will convert incoming values using ToString(). Similarly, various parts of the JS specification itself perform ToString(). One example is the Error constructor, which we will refer to going forward.
If you are trying to implement or polyfill such a specification in JavaScript, how do you do it? For example, given
This file contains 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
If Type(this) is not Object, or this does not have a [[SetData]] internal slot, throw a new TypeError exception.
If Type(arg) is not Object, or arg does not have a [[SetData]] internal slot, throw a new TypeError exception.
Let diffList be a List containing all elements that are in this.[[SetData]] but are not in arg.[[SetData]], using SameValueZero to determine identity. (Optional: formalize this with a loop that operates on the Lists.)
Let newSet be ? OrdinaryCreateFromConstructor(%Set%, "%SetPrototype%", « [[SetData]] »).
All [external resource links] have an algorithm to fetch and process the linked resource.
Individual link types may define their own [fetch and process the linked resource] algorithm, which takes the link element el. But if not otherwise stated, they use the following default fetch and process the linked resource algorithm, given el:
If el's href attribute's value...
... stuff ...
Fetch request. To process response given the response response: