Skip to content

Instantly share code, notes, and snippets.

@dotproto
Created September 7, 2017 03:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dotproto/00fd640ea6e355569b0db24342a51db9 to your computer and use it in GitHub Desktop.
Save dotproto/00fd640ea6e355569b0db24342a51db9 to your computer and use it in GitHub Desktop.
Reflect + some customizations
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