Last active
April 13, 2021 08:03
-
-
Save agentbellnorm/494312bafa1b3033ff0e02d405cd601a to your computer and use it in GitHub Desktop.
clojure's swap function in typescript with proper typing.
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
swap<K extends unknown[]>(swapFunction: (state: T, ...args: K) => T, ...args: K): T { | |
this.state = swapFunction.apply(null, [this.state, ...args]); | |
return this.state; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment