LCOV - code coverage report
Current view: top level - modules/esm/_encoding - util.js (source / functions) Coverage Total Hit
Test: gjs- Code Coverage Lines: 89.5 % 19 17
Test Date: 2024-04-20 17:42:51 Functions: 100.0 % 2 2
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 54.2 % 24 13

             Branch data     Line data    Source code
       1                 :          47 : // SPDX-License-Identifier: MIT
       2                 :             : // SPDX-FileCopyrightText: Node.js contributors. All rights reserved.
       3                 :             : 
       4                 :             : // Modified from https://github.com/nodejs/node/blob/78680c1cbc8b0c435963bc512e826b2a6227c315/lib/internal/encoding.js
       5                 :             : 
       6                 :             : /**
       7                 :             :  * Trims ASCII whitespace from a string.
       8                 :             :  * `String.prototype.trim` removes non-ASCII whitespace.
       9                 :             :  *
      10                 :             :  * @param {string} label the label to trim
      11                 :             :  * @returns {string}
      12                 :             :  */
      13                 :         396 : export const trimAsciiWhitespace = label => {
      14                 :         349 :     let s = 0;
      15                 :         349 :     let e = label.length;
      16                 :             :     while (
      17         [ +  + ]:         351 :         s < e &&
      18         [ -  + ]:         349 :         (label[s] === '\u0009' ||
      19         [ -  + ]:         349 :             label[s] === '\u000a' ||
      20         [ -  + ]:         349 :             label[s] === '\u000c' ||
      21         [ -  + ]:         349 :             label[s] === '\u000d' ||
      22         [ +  - ]:         349 :             label[s] === '\u0020')
      23                 :             :     )
      24                 :           0 :         s++;
      25                 :             : 
      26                 :             :     while (
      27         [ -  + ]:         349 :         e > s &&
      28         [ -  + ]:         349 :         (label[e - 1] === '\u0009' ||
      29         [ -  + ]:         349 :             label[e - 1] === '\u000a' ||
      30         [ -  + ]:         349 :             label[e - 1] === '\u000c' ||
      31         [ -  + ]:         349 :             label[e - 1] === '\u000d' ||
      32         [ +  - ]:         349 :             label[e - 1] === '\u0020')
      33                 :             :     )
      34                 :           0 :         e--;
      35                 :             : 
      36                 :         349 :     return label.slice(s, e);
      37                 :         349 : };
        

Generated by: LCOV version 2.0-1