source: frontend/node_modules/es-abstract/2025/SetDataSize.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 689 bytes
Line 
1'use strict';
2
3var $TypeError = require('es-errors/type');
4
5var forEach = require('../helpers/forEach');
6var isArray = require('../helpers/IsArray');
7
8// https://262.ecma-international.org/16.0/#sec-setdatasize
9
10// TODO: when spec enums are unforgeable, uncomment ~EMPTY~ check
11
12module.exports = function SetDataSize(setData) {
13 if (!isArray(setData) && setData !== 'EMPTY') {
14 throw new $TypeError('Assertion failed: `setData` must be a List or ~EMPTY~');
15 }
16
17 if (setData === 'EMPTY') {
18 return 0;
19 }
20
21 var count = 0; // step 1
22
23 forEach(setData, function (e, i) { // step 2
24 if (i in setData /* && e !== ~EMPTY~ */) {
25 count += 1; // step 2.a
26 }
27 });
28
29 return count; // step 3
30};
Note: See TracBrowser for help on using the repository browser.