Socket
Socket
Sign inDemoInstall

collapse-white-space

Package Overview
Dependencies
0
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    collapse-white-space

Replace multiple white-space characters with a single space


Version published
Maintainers
1
Install size
5.34 kB
Created

Package description

What is collapse-white-space?

The collapse-white-space npm package is designed to reduce multiple whitespace characters in a string down to a single space, effectively 'collapsing' them. This can be particularly useful for cleaning up strings in web development contexts, such as user input or text content processing, where consistent whitespace handling is desired.

What are collapse-white-space's main functionalities?

Collapsing multiple whitespace characters

This feature allows you to take a string with multiple spaces, tabs, or other whitespace characters and reduce them to a single space between words or characters. It's particularly useful for text normalization.

"use strict";\nconst collapse = require('collapse-white-space');\nconst text = 'This    is  a    test string.';\nconsole.log(collapse(text)); // 'This is a test string.'

Other packages similar to collapse-white-space

Readme

Source

collapse-white-space

Build Coverage Downloads Size

Replace multiple whitespace characters with a single space.

Install

npm:

npm install collapse-white-space

Use

var collapse = require('collapse-white-space')

collapse('\tfoo \n\tbar  \t\r\nbaz') //=> ' foo bar baz'

API

collapse(value)

Replace multiple whitespace characters in value with a single space.

License

MIT © Titus Wormer

Keywords

FAQs

Last updated on 23 Jan 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