Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rdct

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rdct

Deeply redact all the things

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

redact( obj [, options] ) NPM

Deeply redact all the things

Installation

npm install --save rdct

Usage

redact(object)

import redact from 'rdct';

let obj = {
    nested: {
        arr: ['with', 'strings', 'in', 'the', 'array'],
        mixed: ['with', false, ['and', 'deeply', 'nested', {stuff: 2}]],
        num: -17772.11,
        str: 'some long string',
        blank: null,
        missing: void 0,
        regex: /test/i,
        func: () => {}
    }
};

console.log(redact(obj, {includeType: true, min: 3}));
// {
//   nested: {
//     arr: [
//     'w**h [String]',
//     's*****s [String]',
//     '*** [String]',
//     't*e [String]',
//     'a***y [String]'
//     ],
//     mixed: [
//       'w**h [String]',
//       '******* [Boolean]',
//       [
//         'a*d [String]',
//         'd****y [String]',
//         'n****d [String]',
//         {
//           stuff: '*** [Number]'
//         }
//       ]
//     ],
//     num: '-1****.*1 [Number]',
//     str: 's**************g [String]',
//     blank: null
//   }
// }

Options

includeType

redact('lorem ipsum', {includeType: true}) // l*********m [String]
redact(123.4222, {includeType: true}) // 1**.***2 [Number]
redact(false, {includeType: true}) // ******* [Boolean]

char

redact('lorem ipsum', {char: '?'}) // l?????????m
redact(123.4222, {char: '^'}) // 1^^.^^^2
redact(false, {char: '!'}) // !!!!!!!

min

redact('lorem ipsum', {min: 15}) // ***************
redact(123, {min: 3}) // 1*3
redact(true, {min: 2}) // ******* (Boolean disallows `min` less than 7)

Keywords

FAQs

Package last updated on 09 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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