From 4e87195739f2a5d9a05451b48773c8afdc680765 Mon Sep 17 00:00:00 2001 From: akiyamn Date: Sun, 24 Sep 2023 23:22:21 +1000 Subject: Initial commit (by create-cloudflare CLI) --- node_modules/stacktracey/impl/partition.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 node_modules/stacktracey/impl/partition.js (limited to 'node_modules/stacktracey/impl/partition.js') diff --git a/node_modules/stacktracey/impl/partition.js b/node_modules/stacktracey/impl/partition.js new file mode 100644 index 0000000..bb130b5 --- /dev/null +++ b/node_modules/stacktracey/impl/partition.js @@ -0,0 +1,22 @@ +"use strict"; + +module.exports = (arr_, pred) => { + + const arr = arr_ || [], + spans = [] + + let span = { label: undefined, + items: [arr.first] } + + arr.forEach (x => { + + const label = pred (x) + + if ((span.label !== label) && span.items.length) { + spans.push (span = { label: label, items: [x] }) } + + else { + span.items.push (x) } }) + + return spans +} \ No newline at end of file -- cgit v1.2.3