Socket
Socket
Sign inDemoInstall

min-indent

Package Overview
Dependencies
0
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    min-indent

Get the shortest leading whitespace from lines in a string


Version published
Weekly downloads
17M
decreased by-0.77%
Maintainers
2
Install size
3.84 kB
Created
Weekly downloads
 

Package description

What is min-indent?

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.

What are min-indent's main functionalities?

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

Other packages similar to min-indent

Readme

Source

min-indent Build Status

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.

Install

$ npm install --save min-indent

Usage

const minIndent = require('min-indent');

const str = '\tunicorn\n\t\tcake';
/*
	unicorn
		cake
*/

minIndent(str); // 1

License

MIT © James Kyle

Keywords

FAQs

Last updated on 28 May 2020

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc