Last active
March 15, 2019 01:29
-
-
Save zetavg/e9a188ff839892ac6131d0899ebeef51 to your computer and use it in GitHub Desktop.
Nix Override Design Pattern (https://nixos.org/nixos/nix-pills/override-design-pattern.html) in JavaScript.
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
const makeOverridable = obj => ({ | |
...obj, | |
override: overrides => makeOverridable({ | |
...obj, | |
...overrides, | |
}), | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
makeOverridable
for functions that have type({ ...args }) => ({ ...obj })
should actually be:Example usage: