@gustavnikolaj/string-utils
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.collapse = exports.deindent = void 0; | ||
exports.reflow = exports.collapse = exports.deindent = void 0; | ||
@@ -13,2 +13,4 @@ var _deindent2 = _interopRequireDefault(require("./deindent")); | ||
var _reflow2 = _interopRequireDefault(require("./reflow")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -19,2 +21,4 @@ | ||
var collapse = _collapse2.default; | ||
exports.collapse = collapse; | ||
exports.collapse = collapse; | ||
var reflow = _reflow2.default; | ||
exports.reflow = reflow; |
{ | ||
"name": "@gustavnikolaj/string-utils", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Template string utilities", | ||
@@ -9,3 +9,4 @@ "main": "index.js", | ||
"collapse.js", | ||
"deindent.js" | ||
"deindent.js", | ||
"reflow.js" | ||
], | ||
@@ -31,2 +32,3 @@ "scripts": { | ||
"babel-plugin-add-module-exports": "^1.0.0", | ||
"coveralls": "^3.0.2", | ||
"eslint": "^5.9.0", | ||
@@ -33,0 +35,0 @@ "eslint-config-pretty-standard": "^2.0.0", |
# Template String Utilities | ||
[![npm version](https://badge.fury.io/js/%40gustavnikolaj%2Fstring-utils.svg)](https://www.npmjs.com/package/@gustavnikolaj/string-utils) | ||
[![Build Status](https://travis-ci.com/gustavnikolaj/string-utils.svg?branch=master)](https://travis-ci.com/gustavnikolaj/string-utils) | ||
[![Coverage Status](https://coveralls.io/repos/github/gustavnikolaj/string-utils/badge.svg?branch=master)](https://coveralls.io/github/gustavnikolaj/string-utils?branch=master) | ||
@@ -69,1 +71,49 @@ ## deindent | ||
``` | ||
## reflow | ||
Strips indentation as deindent, but will persist paragraphs (separated by double | ||
newlines like in markdown) and reflow the paragraphs so that they fit within a | ||
defined width. | ||
```js | ||
import { reflow } from "@gustavnikolaj/string-utils"; | ||
console.log(reflow(8)` | ||
foo bar qux baz foo bar | ||
`); // => "foo bar\nqux baz\nfoo bar" | ||
console.log(reflow(80)` | ||
foo bar | ||
qux baz | ||
`); // => "foo bar\n\nqux baz" | ||
console.log(reflow(30)` | ||
This is a very long string that is for sure longer than 30 characters. | ||
This is a very long string that is for sure longer than 30 characters. | ||
`); | ||
/* => This is a very long string | ||
that is for sure longer than | ||
30 characters. | ||
This is a very long string | ||
that is for sure longer than | ||
30 characters. */ | ||
``` | ||
It also supports being called as a regular non-template-string function: | ||
```js | ||
reflow( | ||
"This is a very long string that is for sure longer than 30 characters.", | ||
30 | ||
); | ||
``` | ||
Can also be required directly: | ||
```js | ||
import reflow from "@gustavnikolaj/string-utils/reflow"; | ||
``` |
12605
6
223
119
14