fast-redact
Advanced tools
Comparing version 3.4.0 to 3.4.1
@@ -43,3 +43,3 @@ 'use strict' | ||
const compileRestore = restorer({ secret, wcLen }) | ||
const compileRestore = restorer() | ||
const strict = 'strict' in opts ? opts.strict : true | ||
@@ -46,0 +46,0 @@ |
@@ -27,3 +27,3 @@ 'use strict' | ||
redact.secret = secret | ||
redact.state = state | ||
@@ -30,0 +30,0 @@ if (serialize === false) { |
@@ -7,5 +7,9 @@ 'use strict' | ||
function restorer ({ secret, wcLen }) { | ||
function restorer () { | ||
return function compileRestore () { | ||
if (this.restore) return | ||
if (this.restore) { | ||
this.restore.state.secret = this.secret | ||
return | ||
} | ||
const { secret, wcLen } = this | ||
const paths = Object.keys(secret) | ||
@@ -20,2 +24,3 @@ const resetters = resetTmpl(secret, paths) | ||
).bind(state) | ||
this.restore.state = state | ||
} | ||
@@ -22,0 +27,0 @@ } |
{ | ||
"name": "fast-redact", | ||
"version": "3.4.0", | ||
"version": "3.4.1", | ||
"description": "very fast object redaction", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -321,10 +321,13 @@ 'use strict' | ||
test('does not increment secret size', ({ end, is }) => { | ||
const redact = fastRedact({ paths: ['*.b'], censor: censorFct, serialize: false }) | ||
test('does not increment secret size', ({ end, is, same }) => { | ||
const redact = fastRedact({ paths: ['x', '*.b'], censor: censorFct, serialize: false }) | ||
is(redact({ a: { b: '0123456' } }).a.b, 'xxx56') | ||
is(redact.secret[''].length, 1) | ||
same(Object.keys(redact.state.secret), ['x']) | ||
const intialSecretSize = JSON.stringify(redact.state.secret).length | ||
is(redact({ c: { b: '0123456', d: 'pristine' } }).c.b, 'xxx56') | ||
is(redact.secret[''].length, 1) | ||
same(Object.keys(redact.state.secret), ['x']) | ||
is(JSON.stringify(redact.state.secret).length, intialSecretSize) | ||
is(redact({ c: { b: '0123456', d: 'pristine' } }).c.d, 'pristine') | ||
is(redact.secret[''].length, 1) | ||
same(Object.keys(redact.state.secret), ['x']) | ||
is(JSON.stringify(redact.state.secret).length, intialSecretSize) | ||
end() | ||
@@ -1415,2 +1418,12 @@ }) | ||
} | ||
const o2 = { | ||
a: { | ||
b1: { | ||
c1: { | ||
d1: { e: '123' }, | ||
d2: { e: '456' } | ||
} | ||
} | ||
} | ||
} | ||
@@ -1439,2 +1452,10 @@ const censor = 'censor' | ||
is(o.a.b2.c2.d2.e, '234') | ||
redact(o2) | ||
is(o2.a.b1.c1.d1.e, censor) | ||
is(o2.a.b1.c1.d2.e, censor) | ||
redact.restore(o2) | ||
is(o2.a.b1.c1.d1.e, '123') | ||
is(o2.a.b1.c1.d2.e, '456') | ||
end() | ||
@@ -1441,0 +1462,0 @@ }) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
91852
2220