node_modules: update
This commit is contained in:
parent
4a21c51f2f
commit
b91baffed3
107 changed files with 3886 additions and 2943 deletions
55
node_modules/fast-redact/lib/modifiers.js
generated
vendored
55
node_modules/fast-redact/lib/modifiers.js
generated
vendored
|
|
@ -16,16 +16,27 @@ function groupRestore ({ keys, values, target }) {
|
|||
}
|
||||
}
|
||||
|
||||
function groupRedact (o, path, censor, isCensorFct) {
|
||||
function groupRedact (o, path, censor, isCensorFct, censorFctTakesPath) {
|
||||
const target = get(o, path)
|
||||
if (target == null) return { keys: null, values: null, target: null, flat: true }
|
||||
const keys = Object.keys(target)
|
||||
const length = keys.length
|
||||
const values = new Array(length)
|
||||
for (var i = 0; i < length; i++) {
|
||||
const k = keys[i]
|
||||
values[i] = target[k]
|
||||
target[k] = isCensorFct ? censor(target[k]) : censor
|
||||
const keysLength = keys.length
|
||||
const pathLength = path.length
|
||||
const pathWithKey = censorFctTakesPath ? [...path] : undefined
|
||||
const values = new Array(keysLength)
|
||||
|
||||
for (var i = 0; i < keysLength; i++) {
|
||||
const key = keys[i]
|
||||
values[i] = target[key]
|
||||
|
||||
if (censorFctTakesPath) {
|
||||
pathWithKey[pathLength] = key
|
||||
target[key] = censor(target[key], pathWithKey)
|
||||
} else if (isCensorFct) {
|
||||
target[key] = censor(target[key])
|
||||
} else {
|
||||
target[key] = censor
|
||||
}
|
||||
}
|
||||
return { keys, values, target, flat: true }
|
||||
}
|
||||
|
|
@ -38,14 +49,15 @@ function nestedRestore (arr) {
|
|||
}
|
||||
}
|
||||
|
||||
function nestedRedact (store, o, path, ns, censor, isCensorFct) {
|
||||
function nestedRedact (store, o, path, ns, censor, isCensorFct, censorFctTakesPath) {
|
||||
const target = get(o, path)
|
||||
if (target == null) return
|
||||
const keys = Object.keys(target)
|
||||
const length = keys.length
|
||||
for (var i = 0; i < length; i++) {
|
||||
const keysLength = keys.length
|
||||
for (var i = 0; i < keysLength; i++) {
|
||||
const key = keys[i]
|
||||
const { value, parent, exists } = specialSet(target, key, ns, censor, isCensorFct)
|
||||
const { value, parent, exists } =
|
||||
specialSet(target, key, path, ns, censor, isCensorFct, censorFctTakesPath)
|
||||
|
||||
if (exists === true && parent !== null) {
|
||||
store.push({ key: ns[ns.length - 1], target: parent, value })
|
||||
|
|
@ -58,10 +70,11 @@ function has (obj, prop) {
|
|||
return Object.prototype.hasOwnProperty.call(obj, prop)
|
||||
}
|
||||
|
||||
function specialSet (o, k, p, v, f) {
|
||||
function specialSet (o, k, path, afterPath, censor, isCensorFct, censorFctTakesPath) {
|
||||
const afterPathLen = afterPath.length
|
||||
const lastPathIndex = afterPathLen - 1
|
||||
const originalKey = k
|
||||
var i = -1
|
||||
var l = p.length
|
||||
var li = l - 1
|
||||
var n
|
||||
var nv
|
||||
var ov
|
||||
|
|
@ -69,22 +82,26 @@ function specialSet (o, k, p, v, f) {
|
|||
var exists = true
|
||||
ov = n = o[k]
|
||||
if (typeof n !== 'object') return { value: null, parent: null, exists }
|
||||
while (n != null && ++i < l) {
|
||||
k = p[i]
|
||||
while (n != null && ++i < afterPathLen) {
|
||||
k = afterPath[i]
|
||||
oov = ov
|
||||
if (!(k in n)) {
|
||||
exists = false
|
||||
break
|
||||
}
|
||||
ov = n[k]
|
||||
nv = f ? v(ov) : v
|
||||
nv = (i !== li) ? ov : nv
|
||||
n[k] = (has(n, k) && nv === ov) || (nv === undefined && v !== undefined) ? n[k] : nv
|
||||
nv = (i !== lastPathIndex)
|
||||
? ov
|
||||
: (isCensorFct
|
||||
? (censorFctTakesPath ? censor(ov, [...path, originalKey, ...afterPath]) : censor(ov))
|
||||
: censor)
|
||||
n[k] = (has(n, k) && nv === ov) || (nv === undefined && censor !== undefined) ? n[k] : nv
|
||||
n = n[k]
|
||||
if (typeof n !== 'object') break
|
||||
}
|
||||
return { value: ov, parent: oov, exists }
|
||||
}
|
||||
|
||||
function get (o, p) {
|
||||
var i = -1
|
||||
var l = p.length
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue