租房小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

200 lines
6.2 KiB

3 months ago
  1. # word-wrap [![NPM version](https://img.shields.io/npm/v/word-wrap.svg?style=flat)](https://www.npmjs.com/package/word-wrap) [![NPM monthly downloads](https://img.shields.io/npm/dm/word-wrap.svg?style=flat)](https://npmjs.org/package/word-wrap) [![NPM total downloads](https://img.shields.io/npm/dt/word-wrap.svg?style=flat)](https://npmjs.org/package/word-wrap) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/word-wrap.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/word-wrap)
  2. > Wrap words to a specified length.
  3. Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
  4. ## Install
  5. Install with [npm](https://www.npmjs.com/):
  6. ```sh
  7. $ npm install --save word-wrap
  8. ```
  9. ## Usage
  10. ```js
  11. var wrap = require('word-wrap');
  12. wrap('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.');
  13. ```
  14. Results in:
  15. ```
  16. Lorem ipsum dolor sit amet, consectetur adipiscing
  17. elit, sed do eiusmod tempor incididunt ut labore
  18. et dolore magna aliqua. Ut enim ad minim veniam,
  19. quis nostrud exercitation ullamco laboris nisi ut
  20. aliquip ex ea commodo consequat.
  21. ```
  22. ## Options
  23. ![image](https://cloud.githubusercontent.com/assets/383994/6543728/7a381c08-c4f6-11e4-8b7d-b6ba197569c9.png)
  24. ### options.width
  25. Type: `Number`
  26. Default: `50`
  27. The width of the text before wrapping to a new line.
  28. **Example:**
  29. ```js
  30. wrap(str, {width: 60});
  31. ```
  32. ### options.indent
  33. Type: `String`
  34. Default: `` (two spaces)
  35. The string to use at the beginning of each line.
  36. **Example:**
  37. ```js
  38. wrap(str, {indent: ' '});
  39. ```
  40. ### options.newline
  41. Type: `String`
  42. Default: `\n`
  43. The string to use at the end of each line.
  44. **Example:**
  45. ```js
  46. wrap(str, {newline: '\n\n'});
  47. ```
  48. ### options.escape
  49. Type: `function`
  50. Default: `function(str){return str;}`
  51. An escape function to run on each line after splitting them.
  52. **Example:**
  53. ```js
  54. var xmlescape = require('xml-escape');
  55. wrap(str, {
  56. escape: function(string){
  57. return xmlescape(string);
  58. }
  59. });
  60. ```
  61. ### options.trim
  62. Type: `Boolean`
  63. Default: `false`
  64. Trim trailing whitespace from the returned string. This option is included since `.trim()` would also strip the leading indentation from the first line.
  65. **Example:**
  66. ```js
  67. wrap(str, {trim: true});
  68. ```
  69. ### options.cut
  70. Type: `Boolean`
  71. Default: `false`
  72. Break a word between any two letters when the word is longer than the specified width.
  73. **Example:**
  74. ```js
  75. wrap(str, {cut: true});
  76. ```
  77. ## About
  78. <details>
  79. <summary><strong>Contributing</strong></summary>
  80. Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
  81. </details>
  82. <details>
  83. <summary><strong>Running Tests</strong></summary>
  84. 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:
  85. ```sh
  86. $ npm install && npm test
  87. ```
  88. </details>
  89. <details>
  90. <summary><strong>Building docs</strong></summary>
  91. _(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
  92. To generate the readme, run the following command:
  93. ```sh
  94. $ npm install -g verbose/verb#dev verb-generate-readme && verb
  95. ```
  96. </details>
  97. ### Related projects
  98. You might also be interested in these projects:
  99. * [common-words](https://www.npmjs.com/package/common-words): Updated list (JSON) of the 100 most common words in the English language. Useful for… [more](https://github.com/jonschlinkert/common-words) | [homepage](https://github.com/jonschlinkert/common-words "Updated list (JSON) of the 100 most common words in the English language. Useful for excluding these words from arrays.")
  100. * [shuffle-words](https://www.npmjs.com/package/shuffle-words): Shuffle the words in a string and optionally the letters in each word using the… [more](https://github.com/jonschlinkert/shuffle-words) | [homepage](https://github.com/jonschlinkert/shuffle-words "Shuffle the words in a string and optionally the letters in each word using the Fisher-Yates algorithm. Useful for creating test fixtures, benchmarking samples, etc.")
  101. * [unique-words](https://www.npmjs.com/package/unique-words): Returns an array of unique words, or the number of occurrences of each word in… [more](https://github.com/jonschlinkert/unique-words) | [homepage](https://github.com/jonschlinkert/unique-words "Returns an array of unique words, or the number of occurrences of each word in a string or list.")
  102. * [wordcount](https://www.npmjs.com/package/wordcount): Count the words in a string. Support for english, CJK and Cyrillic. | [homepage](https://github.com/jonschlinkert/wordcount "Count the words in a string. Support for english, CJK and Cyrillic.")
  103. ### Contributors
  104. | **Commits** | **Contributor** |
  105. | --- | --- |
  106. | 47 | [jonschlinkert](https://github.com/jonschlinkert) |
  107. | 7 | [OlafConijn](https://github.com/OlafConijn) |
  108. | 3 | [doowb](https://github.com/doowb) |
  109. | 2 | [aashutoshrathi](https://github.com/aashutoshrathi) |
  110. | 2 | [lordvlad](https://github.com/lordvlad) |
  111. | 2 | [hildjj](https://github.com/hildjj) |
  112. | 1 | [danilosampaio](https://github.com/danilosampaio) |
  113. | 1 | [2fd](https://github.com/2fd) |
  114. | 1 | [leonard-thieu](https://github.com/leonard-thieu) |
  115. | 1 | [mohd-akram](https://github.com/mohd-akram) |
  116. | 1 | [toddself](https://github.com/toddself) |
  117. | 1 | [wolfgang42](https://github.com/wolfgang42) |
  118. | 1 | [zachhale](https://github.com/zachhale) |
  119. ### Author
  120. **Jon Schlinkert**
  121. * [GitHub Profile](https://github.com/jonschlinkert)
  122. * [Twitter Profile](https://twitter.com/jonschlinkert)
  123. * [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
  124. ### License
  125. Copyright © 2023, [Jon Schlinkert](https://github.com/jonschlinkert).
  126. Released under the [MIT License](LICENSE).
  127. ***
  128. _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on July 22, 2023._