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

main
Last change on this file since 0c6b92a was 0c6b92a, checked in by stefan toskovski <stefantoska84@…>, 5 weeks ago

Pred finalna verzija

  • Property mode set to 100644
File size: 1.5 KB
Line 
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
14// https://tc39.es/proposal-iterator-helpers/#sec-getiteratorflattenable
15
16module.exports = function GetIteratorFlattenable(obj, stringHandling) {
17 if (stringHandling !== 'REJECT-STRINGS' && stringHandling !== 'ITERATE-STRINGS') {
18 throw new $TypeError('Assertion failed: `stringHandling` must be "REJECT-STRINGS" or "ITERATE-STRINGS"');
19 }
20
21 if (Type(obj) !== 'Object') {
22 if (stringHandling === 'REJECT-STRINGS' || typeof obj !== 'string') {
23 throw new $TypeError('obj must be an Object'); // step 1.a
24 }
25 }
26
27 var method = void undefined; // step 2
28
29 // method = GetMethod(obj, Symbol.iterator); // step 5.a
30 method = getIteratorMethod(
31 {
32 AdvanceStringIndex: AdvanceStringIndex,
33 GetMethod: GetMethod,
34 IsArray: IsArray
35 },
36 obj
37 );
38
39 var iterator;
40 if (typeof method === 'undefined') { // step 3
41 iterator = obj; // step 3.a
42 } else { // step 4
43 iterator = Call(method, obj); // step 4.a
44 }
45
46 if (Type(iterator) !== 'Object') {
47 throw new $TypeError('iterator must be an Object'); // step 5
48 }
49 return GetIteratorDirect(iterator); // step 6
50};
Note: See TracBrowser for help on using the repository browser.