htmlencode is a minimalist Node.js module, currently at version 0.0.5, designed to provide basic HTML encoding and decoding functionalities. It serves as a wrapper for the legacy client-side JavaScript library found at `strictly-software.com/htmlencode`, adapting it for server-side Node.js environments. The package introduced two key modifications to the original source: renaming the global `Encoder` object to `module.exports` for CommonJS compatibility and patching a global variable leak within the `htmlDecode` method. Given its low version number and the nature of its changes (primarily adapting an external, presumably old, client-side script for Node.js), the package appears to have had a very limited release cadence and is likely no longer actively maintained. It offers basic HTML entity conversion, supporting both named and numerical entities, configured either globally via the `EncodeType` property or through an `Encoder` class instance.
npm install htmlencodeVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic HTML encoding and decoding, global entity type changes, and instance-specific encoding using the Encoder class.
Migrate to a actively maintained and more robust HTML sanitization/encoding library like 'dompurify' or 'sanitize-html', or a dedicated encoding library like 'he'.
Ensure your project is configured for CommonJS, or use dynamic `import()` or `createRequire` from the `module` module to load it within an ESM context. Consider modern alternatives that support ESM.
Immediately replace this package with a security-audited and actively maintained library specifically designed for HTML sanitization or secure encoding, such as 'dompurify', 'sanitize-html', or 'he'.
If you must use this package, create a `declarations.d.ts` file with `declare module 'htmlencode';` or more specific type definitions. However, migrating to a typed alternative is recommended.
This package is CommonJS-only. Either convert your Node.js project or file to CommonJS (`.js` files treated as CJS, or explicitly `.cjs`), or use Node.js's `createRequire` utility in ESM to load it: `import { createRequire } from 'module'; const require = createRequire(import.meta.url); const htmlencode = require('htmlencode');`For CommonJS, use `const htmlencode = require('htmlencode');` to get the module object, then access its methods like `htmlencode.htmlEncode()`. Direct named imports are not supported for this package.No dependency data recorded yet.