
Security News
CISA Kills Off RSS Feeds for KEVs and Cyber Alerts
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
The min-indent npm package is designed to determine the smallest indentation of non-empty lines in a given string. This is particularly useful in scenarios where consistent text formatting is required, or when preparing text for further processing that is sensitive to leading whitespace.
Detect minimum indentation
This feature allows you to find the smallest number of leading spaces in a multi-line string. It's useful for adjusting the text indentation level or preprocessing before rendering in UI components.
const minIndent = require('min-indent');
const sampleText = ` line one
line two
line three`;
const minimumIndentation = minIndent(sampleText);
console.log(minimumIndentation); // Outputs: 2
Similar to min-indent, strip-indent removes the common leading whitespace from each line in a string. The main difference is that strip-indent modifies the string to normalize indentation, whereas min-indent only calculates the minimum indentation without altering the original string.
While min-indent is used to detect indentation, indent-string is used to add or increase indentation to a string. This package can be seen as a complementary tool to min-indent, where one measures and the other modifies indentation.
Get the shortest leading whitespace from lines in a string
The line with the least number of leading whitespace, ignoring empty lines, determines the number.
Useful for removing redundant indentation.
$ npm install --save min-indent
const minIndent = require('min-indent');
const str = '\tunicorn\n\t\tcake';
/*
unicorn
cake
*/
minIndent(str); // 1
MIT © James Kyle
FAQs
Get the shortest leading whitespace from lines in a string
We found that min-indent demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.