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 guards */ | |
export function assertType<T>(obj: any, assertion: (obj: T) => boolean): asserts obj is T { | |
if (!assertion(obj)) throw new Error('Invalid type') | |
} | |
export function is<T>(obj: any, assertion: (obj: T) => boolean): obj is T { | |
return assertion(obj); | |
} |
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
// Class-based Tree Shaking - HTTP203 @ Google Chrome Developers | |
// https://www.youtube.com/watch?v=lsd2-TCgHEs&t=599 | |
class Store { | |
/** | |
* Do the given action with the given parameters. | |
* | |
* @param {A => R} action Action to be taken. | |
* @param {A} args Arguments to be passed to the action. | |
* @returns {R} Returns the result of original action call. |
NewerOlder