Function replaceAsync

  • Replace Something in a String with async callback

    Parameters

    • input: string
    • searchValue: string | RegExp
    • replacer: ((match) => string | Promise<string>)
        • (match): string | Promise<string>
        • Parameters

          • match: string

          Returns string | Promise<string>

    Returns Promise<string>

    Example

    import { string } from "@rjweb/utils"
    import db from "somewhere"

    string.replaceAsync('very long string or something', /./g, async(match) => {
    const result = await db.get(match)

    return result
    })

    Since

    1.8.3

    Supports

    nodejs, browser