MCPcopy Create free account
hub / github.com/angular/dev-infra / iteratorMixin

Function iteratorMixin

github-actions/browserstack/set-browserstack-env.js:4707–4763  ·  view source on GitHub ↗
(name, object, kInternalIterator, keyIndex = 0, valueIndex = 1)

Source from the content-addressed store, hash-verified

4705 if (result === void 0) {
4706 throw new TypeError("Value is not JSON serializable");
4707 }
4708 assert(typeof result === "string");
4709 return result;
4710 }
4711 var esIteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()));
4712 function createIterator(name, kInternalIterator, keyIndex = 0, valueIndex = 1) {
4713 var _target, _kind, _index;
4714 class FastIterableIterator {
4715 /**
4716 * @see https://webidl.spec.whatwg.org/#dfn-default-iterator-object
4717 * @param {unknown} target
4718 * @param {'key' | 'value' | 'key+value'} kind
4719 */
4720 constructor(target, kind) {
4721 /** @type {any} */
4722 __privateAdd(this, _target, void 0);
4723 /** @type {'key' | 'value' | 'key+value'} */
4724 __privateAdd(this, _kind, void 0);
4725 /** @type {number} */
4726 __privateAdd(this, _index, void 0);
4727 __privateSet(this, _target, target);
4728 __privateSet(this, _kind, kind);
4729 __privateSet(this, _index, 0);
4730 }
4731 next() {
4732 if (typeof this !== "object" || this === null || !__privateIn(_target, this)) {
4733 throw new TypeError(
4734 `'next' called on an object that does not implement interface ${name} Iterator.`
4735 );
4736 }
4737 const index = __privateGet(this, _index);
4738 const values = __privateGet(this, _target)[kInternalIterator];
4739 const len = values.length;
4740 if (index >= len) {
4741 return {
4742 value: void 0,
4743 done: true
4744 };
4745 }
4746 const { [keyIndex]: key, [valueIndex]: value } = values[index];
4747 __privateSet(this, _index, index + 1);
4748 let result;
4749 switch (__privateGet(this, _kind)) {
4750 case "key":
4751 result = key;
4752 break;
4753 case "value":
4754 result = value;
4755 break;
4756 case "key+value":
4757 result = [key, value];
4758 break;
4759 }
4760 return {
4761 value: result,
4762 done: false
4763 };
4764 }

Callers 1

""Function · 0.70

Calls 3

createIteratorFunction · 0.70
__spreadPropsFunction · 0.70
__spreadValuesFunction · 0.70

Tested by

no test coverage detected