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