dirty-compact is a utility package designed to compact databases created by node-dirty, a flat-file, newline-separated JSON key-value store. Last published over 12 years ago at version 0.0.2, it is tightly coupled with node-dirty, which itself has seen no updates since 2014. Both packages are long-abandoned, meaning they receive no active development, bug fixes, or security patches. They were intended for small-scale applications, typically under 1 million records, and lack modern features like ES module support, TypeScript types, or robust error handling. Due to their age and unmaintained status, they are highly susceptible to compatibility issues with current Node.js versions and present significant security vulnerabilities.
npm install dirty-compactVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to use `dirty-compact` to compact a `node-dirty` database file. It first creates a simple dummy database with some overwritten entries and then uses the `compact` function to optimize it, removing redundant data and saving the original as a backup. It highlights the CommonJS `require` syntax necessary for this package.
Avoid using this package for new projects. Consider modern, actively maintained alternatives for key-value storage or flat-file databases.
Ensure your project is configured for CommonJS, or manually `require()` the module in an older Node.js environment. For new projects, use modern packages with ESM support.
Do not use in production environments. If absolutely necessary for legacy systems, isolate it heavily and consider alternatives for data storage.
Evaluate your data storage needs. For more than ~1 million records, or for any production use, choose a robust, actively maintained database solution.
Always back up your database files before running any compaction. Implement robust error handling and verification steps if this package must be used.
Change your import statement to `const compact = require('dirty-compact').compact;` and ensure your file is treated as CommonJS (e.g., `.js` extension with `"type": "commonjs"` in `package.json`, or an older Node.js version).Ensure you are accessing the named export `compact` correctly: `const { compact } = require('dirty-compact');` or `const dirtyCompact = require('dirty-compact'); const compact = dirtyCompact.compact;`.Verify that the user running the Node.js application has the necessary file system permissions (read and write) for both the source and backup database files and their containing directories.