Installations
npm install word-wrap
Developer
Developer Guide
Module System
CommonJS
Min. Node Version
>=0.10.0
Typescript Support
No
Node Version
18.16.1
NPM Version
9.5.1
Statistics
196 Stars
73 Commits
59 Forks
6 Watching
2 Branches
14 Contributors
Updated on 27 Nov 2024
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
5,149,743,451
Last day
-1.9%
6,914,176
Compared to previous day
Last week
3.8%
38,493,309
Compared to previous week
Last month
25.5%
148,887,693
Compared to previous month
Last year
-8.3%
1,245,582,548
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
2
word-wrap
Wrap words to a specified length.
Please consider following this project's author, Jon Schlinkert, and consider starring the project to show your :heart: and support.
Install
Install with npm:
1$ npm install --save word-wrap
Usage
1var wrap = require('word-wrap'); 2 3wrap('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.');
Results in:
Lorem ipsum dolor sit amet, consectetur adipiscing
elit, sed do eiusmod tempor incididunt ut labore
et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat.
Options
options.width
Type: Number
Default: 50
The width of the text before wrapping to a new line.
Example:
1wrap(str, {width: 60});
options.indent
Type: String
Default: `` (two spaces)
The string to use at the beginning of each line.
Example:
1wrap(str, {indent: ' '});
options.newline
Type: String
Default: \n
The string to use at the end of each line.
Example:
1wrap(str, {newline: '\n\n'});
options.escape
Type: function
Default: function(str){return str;}
An escape function to run on each line after splitting them.
Example:
1var xmlescape = require('xml-escape'); 2wrap(str, { 3 escape: function(string){ 4 return xmlescape(string); 5 } 6});
options.trim
Type: Boolean
Default: false
Trim trailing whitespace from the returned string. This option is included since .trim()
would also strip the leading indentation from the first line.
Example:
1wrap(str, {trim: true});
options.cut
Type: Boolean
Default: false
Break a word between any two letters when the word is longer than the specified width.
Example:
1wrap(str, {cut: true});
About
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Running Tests
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
1$ npm install && npm test
Building docs
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
1$ npm install -g verbose/verb#dev verb-generate-readme && verb
Related projects
You might also be interested in these projects:
- common-words: Updated list (JSON) of the 100 most common words in the English language. Useful for… more | homepage
- shuffle-words: Shuffle the words in a string and optionally the letters in each word using the… more | homepage
- unique-words: Returns an array of unique words, or the number of occurrences of each word in… more | homepage
- wordcount: Count the words in a string. Support for english, CJK and Cyrillic. | homepage
Contributors
Commits | Contributor |
---|---|
47 | jonschlinkert |
7 | OlafConijn |
3 | doowb |
2 | aashutoshrathi |
2 | lordvlad |
2 | hildjj |
1 | danilosampaio |
1 | 2fd |
1 | leonard-thieu |
1 | mohd-akram |
1 | toddself |
1 | wolfgang42 |
1 | zachhale |
Author
Jon Schlinkert
License
Copyright © 2023, Jon Schlinkert. Released under the MIT License.
This file was generated by verb-generate-readme, v0.8.0, on July 22, 2023.
Stable Version
The latest stable version of the package.
Stable Version
1.2.5
MODERATE
1
5.3/10
Summary
word-wrap vulnerable to Regular Expression Denial of Service
Affected Versions
< 1.2.4
Patched Versions
1.2.4
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 5/18 approved changesets -- score normalized to 2
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/publish.yml:1
- Info: no jobLevel write permissions found
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:9: update your workflow using https://app.stepsecurity.io/secureworkflow/jonschlinkert/word-wrap/publish.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/jonschlinkert/word-wrap/publish.yml/master?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/publish.yml:16
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 npmCommand dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 17 are checked with a SAST tool
Score
3.6
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to word-wrap
postcss-replace-overflow-wrap
PostCSS plugin to replace overflow-wrap with word-wrap or optionally retain both declarations.
@aashutoshrathi/word-wrap
Wrap words to a specified length.
jp-wrap
Japanese word wrap
react-native-wrapped-text
react native word wrap text component for support korean