Skip to content

Instantly share code, notes, and snippets.

@bendc bendc/iterable.js
Created Jan 26, 2016

What would you like to do?
Make objects iterable
const iterable = function* (obj) {
yield* Object.keys(obj).map(key => [key, obj[key]]);

This comment has been minimized.

Copy link
Owner Author

bendc commented Jan 26, 2016


const obj = iterable({
  a: 1,
  b: 2
});; // => value: ["a", 1], done: false; // => value: ["b", 2], done: false; // => value: undefined, done: true
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.