Socket
Socket
Sign inDemoInstall

fast-redact

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-redact - npm Package Compare versions

Comparing version 1.4.3 to 1.4.4

2

lib/redactor.js

@@ -91,3 +91,3 @@ 'use strict'

function strictImpl (strict) {
return strict === true ? `throw Error('fast-redact: primitives cannot be redacted')` : `return o`
return strict === true ? `throw Error('fast-redact: primitives cannot be redacted')` : `return typeof o === 'string' ? JSON.stringify(o) : o`
}
{
"name": "fast-redact",
"version": "1.4.3",
"version": "1.4.4",
"description": "very fast object redaction",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -160,3 +160,4 @@ # fast-redact

of an object it finds a primitive. When `strict` is set to `false`, the redactor function
will return the primitive value without being redacted.
will return the primitive value without being redacted and if the primitive is of type "string",
the primitive value is returned as JSON (i.e. within double quotes and escaped per JSON rules).

@@ -163,0 +164,0 @@ ## Approach

@@ -31,3 +31,3 @@ 'use strict'

test('throws when passed non-object using [strict: true]', ({ end, throws }) => {
test('throws when passed non-object number using [strict: true]', ({ end, throws }) => {
const redact = fastRedact({ paths: ['a.b.c'], strict: true })

@@ -38,10 +38,42 @@ throws(() => redact(1))

test('returns original value when passed non-object using [strict: false]', ({ end, is, doesNotThrow }) => {
test('returns original value when passed non-object boolean using [strict: false]', ({ end, is, doesNotThrow }) => {
const redact = fastRedact({ paths: ['a.b.c'], strict: false })
doesNotThrow(() => redact(true))
const o = redact(true)
is(o, true)
end()
})
test('returns original value when passed non-object null using [strict: false]', ({ end, is, doesNotThrow }) => {
const redact = fastRedact({ paths: ['a.b.c'], strict: false })
doesNotThrow(() => redact(null))
const o = redact(null)
is(o, null)
end()
})
test('returns original value when passed non-object undefined using [strict: false]', ({ end, is, doesNotThrow }) => {
const redact = fastRedact({ paths: ['a.b.c'], strict: false })
doesNotThrow(() => redact())
const o = redact()
is(o, undefined)
end()
})
test('returns original value quoted when passed non-object string using [strict: false]', ({ end, is, doesNotThrow }) => {
const redact = fastRedact({ paths: ['a.b.c'], strict: false })
doesNotThrow(() => redact(1))
const o = redact(1)
is(o, 1)
const o = redact('A')
is(o, '"A"')
end()
})
test('returns original value quoted when passed non-object string using [strict: false]', ({ end, is, doesNotThrow }) => {
const redact = fastRedact({ paths: ['a.b.c'], strict: false })
doesNotThrow(() => redact(1))
const o = redact('A')
is(o, '"A"')
end()
})
test('throws if a path is not a string', ({ end, is, throws }) => {

@@ -48,0 +80,0 @@ throws((e) => {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc