{"ScriptPreparationCode":null,"TestCases":[{"Name":"filter","Code":"const posts = [\r\n\t{ id: 1, type: \u0027foo\u0027 },\r\n\t{ id: 2, type: \u0027bar\u0027 },\r\n\t{ id: 3, type: \u0027baz\u0027 },\r\n\t{ id: 4, type: \u0027foo\u0027 },\r\n\t{ id: 5, type: \u0027bar\u0027 },\r\n\t{ id: 6, type: \u0027baz\u0027 },\r\n\t{ id: 7, type: \u0027foo\u0027 },\r\n\t{ id: 8, type: \u0027bar\u0027 },\r\n\t{ id: 9, type: \u0027baz\u0027 }\r\n];\r\n\r\nposts.filter(p =\u003E p.type === \u0027foo\u0027).length;\r\nposts.filter(p =\u003E p.type === \u0027foo\u0027).length;\r\nposts.filter(p =\u003E p.type === \u0027foo\u0027).length;\r\nposts.filter(p =\u003E p.type === \u0027foo\u0027).length;","IsDeferred":false},{"Name":"groupBy","Code":"const posts = [\r\n\t{ id: 1, type: \u0027foo\u0027 },\r\n\t{ id: 2, type: \u0027bar\u0027 },\r\n\t{ id: 3, type: \u0027baz\u0027 },\r\n\t{ id: 4, type: \u0027foo\u0027 },\r\n\t{ id: 5, type: \u0027bar\u0027 },\r\n\t{ id: 6, type: \u0027baz\u0027 },\r\n\t{ id: 7, type: \u0027foo\u0027 },\r\n\t{ id: 8, type: \u0027bar\u0027 },\r\n\t{ id: 9, type: \u0027baz\u0027 }\r\n];\r\n\r\nvar groupBy = function(xs, key) {\r\n return xs.reduce(function(rv, x) {\r\n (rv[x[key]] = rv[x[key]] || []).push(x);\r\n return rv;\r\n }, {});\r\n};\r\n\r\nconst postsByType = groupBy(posts, \u0027type\u0027)\r\n\r\npostsByType.foo.length;\r\npostsByType.bar.length;\r\npostsByType.baz.length;\r\npostsByType.foo.length;","IsDeferred":false}]}