Registry / devops / string-minify

string-minify

JSON →
library1.0.1jsnpmunverified

string-minify is a minimal Node.js utility (v1.0.1) that removes extra whitespace, tabs, newlines, and trims strings. It's a single-function, zero-dependency module designed for simple string cleanup in Node.js >=8. Unlike full-fledged minifiers (e.g., UglifyJS, Terser), it only collapses whitespace and does not handle code syntax. Released under MIT, it is stable but not actively developed. Suitable for preprocessing text content.

npm install string-minify
INSTALL
IMPORT
SIG · STRING-MINIFY
S
string-minify
devopsjavascriptv1.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import minifier from 'string-minify'
import { minifier } from 'string-minify'
The module exports a single function as default; ES module import should not use named import.
default (require)
const minifier = require('string-minify')
const { minifier } = require('string-minify')
CommonJS require returns the function directly, not an object with a named property.
type import (TypeScript)
import minifier from 'string-minify'
import { minifier } from 'string-minify'
TypeScript users should use default import for the function; the package does not ship types.

Demonstrates basic usage: importing the minifier, passing a multi-line string with extra spaces, and verifying the result.

const minifier = require('string-minify'); const ugly = `Hello world! I am a string! `; const clean = minifier(ugly); console.log(clean); // "Hello world! I am a string!" console.log(clean === 'Hello world! I am a string!'); // true
Debug
Known issues
gotchaThe minifier removes all consecutive whitespace, including indentation and line breaks. If you need to preserve line breaks or indentation, do not use this package.
fix
Consider using a different tool or manually splitting the string before minification.
affects: >=0.0.0
gotchaOnly supports Node.js >=8; will fail on older versions without proper ES6 support.
fix
Upgrade Node.js to version 8 or later.
affects: >=0.0.0
gotchaNo TypeScript type definitions provided; TypeScript users must create their own or use a declaration file.
fix
Add a global type declaration: declare module 'string-minify';
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: minifier is not a function
Using named import on ES modules or destructuring require incorrectly.
fix
Use default import: import minifier from 'string-minify' or const minifier = require('string-minify');
Cannot find module 'string-minify'
Package not installed or not in node_modules.
fix
Run: npm install string-minify
Unexpected token function
Using ES module syntax (import) in a CommonJS environment without proper transpilation.
fix
Use require('string-minify') instead of import.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Resources
string-minify — npm install string-minify · libregistry