All files / lib strings.js

100% Statements 12/12
100% Branches 10/10
100% Functions 5/5
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 197x 8x       7x   7x 8x 4x 4x 4x 5x 5x   4x      
export const upperCaseFirst = (sentence = "") =>
    sentence && typeof sentence === "string" && sentence.length
        ? `${sentence[0].toUpperCase()}${sentence.slice(1, sentence.length)}`
        : "";
 
export const removeFirst = sentence => sentence.slice(1, sentence.length);
 
export const template = (strings, ...keys) => {
    return (...values) => {
        const dict = values[values.length - 1] || {};
        const result = [strings[0]];
        keys.forEach((key, i) => {
            const value = Number.isInteger(key) ? values[key] : dict[key];
            result.push(value, strings[i + 1]);
        });
        return result.join("");
    };
};