Skip to content

Commit

Permalink
documentation updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaly-t committed Jan 13, 2016
1 parent 04f7e27 commit 5328777
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,21 @@ tw.footer = '-footer';
tw.wrap('body'); //=> header-body-footer
```

See also: [grunt-file-wrap]
For bulk file processing see [grunt-file-wrap].

## API

### wrap(text, [options]) ⇒ String

Wraps the `text` with the current `header` + `footer`, according to the `options`, and returns the result.
Wraps the `text` with the current `header` + `footer`, according to the `options`, and returns the result.

By default, the header is added when it is not found within the `text`, or when there are non-empty symbols that precede it.
Accordingly, the footer is added when it is not found within the `text`, or when there are non-empty symbols that follow it.

Before the header or footer are searched for within `text`, they are trimmed first - all trailing empty symbols are removed
from them (spaces, tabs, line breaks). However, their full content is used when adding them.

Passing in a non-string value for the `text` will throw `Invalid text input.`

##### options.skipCheck ⇒ Boolean

Expand All @@ -64,9 +72,6 @@ Disables verification for duplicate header or footer.
* `false (default)` - add header + footer, if they are missing
* `true` - add header + footer regardless of their presence

By default, the header is added when it is not found within the `text`, or when there are non-empty symbols that precede it.
Accordingly, the footer is added when it is not found within the `text`, or when there are non-empty symbols that follow it.

Enabling this option is effectively switching off most of what this library does, which may be needed when processing
files in a bulk requires no verification for certain file types.

Expand All @@ -77,10 +82,6 @@ Enforces uniqueness of both header and footer within the `text`.
* `false (default)` - verify for non-empty symbols that precede the header or follow the footer
* `true` - ignore non-empty symbols, add header + footer only when not found

By default, if the header is found within the `text`, it will still be added, if any non-empty symbol is found that precede
the header - any symbol other than a space, a tab or a line break. Accordingly, the footer will be added even when it is
found, if it is followed by any non-empty symbol.

Enabling this option is to ignore non-empty symbols that precede the header or follow the footer, and add them only
when they are not found within the `text` at all.

Expand All @@ -90,10 +91,14 @@ NOTE: This option has no effect when option `skipCheck` is enabled.

Header text to be added, set to an empty string by default.

Setting it to a non-string value will throw `Invalid header content.`

### wrap.footer ⇒ String

Footer text to be added, set to an empty string by default.

Setting it to a non-string value will throw `Invalid footer content.`

### wrap.clear()

Resets content for both `header` and `footer` to empty strings.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "text-wrap",
"version": "0.1.0",
"version": "0.1.1",
"description": "Fast and efficient way to wrap your text with a header + footer.",
"main": "lib/index.js",
"scripts": {
Expand Down

0 comments on commit 5328777

Please sign in to comment.