You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+17-6Lines changed: 17 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,17 +6,28 @@ Remove personally identifiable information from text.
6
6
7
7
> This package is published on npm as [piiranha](https://www.npmjs.com/package/piiranha) and is maintained as a fork of the original [solvvy/redact-pii](https://github.com/solvvy/redact-pii) package.
8
8
9
-
### Prerequesites
9
+
### Prerequisites
10
10
11
-
This library is primarily written for node.js but it should work in the browser as well.
12
-
It is written in TypeScript and compiles to ES2017. The library makes use of `async` functions and hence needs node.js 8.0.0 or higher (or a modern browser).
11
+
This library is primarily written for Node.js, but also works in the browser with compatible tooling/runtime (such as Vite, Webpack, Rollup, Parcel, esbuild). A transpiler/build setup such as TypeScript compiler, Babel, or both, can be used to target older browser support.
12
+
It is written in TypeScript and currently compiles to ES2016.
13
+
The project is tested in CI on Node.js 18.x and 20.x.
13
14
14
15
### Simple example (synchronous API)
15
16
16
17
```
17
18
npm install piiranha
18
19
```
19
20
21
+
```js
22
+
import { SyncRedactor } from'piiranha';
23
+
constredactor=newSyncRedactor();
24
+
constredactedText=redactor.redact('Hi David Johnson, Please give me a call at 555-555-5555');
25
+
// Hi NAME, Please give me a call at PHONE_NUMBER
26
+
console.log(redactedText);
27
+
```
28
+
29
+
CommonJS equivalent:
30
+
20
31
```js
21
32
const { SyncRedactor } =require('piiranha');
22
33
constredactor=newSyncRedactor();
@@ -28,7 +39,7 @@ console.log(redactedText);
28
39
### Simple example (asynchronous / promise-based API)
29
40
30
41
```js
31
-
const { AsyncRedactor } =require('piiranha');
42
+
import { AsyncRedactor } from'piiranha';
32
43
constredactor=newAsyncRedactor();
33
44
redactor.redactAsync('Hi David Johnson, Please give me a call at 555-555-5555').then((redactedText) => {
34
45
// Hi NAME, Please give me a call at PHONE_NUMBER
@@ -61,7 +72,7 @@ redactor.redactAsync('Hi David Johnson, Please give me a call at 555-555-5555').
61
72
### Customize replacement values
62
73
63
74
```js
64
-
const { SyncRedactor } =require('piiranha');
75
+
import { SyncRedactor } from'piiranha';
65
76
66
77
// use a single replacement value for all built-in patterns found.
@@ -86,7 +97,7 @@ redactor.redact('Dear David Johnson');
86
97
Note that the order of redaction rules matters, therefore you have to decide whether you want your custom redaction rules to run `before` or `after` the built-in ones. Generally it's better to put very specialized patterns or functions `before` the built-in ones and more broad / general ones `after`.
0 commit comments