source: imaps-frontend/node_modules/es-iterator-helpers/aos/GetIteratorFlattenable.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[d565449]1'use strict';
2
3var $TypeError = require('es-errors/type');
4
5var AdvanceStringIndex = require('es-abstract/2024/AdvanceStringIndex');
6var Call = require('es-abstract/2024/Call');
7var GetIteratorDirect = require('./GetIteratorDirect');
8var GetMethod = require('es-abstract/2024/GetMethod');
9var IsArray = require('es-abstract/2024/IsArray');
10var Type = require('es-abstract/2024/Type');
11
12var getIteratorMethod = require('es-abstract/helpers/getIteratorMethod');
13
14module.exports = function GetIteratorFlattenable(obj, stringHandling) {
15 if (Type(obj) !== 'Object') {
16 if (stringHandling === 'reject-strings' || typeof obj !== 'string') {
17 throw new $TypeError('obj must be an Object'); // step 1.a
18 }
19 }
20
21 var method = void undefined; // step 2
22
23 // method = GetMethod(obj, Symbol.iterator); // step 5.a
24 method = getIteratorMethod(
25 {
26 AdvanceStringIndex: AdvanceStringIndex,
27 GetMethod: GetMethod,
28 IsArray: IsArray
29 },
30 obj
31 );
32
33 var iterator;
34 if (typeof method === 'undefined') { // step 3
35 iterator = obj; // step 3.a
36 } else { // step 4
37 iterator = Call(method, obj); // step 4.a
38 }
39
40 if (Type(iterator) !== 'Object') {
41 throw new $TypeError('iterator must be an Object'); // step 5
42 }
43 return GetIteratorDirect(iterator); // step 6
44};
Note: See TracBrowser for help on using the repository browser.