MCPcopy
hub / github.com/codeceptjs/CodeceptJS / replaceValueDeep

Function replaceValueDeep

lib/utils.js:412–432  ·  view source on GitHub ↗
(obj, key, value)

Source from the content-addressed store, hash-verified

410 * @param {*} value value to set for key
411 */
412export const replaceValueDeep = function replaceValueDeep(obj, key, value) {
413 if (!obj) return
414
415 if (obj instanceof Array) {
416 for (const i in obj) {
417 replaceValueDeep(obj[i], key, value)
418 }
419 }
420
421 if (Object.prototype.hasOwnProperty.call(obj, key)) {
422 obj[key] = value
423 }
424
425 if (typeof obj === 'object' && obj !== null) {
426 const children = Object.values(obj)
427 for (const child of children) {
428 replaceValueDeep(child, key, value)
429 }
430 }
431 return obj
432}
433
434export const ansiRegExp = function ({ onlyFirst = false } = {}) {
435 const pattern = ['[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)', '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'].join('|')

Callers 2

getOverridenConfigFunction · 0.90
executeRunFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected