All files / plugins split.js

25% Statements 1/4
0% Branches 0/7
0% Functions 0/3
25% Lines 1/4

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      1x          
import {toStr} from "../helpers/string/to_string";
import {isEmpty} from "./is_empty";
 
export const split = (str, sep = undefined, limit = undefined, trim = true) => {
    return toStr(str)
        .split(sep, limit)
        .map( el => trim ? el.trim() : el )
        .filter( el => trim ? !isEmpty(el) : true)
}