Skip to content

Instantly share code, notes, and snippets.

@TCotton
Created February 12, 2017 14:27
Show Gist options
  • Save TCotton/9b6f4f62e121f02fcabe29788f3002a7 to your computer and use it in GitHub Desktop.
Save TCotton/9b6f4f62e121f02fcabe29788f3002a7 to your computer and use it in GitHub Desktop.
find object values and arrays -> shallow object
function* objectEntries(obj, findKeys = false) {
let keys = Reflect.ownKeys(obj);
if(findKeys) {
yield keys;
} else {
for (let key of keys) {
yield [key, obj[key]];
}
}
}
objectEntries({one: 'this is a string', two: 'this is another string'}, true).next();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment