2 replaces with 1 replace with callback

Benchmark created on


Setup

const name = 'schema.table'

const replacer = (char) => char === '.' ? '"."' : '""'

Test runner

Ready to run.

Testing in
TestOps/sec
2 replaces
`"${name.replace(/"/g, '""').replace(/\./g, '"."')}"`
ready
1 replace with callback
`"${name.replace(/["\.]/g, replacer)}"`
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.