Failed Conditions
Push — master ( f5e7b3...711045 )
by Yo
01:30
created

mapNormalizeAnyway.js ➔ ... ➔ ???   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
c 2
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 9.4285
1
"use strict";
2
3
const seqAnyway = require('./seqAnyway');
4
/**
5
 * @param {*}               initialValue
6
 * @param {Array<callback>} callbackList Each callback  will receive the result of previous one (or initialValue).
7
 *
8
 * @returns {Promise<string>} Return a promise resolved with normalized value
9
 */
10
module.exports = (initialValue, callbackList) => {
11
    let lastResult = initialValue;
12
13
    return seqAnyway(
14
        callbackList.map(callback => {
15
            return () => {
16
                lastResult = callback(lastResult);
17
            };
18
        })
19
    )
20
        .then(() => lastResult);
21
};
22