impl/partition.js   A
last analyzed

Complexity

Total Complexity 4
Complexity/F 2

Size

Lines of Code 22
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 0
c 0
b 0
f 0
nc 4
dl 0
loc 22
rs 10
wmc 4
mnd 1
bc 4
fnc 2
bpm 2
cpm 2
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A partition.js ➔ ??? 0 20 1
1
"use strict";
2
3
module.exports = (arr_, pred) => {
4
5
    const arr   = arr_ || [],
6
          spans = []
7
    
8
    let span = { label: undefined,
9
                 items: [arr.first] }
10
                 
11
    arr.forEach (x => {
12
13
        const label = pred (x)
14
15
        if ((span.label !== label) && span.items.length) {
16
            spans.push (span = { label: label, items: [x] }) }
17
18
        else {
19
            span.items.push (x) } })
20
21
    return spans
22
}