Created
March 5, 2017 07:41
-
-
Save codemilli/3b183dae5e599fc7a864877546821307 to your computer and use it in GitHub Desktop.
FunctorObject
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
class FunctorObject { | |
constructor (obj) { | |
this.value = obj; | |
} | |
map (func) { | |
const obj = {}; | |
for (const key of Object.keys(this.value)) { | |
obj[key] = func(this.value[key]); | |
} | |
return new FunctorObject(obj); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment