Created
February 18, 2015 00:41
-
-
Save roman01la/a382359845f9067e9387 to your computer and use it in GitHub Desktop.
Property with a custom getter to get merged Set objects as a single Set
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
let obj = { | |
a: new Set([1,2,3]), | |
b: new Set([4,2,6,7]), | |
c: new Set([6,2,1,0]) | |
}; | |
Object.defineProperties(obj, { | |
all: { | |
get() { return new Set([...Object.keys(this).reduce((a, b) => [...(this[a] || a), ...this[b]])]); } | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment