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

  1. string*-String

    The string to process

  2. chunks*-String[]

    The chunks to replace

  3. replacer*-Function

    The replacer function that need to return a string with which you want to replace the token

Return

  1. -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>ld

Todo

  • testsnormal