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

Function createIterator

github-actions/saucelabs/set-saucelabs-env.js:4635–4706  ·  view source on GitHub ↗
(name, kInternalIterator, keyIndex = 0, valueIndex = 1)

Source from the content-addressed store, hash-verified

4633 function serializeJavascriptValueToJSONString(value) {
4634 const result = JSON.stringify(value);
4635 if (result === void 0) {
4636 throw new TypeError("Value is not JSON serializable");
4637 }
4638 assert(typeof result === "string");
4639 return result;
4640 }
4641 var esIteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()));
4642 function createIterator(name, kInternalIterator, keyIndex = 0, valueIndex = 1) {
4643 var _target, _kind, _index;
4644 class FastIterableIterator {
4645 /**
4646 * @see https://webidl.spec.whatwg.org/#dfn-default-iterator-object
4647 * @param {unknown} target
4648 * @param {'key' | 'value' | 'key+value'} kind
4649 */
4650 constructor(target, kind) {
4651 /** @type {any} */
4652 __privateAdd(this, _target, void 0);
4653 /** @type {'key' | 'value' | 'key+value'} */
4654 __privateAdd(this, _kind, void 0);
4655 /** @type {number} */
4656 __privateAdd(this, _index, void 0);
4657 __privateSet(this, _target, target);
4658 __privateSet(this, _kind, kind);
4659 __privateSet(this, _index, 0);
4660 }
4661 next() {
4662 if (typeof this !== "object" || this === null || !__privateIn(_target, this)) {
4663 throw new TypeError(
4664 `'next' called on an object that does not implement interface ${name} Iterator.`
4665 );
4666 }
4667 const index = __privateGet(this, _index);
4668 const values = __privateGet(this, _target)[kInternalIterator];
4669 const len = values.length;
4670 if (index >= len) {
4671 return {
4672 value: void 0,
4673 done: true
4674 };
4675 }
4676 const { [keyIndex]: key, [valueIndex]: value } = values[index];
4677 __privateSet(this, _index, index + 1);
4678 let result;
4679 switch (__privateGet(this, _kind)) {
4680 case "key":
4681 result = key;
4682 break;
4683 case "value":
4684 result = value;
4685 break;
4686 case "key+value":
4687 result = [key, value];
4688 break;
4689 }
4690 return {
4691 value: result,
4692 done: false

Callers 1

iteratorMixinFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected