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

lib-redactor

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lib-redactor

Another library that will help you ██████ texts with ease.

  • 0.4.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
increased by300%
Maintainers
1
Weekly downloads
 
Created
Source

lib-redactor

Another library that will help you ██████ texts with ease.

GitHub Workflow Status WTFPL Known Vulnerabilities npm


Installation

npm install -S lib-redactor

Usage

import redactor from "lib-redactor";
  
const redactMe = {
  first_name: "John",
  last_name: "Doe",
  phone_number: "6969696969",
  email: "john.doe69@email.com"
};

const redactionRule = redactor(["phone_number", "email"]);

const redacted = redactionRule(redactMe);

console.log(redacted);
/// will log the following:
/// {
///   "first_name": "John",
///   "last_name": "Doe",
///   "phone_number: "6████████9",
///   "email": "j██████████████████m"
/// }

Changing mask character

import redactor from "lib-redactor";
  
const redactMe = {
  first_name: "John",
  last_name: "Doe",
  phone_number: "6969696969",
  email: "john.doe69@email.com"
};
const options = {
  maskCharacter: "X"
};
const redactionRule = redactor(["phone_number", "email"], options);

const redacted = redactionRule(redactMe);

console.log(redacted);
/// will log the following:
/// {
///   "first_name": "John",
///   "last_name": "Doe",
///   "phone_number: "6XXXXXXXX9",
///   "email": "jXXXXXXXXXXXXXXXXXXm"
/// }

Redacting based on supplied keywords or basic pattern

import redactor from "lib-redactor";
  

const redactMe = {
  phrase: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
}
;
const options = {
  maskCharacter: "X",
  fullRedaction: true,
  blacklistedWords: [
    /Lorem/g,
    "elit",
    "non",
    "dolor"
  ]
};
const redactionRule = redactor([], options);

const redacted = redactionRule(redactMe);

console.log(redacted);
/// will log the following:
/// {
///   "phrase_full": "XXXXX ipsum XXXXX sit amet, consectetur adipiscing XXXX, sed do eiusmod tempor incididunt ut labore et XXXXXe magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure XXXXX in reprehenderit in voluptate vXXXX esse cillum XXXXXe eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat XXX proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
/// }

License

lib-redactor is WTFPL licensed.

Keywords

FAQs

Package last updated on 26 Aug 2021

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