@hackylabs/deep-redact
Advanced tools
Comparing version 2.0.1 to 2.0.2
{ | ||
"name": "@hackylabs/deep-redact", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "A fast, safe and configurable zero-dependency library for redacting strings or deeply redacting arrays and objects.", | ||
@@ -12,2 +12,17 @@ "private": false, | ||
"module": "./dist/esm/index.mjs", | ||
"exports": { | ||
".": { | ||
"import": "./dist/esm/index.mjs", | ||
"require": "./dist/cjs/index.js", | ||
"types": "./dist/types/index.d.ts" | ||
}, | ||
"./utils/redactorUtils": { | ||
"import": "./dist/esm/utils/redactorUtils.mjs", | ||
"require": "./dist/cjs/utils/redactorUtils.js", | ||
"types": "./dist/types/utils/redactorUtils.d.ts" | ||
} | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"keywords": [ | ||
@@ -30,15 +45,5 @@ "redact", | ||
], | ||
"exports": { | ||
".": { | ||
"import": "./dist/esm/index.js", | ||
"require": "./dist/cjs/index.js", | ||
"types": "./dist/types/index.d.ts" | ||
} | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/hackylabs/deep-redact" | ||
"url": "git+https://github.com/hackylabs/deep-redact" | ||
}, | ||
@@ -58,6 +63,7 @@ "scripts": { | ||
"//": [ | ||
"fast-redact installed only as a benchmark comparison and is not used in the library", | ||
"fast-redact and obglob are installed only as benchmark comparisons and are not used in the library", | ||
"all dependencies are for development purposes only" | ||
], | ||
"devDependencies": { | ||
"@hackylabs/obglob": "1.1.2", | ||
"@memlab/core": "1.1.34", | ||
@@ -77,5 +83,6 @@ "@types/fast-redact": "3.0.4", | ||
"image-charts": "6.1.19", | ||
"typescript": "5.5.4", | ||
"superjson": "2.2.1", | ||
"typescript": "5.6.2", | ||
"vitest": "2.0.4" | ||
} | ||
} |
# Deep Redact | ||
[![npm version](https://badge.fury.io/js/@hackylabs%2Fdeep-redact.svg)](https://badge.fury.io/js/@hackylabs%2Fdeep-redact) | ||
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/hackylabs/deep-redact/blob/main/LICENSE) | ||
Faster than Fast Redact <sup>1</sup> as well as being safer and more configurable than many other redaction libraries, | ||
@@ -14,2 +17,4 @@ Deep Redact is a zero-dependency tool that redacts sensitive information from strings and objects. It is designed to be | ||
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/hackylabs) | ||
## Installation | ||
@@ -86,12 +91,22 @@ | ||
### Benchmark | ||
Comparisons are made against JSON.stringify and Fast Redact as well as different configurations of Deep Redact, using | ||
[this test object](./test/setup/dummyUser.ts). Fast Redact was configured to redact the same keys on the same object as | ||
Deep Redact without using wildcards. | ||
Comparisons are made against JSON.stringify, Regex.replace, Fast Redact & | ||
(one of my other creations, [@hackylabs/obglob](https://npmjs.com/package/@hackylabs/obglob)) as well as different | ||
configurations of Deep Redact, using [this test object](./test/setup/dummyUser.ts). Fast Redact was configured to redact | ||
the same keys on the same object as Deep Redact without using wildcards. | ||
The benchmark is run on a 2021 iMac with an M1 chip with 16GB memory running Sonoma 14.5. | ||
The benchmark is run on a 2021 iMac with an M1 chip with 16GB memory running macOS Sequoia 15.0.0. | ||
JSON.stringify is included as a benchmark because it is the fastest way to deeply iterate over an object although it | ||
doesn't redact any sensitive information. Fast-redact is included as a benchmark because it's the next fastest redaction | ||
library available. Neither JSON.stringify nor Fast Redact offer the same level of configurability as deep-redact. | ||
JSON.stringify is included as a benchmark because it is the fastest way to deeply iterate over an object, although it | ||
doesn't redact any sensitive information. | ||
Regex.replace is included as a benchmark because it is the fastest way to redact sensitive information from a string. | ||
However, a regex pattern for all keys to be redacted is much harder to configure than a dedicated redaction library, | ||
especially when dealing with multiple types of values. It also doesn't handle circular references or other unsupported | ||
values as gracefully as deep-redact unless a third-party library is used to stringify the object beforehand. | ||
Fast-redact is included as a benchmark because it's the next fastest library available specifically for redaction. | ||
Neither JSON.stringify, Regex.replace nor Fast Redact offer the same level of configurability as deep-redact. Both Fast | ||
Redact and Obglob are slower and rely on dependencies. | ||
![Benchmark](./benchmark.png) | ||
@@ -101,15 +116,19 @@ | ||
| --- | --- | --- | --- | --- | | ||
| JSON.stringify, large object | 295500.62 | 0.0033840876 | 0.00002 | 147751 | | ||
| DeepRedact, remove item, single object | 36272.4 | 0.0275691709 | 0.00016 | 18137 | | ||
| DeepRedact, custom replacer function, single object | 30314.59 | 0.0329874115 | 0.00028 | 15158 | | ||
| DeepRedact, default config, large object | 30028.19 | 0.0333020395 | 0.0002 | 15015 | | ||
| DeepRedact, replace string by length, single object | 28756.9 | 0.0347742688 | 0.00028 | 14379 | | ||
| DeepRedact, retain structure, single object | 24803.01 | 0.0403176903 | 0.00032 | 12402 | | ||
| DeepRedact, fuzzy matching, single object | 22243.3 | 0.0449573621 | 0.00038 | 11122 | | ||
| DeepRedact, config per key, single object | 21603.85 | 0.0462880355 | 0.0013 | 10802 | | ||
| fast redact, large object | 9529.2 | 0.1049406557 | 0.00064 | 4765 | | ||
| DeepRedact, case insensitive matching, single object | 6503.72 | 0.1537581959 | 0.00105 | 3252 | | ||
| DeepRedact, default config, 1000 large objects | 5915.05 | 0.1690602382 | 0.00296 | 2958 | | ||
| DeepRedact, fuzzy and case insensitive matching, single object | 5591.96 | 0.1788283015 | 0.00184 | 2796 | | ||
| JSON.stringify, 1000 large objects | 394.41 | 2.5354059248 | 0.01001 | 198 | | ||
| fast redact, 1000 large objects | 172.23 | 5.8060829174 | 0.06886 | 87 | | ||
| JSON.stringify, large object | 161827.79 | 0.0061794083 | 0.00002 | 80914 | | ||
| DeepRedact, remove item, single object | 26010.46 | 0.0384460656 | 0.00016 | 13006 | | ||
| DeepRedact, custom replacer function, single object | 22412.54 | 0.0446178767 | 0.00031 | 11207 | | ||
| DeepRedact, replace string by length, single object | 22323.79 | 0.044795253 | 0.00024 | 11162 | | ||
| DeepRedact, default config, large object | 21932.77 | 0.0455938725 | 0.00025 | 10967 | | ||
| Regex replace, large object | 21919.75 | 0.0456209497 | 0.00027 | 10960 | | ||
| DeepRedact, retain structure, single object | 18417.65 | 0.0542957469 | 0.00024 | 9212 | | ||
| DeepRedact, fuzzy matching, single object | 17428.25 | 0.0573781129 | 0.00028 | 8715 | | ||
| DeepRedact, config per key, single object | 16975.98 | 0.0589067685 | 0.00033 | 8488 | | ||
| DeepRedact, default config, 1000 large objects | 7787.76 | 0.1284065968 | 0.00319 | 3894 | | ||
| fast redact, large object | 5847.55 | 0.1710116908 | 0.00143 | 2924 | | ||
| DeepRedact, case insensitive matching, single object | 5136.64 | 0.1946798809 | 0.00152 | 2569 | | ||
| ObGlob, large object | 5083.79 | 0.1967037628 | 0.01079 | 2542 | | ||
| DeepRedact, fuzzy and case insensitive matching, single object | 4819.04 | 0.2075101033 | 0.00142 | 2410 | | ||
| JSON.stringify, 1000 large objects | 226.71 | 4.4109355351 | 0.04147 | 114 | | ||
| ObGlob, 1000 large objects | 164.41 | 6.0825151928 | 0.15338 | 83 | | ||
| fast redact, 1000 large objects | 121.82 | 8.2088192787 | 0.09619 | 61 | | ||
| Regex replace, 1000 large objects | 94.57 | 10.5740055833 | 0.30159 | 48 | |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
60021
131
18