1.2.2 • Published 3 years ago

@spenserca/scrub-a-dub-dub v1.2.2

Weekly downloads
1
License
MIT
Repository
github
Last release
3 years ago

scrub-a-dub-dub

A utility for marking object properties for data sanitization

Usage

This library provides these defaults to apply during scrubbing:

typedefault
string****
number8675309
Date12/31/9999
all others****

You can use the default values by following these steps:

  1. For a given class mark properties that you want scrubbed with the @scrub decorator

    export class SomeClass {
      @scrub()
      propertyToScrub: string;
    
      constructor (message: string) {
        this.propertyToScrub = message;
      }
    }
  2. Scrub the object by calling scrubObject

    const scrubbed = scrubObject(new SomeClass('hello world'));
  3. Any properties that are marked should be scrubbed
    console.log(scrubbed.propertyToScrub); // logs the default scrubbed string '********' and not 'hello world'

Alternatively, you can provide your own scrubbing function to the decorator to override the default scrubbing methods:

  1. For a given class mark properties that you want scrubbed with the @scrub decorator

    export class SomeClass {
      @scrub({
        scrubFunction: () => 'spenser was not here'
      })
      propertyToScrub: string;
    
      constructor (message: string) {
        this.propertyToScrub = message;
      }
    }
  2. Scrub the object by calling scrubObject

    const scrubbed = scrubObject(new SomeClass('hello world'));
  3. Any properties that are marked should be scrubbed
    console.log(scrubbed.propertyToScrub); // logs the override's scrubbed string 'spenser was not here' and not 'hello world'
1.2.2

3 years ago

1.2.0

4 years ago

1.2.1

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.22

4 years ago

1.0.23

4 years ago

1.0.21

4 years ago

1.0.20

4 years ago

1.0.19

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago