🌳
pt0/sharedF/moDashF/replaceAllF.mts
1import * as _ from 'lodash-es'
5export const replaceAllStrict = (contents: string, fromStr: string, toStr: string): string => {
6 if (fromStr == toStr) return contents
7 contents = replaceStrict(contents, fromStr, toStr)
8 while (_.includes(contents, fromStr)) {
9 contents = replaceStrict(contents, fromStr, toStr)
10 }
11 return contents
14export const replaceAll = (contents: string, fromStr: string, toStr: string): string => {
15 assertString(fromStr)
17 if (!_.includes(contents, fromStr)) return contents
18 return replaceAllStrict(contents, fromStr, toStr)