Created
September 7, 2017 03:34
-
-
Save dotproto/00fd640ea6e355569b0db24342a51db9 to your computer and use it in GitHub Desktop.
Reflect + some customizations
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
export default var Silver = Object.create(Reflect, { | |
// ownEntries has a similar API to Object.entries, but it uses the same | |
// enumeration logic as Reflect.keys | |
ownEntries: { | |
writable: true, | |
enumerable: false, | |
configurable: true, | |
value: function(obj) { | |
return Reflect.ownKeys(obj).map(key => [key, obj[key]]); | |
} | |
}, | |
ownValues: { | |
writable: true, | |
enumerable: false, | |
configurable: true, | |
value: function(obj) { | |
return Reflect.ownKeys(obj).map(key => obj[key]) | |
} | |
} | |
}); | |
export let ownEntries = Silver.ownEntries; | |
export let ownValues = Silver.ownValues; | |
// var obj = {2: 'two', [Symbol('test')]: 'symbol', 'a': 'b'}; | |
// Object.defineProperty(obj, 1, { value: 'one' }); | |
// Silver.entries(obj) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment