Debian Codegraph @

js/src/tests/test262/built-ins/Object/groupBy/string.js

raw
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-object.groupby
6 description: Object.groupBy works for string items
7 info: |
8 Object.groupBy ( items, callbackfn )
9 ...
10 includes: [compareArray.js]
11 features: [array-grouping]
12 ---*/
13
14 const string = '🥰💩🙏😈';
15
16 const obj = Object.groupBy(string, function (char) {
17 return char < '🙏' ? 'before' : 'after';
18 });
19
20 assert.compareArray(Object.keys(obj), ['after', 'before']);
21 assert.compareArray(obj.before, ['💩', '😈']);
22 assert.compareArray(obj.after, ['🥰', '🙏']);
23
24 reportCompare(0, 0);