Sha256: 28e211b34823faa36f348dbe4f20ddff6734cbb2b4fbbc0c53f8bda24128c95b

Contents?: true

Size: 1.28 KB

Versions: 17

Compression:

Stored size: 1.28 KB

Contents

'use strict';
var InternalStateModule = require('../internals/internal-state');
var createIteratorConstructor = require('../internals/create-iterator-constructor');
var has = require('../internals/has');
var objectKeys = require('../internals/object-keys');
var toObject = require('../internals/to-object');

var OBJECT_ITERATOR = 'Object Iterator';
var setInternalState = InternalStateModule.set;
var getInternalState = InternalStateModule.getterFor(OBJECT_ITERATOR);

module.exports = createIteratorConstructor(function ObjectIterator(source, mode) {
  var object = toObject(source);
  setInternalState(this, {
    type: OBJECT_ITERATOR,
    mode: mode,
    object: object,
    keys: objectKeys(object),
    index: 0
  });
}, 'Object', function next() {
  var state = getInternalState(this);
  var keys = state.keys;
  while (true) {
    if (keys === null || state.index >= keys.length) {
      state.object = state.keys = null;
      return { value: undefined, done: true };
    }
    var key = keys[state.index++];
    var object = state.object;
    if (!has(object, key)) continue;
    switch (state.mode) {
      case 'keys': return { value: key, done: false };
      case 'values': return { value: object[key], done: false };
    } /* entries */ return { value: [key, object[key]], done: false };
  }
});

Version data entries

17 entries across 16 versions & 6 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/core-js/internals/object-iterator.js
tang-0.2.1 spec/tang_app/node_modules/core-js/internals/object-iterator.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/core-js/internals/object-iterator.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/core-js/internals/object-iterator.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/core-js/internals/object-iterator.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/core-js/internals/object-iterator.js
tang-0.2.0 spec/tang_app/node_modules/core-js/internals/object-iterator.js
tang-0.1.0 spec/tang_app/node_modules/core-js/internals/object-iterator.js
tang-0.0.9 spec/tang_app/node_modules/core-js/internals/object-iterator.js
enju_library-0.3.8 spec/dummy/node_modules/core-js/internals/object-iterator.js
condenser-0.3 lib/condenser/processors/node_modules/core-js-pure/internals/object-iterator.js
condenser-0.2 lib/condenser/processors/node_modules/core-js-pure/internals/object-iterator.js
condenser-0.1 lib/condenser/processors/node_modules/core-js-pure/internals/object-iterator.js
condenser-0.0.12 lib/condenser/processors/node_modules/core-js-pure/internals/object-iterator.js
condenser-0.0.11 lib/condenser/processors/node_modules/core-js-pure/internals/object-iterator.js
condenser-0.0.10 lib/condenser/processors/node_modules/core-js-pure/internals/object-iterator.js
condenser-0.0.9 lib/condenser/processors/node_modules/core-js-pure/internals/object-iterator.js