tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

string.js (668B)


      1 // Copyright (c) 2023 Ecma International.  All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 esid: sec-map.groupby
      6 description: Map.groupBy works for string items
      7 info: |
      8  Map.groupBy ( items, callbackfn )
      9  ...
     10 includes: [compareArray.js]
     11 features: [array-grouping, Map]
     12 ---*/
     13 
     14 const string = '🥰💩🙏😈';
     15 
     16 const map = Map.groupBy(string, function (char) {
     17  return char < '🙏' ? 'before' : 'after';
     18 });
     19 
     20 assert.compareArray(Array.from(map.keys()), ['after', 'before']);
     21 assert.compareArray(map.get('before'), ['💩', '😈']);
     22 assert.compareArray(map.get('after'), ['🥰', '🙏']);
     23 
     24 reportCompare(0, 0);