Skip to content

Instantly share code, notes, and snippets.

@dotproto dotproto/silver.js
Created Sep 7, 2017

Embed
What would you like to do?
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
You can’t perform that action at this time.