Skip to content

Instantly share code, notes, and snippets.

View jimmywarting's full-sized avatar

Jimmy Wärting jimmywarting

View GitHub Profile
@MattiasBuelens
MattiasBuelens / readable-stream-async-iterator-polyfill.js
Created September 1, 2023 09:17
ReadableStream async iterator polyfill
/**
* A polyfill for `ReadableStream.protototype[Symbol.asyncIterator]`,
* aligning as closely as possible to the specification.
*
* @see https://streams.spec.whatwg.org/#rs-asynciterator
* @see https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream#async_iteration
*/
ReadableStream.prototype.values ??= function({ preventCancel = false } = {}) {
const reader = this.getReader();
return {
@jimmywarting
jimmywarting / custom json replacer reviver.md
Last active August 15, 2022 10:25
Custom json replacer/reviver with extended support

This custom json replacer/reviver allow you to store more types as json and still keep it as valid json.

features

  • Allow you to stringify/parse
    • BigInt
    • Infinity
    • NaN
    • Date
    • typed arrays & ArrayBuffers as web-safe base64

Why I hate TypeScript

Warning: These views are highly oppinated and might have some slightly incorrect facts. My experience with typescript was about 2 weeks in Node and a week in angular2.

Not Standard

TypeScript is implementing their own take on JavaScript. Some of the things they are writing will likely never make it in an official ES* spec either.

Technologies that have competing spec / community driven development have a history of failing; take: Flash, SilverLight, CoffeeScript, the list goes on. If you have a large code base, picking TypeScript is something your going to be living with for a long time. I can take a bet in 3 years JavaScript will still be around without a doubt.

Its also worth noting that they have built some things like module system and as soon as the spec came out they ditched it and started using that. Have fun updating!