rambdax
Version:
Extended version of Rambda - a lightweight, faster alternative to Ramda
29 lines (22 loc) • 537 B
JavaScript
import { replace } from './replace'
import { type } from './type'
export function remove(inputs, text){
if (arguments.length === 1){
return textHolder => remove(inputs, textHolder)
}
if (type(text) !== 'String'){
throw new Error(`R.remove requires string not ${ type(text) }`)
}
if (type(inputs) !== 'Array'){
return replace(
inputs, '', text
)
}
let textCopy = text
inputs.forEach(singleInput => {
textCopy = replace(
singleInput, '', textCopy
).trim()
})
return textCopy
}