Ignore:
Timestamp:
01/21/25 03:08:24 (3 days ago)
Author:
stefan toskovski <stefantoska84@…>
Branches:
main
Parents:
0c6b92a
Message:

F4 Finalna Verzija

File:
1 edited

Legend:

Unmodified
Added
Removed
  • imaps-frontend/node_modules/es-abstract/2024/FindViaPredicate.js

    r0c6b92a r79a0317  
    22
    33var $TypeError = require('es-errors/type');
     4var isInteger = require('math-intrinsics/isInteger');
    45
    56var Call = require('./Call');
     
    89var IsCallable = require('./IsCallable');
    910var ToString = require('./ToString');
    10 var Type = require('./Type');
    1111
    12 var isInteger = require('../helpers/isInteger');
     12var isObject = require('../helpers/isObject');
     13
     14// https://262.ecma-international.org/15.0/#sec-findviapredicate
    1315
    1416module.exports = function FindViaPredicate(O, len, direction, predicate, thisArg) {
    15         if (Type(O) !== 'Object') {
     17        if (!isObject(O)) {
    1618                throw new $TypeError('Assertion failed: Type(O) is not Object');
    1719        }
     
    1921                throw new $TypeError('Assertion failed: len must be a non-negative integer');
    2022        }
    21         if (direction !== 'ascending' && direction !== 'descending') {
    22                 throw new $TypeError('Assertion failed: direction must be "ascending" or "descending"');
     23        if (direction !== 'ascending' && direction !== 'descending' && direction !== 'DESCENDING' && direction !== 'ASCENDING') {
     24                throw new $TypeError('Assertion failed: direction must be ~ASCENDING~ or ~DESCENDING~');
    2325        }
    2426
     
    2830
    2931        for ( // steps 2-4
    30                 var k = direction === 'ascending' ? 0 : len - 1;
    31                 direction === 'ascending' ? k < len : k >= 0;
     32                var k = direction === 'ascending' || direction === 'ASCENDING' ? 0 : len - 1;
     33                direction === 'ascending' || direction === 'ASCENDING' ? k < len : k >= 0;
    3234                k += 1
    3335        ) {
Note: See TracChangeset for help on using the changeset viewer.