shared
utils
string
object
is
extension
js
tracking
string
dom
when
selection
position
iframe
event
scroll
console
node
string
project
fs
console
replaceChunks
Type:Function
Status:stable
Since:1.0.0
Platform:jsnode
@blackbyte.sugar.shared.string
Replace the passed “chunks” with the result of the passed replacer function. The replacer function take as argument the token value
Params
- string*-String
The string to process
- chunks*-String[]
The chunks to replace
- replacer*-Function
The replacer function that need to return a string with which you want to replace the token
Return
- -String
The new string with replaced chunks
Example
import { replaceChunks } from '@blackbyte/sugar/string'
replaceChunks('hello world', ['or'], (token) => {
return `<span>${token}</span>;
}) // Hello w<span>or</span>ldTodo
- testsnormal
Author
- Olivier Bosselolivier.bossel@gmail.comhttps://blackbyte.space