Last active
July 4, 2018 20:40
-
-
Save renanpvaz/3d9567e4242514cefa72e9f52a116798 to your computer and use it in GitHub Desktop.
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
const { random, floor } = Math | |
const CatSack = Object.assign( | |
(...cats) => ({ pull: () => cats[floor(random() * cats.length)] }), | |
{ of: (...args) => CatSack(...args) } | |
) | |
const sack = CatSack.of('Oof', null, {}) | |
sack.pull() | |
// null | |
sack.pull() | |
// null | |
sack.pull() | |
// {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment