|
1 |
| -# wrapper |
2 |
| -Wrap the text with the opening and closing chars. |
| 1 | + |
| 2 | +<a href="https://www.typescriptlang.org/"> |
| 3 | + <img |
| 4 | + src="https://raw.githubusercontent.com/typescript-package/core/refs/heads/main/ts-package-barcode-logo-512.png" |
| 5 | + width="20%" |
| 6 | + title="@typescript-package/wrapper" |
| 7 | + /> |
| 8 | +</a> |
| 9 | + |
| 10 | +## typescript-package/wrapper |
| 11 | + |
| 12 | +A lightweight TypeScript library to wrap the text with the opening and closing chars. |
| 13 | + |
| 14 | +<!-- npm badge --> |
| 15 | +[![npm version][typescript-package-npm-badge-svg]][typescript-package-npm-badge] |
| 16 | +[![GitHub issues][typescript-package-badge-issues]][typescript-package-issues] |
| 17 | +[![GitHub license][typescript-package-badge-license]][typescript-package-license] |
| 18 | + |
| 19 | +<br> |
| 20 | + |
| 21 | +## Table of contents |
| 22 | + |
| 23 | +* [Installation](#installation) |
| 24 | +* [Api](#api) |
| 25 | +* [Git](#git) |
| 26 | + * [Commit](#commit) |
| 27 | + * [Versioning](#versioning) |
| 28 | +* [License](#license) |
| 29 | + |
| 30 | +## Installation |
| 31 | + |
| 32 | +```bash |
| 33 | +npm install @typescript-package/wrapper |
| 34 | +``` |
| 35 | + |
| 36 | +## Api |
| 37 | + |
| 38 | +```typescript |
| 39 | +import { |
| 40 | + // Object. |
| 41 | + Wrap, |
| 42 | + Wrapper, |
| 43 | + // Type |
| 44 | + Wrapped |
| 45 | +} from '@typescript-package/wrapper'; |
| 46 | +``` |
| 47 | + |
| 48 | +### `Wrap` |
| 49 | + |
| 50 | +```typescript |
| 51 | +import { Wrap } from "@typescript-package/wrapper"; |
| 52 | + |
| 53 | +// Initialize. |
| 54 | +const htmlTag = new Wrap('<', '>', 'div'); |
| 55 | + |
| 56 | +// The `Wrap` object. |
| 57 | +console.log(htmlTag); // Output: Wrap {'<div>', #closing: '>', #opening: '<', #text: 'div'} |
| 58 | + |
| 59 | +console.log(htmlTag.valueOf()); // Output: <div> |
| 60 | + |
| 61 | +// Initialize. |
| 62 | +const bbCode = new Wrap('[', ']', 'quote'); |
| 63 | + |
| 64 | +console.log(bbCode); // Output: Wrap {'[quote]', #closing: ']', #opening: '[', #text: 'quote'} |
| 65 | + |
| 66 | +console.log(bbCode.valueOf()); // Output: [quote] |
| 67 | +``` |
| 68 | + |
| 69 | +### `Wrapper` |
| 70 | + |
| 71 | +```typescript |
| 72 | +import { Wrapper } from "@typescript-package/wrapper"; |
| 73 | + |
| 74 | +// Initialize. |
| 75 | +const htmlTag = new Wrapper( |
| 76 | + '<', |
| 77 | + '>', |
| 78 | + 'div' |
| 79 | +); |
| 80 | + |
| 81 | +// The `Wrap` object. |
| 82 | +console.log(htmlTag); // Output: Wrapper {'<div>', #closing: '>', #opening: '<', #text: 'div'} |
| 83 | + |
| 84 | +console.log(htmlTag.valueOf()); // Output: <div> |
| 85 | + |
| 86 | +// Initialize. |
| 87 | +const bbCode = new Wrapper('[', ']', 'quote'); |
| 88 | + |
| 89 | +console.log(bbCode); // Output: Wrapper {'[quote]', #closing: ']', #opening: '[', #text: 'quote'} |
| 90 | + |
| 91 | +// Wrap the valueOf [quote] |
| 92 | +console.log(bbCode.wrap()); // Output: [[quote]] |
| 93 | + |
| 94 | +// Wrap the valueOf [quote] with the specified `opening` and `closing` chars. |
| 95 | +console.log(bbCode.wrap(`(`, `)`)); // Output: ([quote]) |
| 96 | + |
| 97 | +// Wrap the specified text with the `opening` and `closing` chars. |
| 98 | +console.log(bbCode.wrapOn(`/italic`)); // Output: [/italic] |
| 99 | + |
| 100 | +// Replace the `opening` and `closing` chars. |
| 101 | +console.log(bbCode.rewrap(`(`, `)`)); // Output: (quote) |
| 102 | + |
| 103 | +// Wraps the `text` inside. |
| 104 | +console.log(bbCode.wrapText(`(`, `)`)); // Output: [(quote)] |
| 105 | + |
| 106 | +// Returns the primitive value. |
| 107 | +console.log(bbCode.valueOf()); // Output: [quote] |
| 108 | +``` |
| 109 | + |
| 110 | +## GIT |
| 111 | + |
| 112 | +### Commit |
| 113 | + |
| 114 | +* [AngularJS Git Commit Message Conventions][git-commit-angular] |
| 115 | +* [Karma Git Commit Msg][git-commit-karma] |
| 116 | +* [Conventional Commits][git-commit-conventional] |
| 117 | + |
| 118 | +### Versioning |
| 119 | + |
| 120 | +[Semantic Versioning 2.0.0][git-semver] |
| 121 | + |
| 122 | +**Given a version number MAJOR.MINOR.PATCH, increment the:** |
| 123 | + |
| 124 | +* MAJOR version when you make incompatible API changes, |
| 125 | +* MINOR version when you add functionality in a backwards-compatible manner, and |
| 126 | +* PATCH version when you make backwards-compatible bug fixes. |
| 127 | + |
| 128 | +Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format. |
| 129 | + |
| 130 | +**FAQ** |
| 131 | +How should I deal with revisions in the 0.y.z initial development phase? |
| 132 | + |
| 133 | +> The simplest thing to do is start your initial development release at 0.1.0 and then increment the minor version for each subsequent release. |
| 134 | +
|
| 135 | +How do I know when to release 1.0.0? |
| 136 | + |
| 137 | +> If your software is being used in production, it should probably already be 1.0.0. If you have a stable API on which users have come to depend, you should be 1.0.0. If you’re worrying a lot about backwards compatibility, you should probably already be 1.0.0. |
| 138 | +
|
| 139 | +## License |
| 140 | + |
| 141 | +MIT © typescript-package ([license][typescript-package-license]) |
| 142 | + |
| 143 | +<!-- This package: typescript-package --> |
| 144 | + <!-- GitHub: badges --> |
| 145 | + [typescript-package-badge-issues]: https://img.shields.io/github/issues/typescript-package/wrapper |
| 146 | + [isscript-package-badge-forks]: https://img.shields.io/github/forks/typescript-package/wrapper |
| 147 | + [typescript-package-badge-stars]: https://img.shields.io/github/stars/typescript-package/wrapper |
| 148 | + [typescript-package-badge-license]: https://img.shields.io/github/license/typescript-package/wrapper |
| 149 | + <!-- GitHub: badges links --> |
| 150 | + [typescript-package-issues]: https://github.com/typescript-package/wrapper/issues |
| 151 | + [typescript-package-forks]: https://github.com/typescript-package/wrapper/network |
| 152 | + [typescript-package-license]: https://github.com/typescript-package/wrapper/blob/master/LICENSE |
| 153 | + [typescript-package-stars]: https://github.com/typescript-package/wrapper/stargazers |
| 154 | +<!-- This package --> |
| 155 | + |
| 156 | +<!-- Package: typescript-package --> |
| 157 | + <!-- npm --> |
| 158 | + [typescript-package-npm-badge-svg]: https://badge.fury.io/js/@typescript-package%2Fwrapper.svg |
| 159 | + [typescript-package-npm-badge]: https://badge.fury.io/js/@typescript-package%2Fwrapper |
| 160 | + |
| 161 | +<!-- GIT --> |
| 162 | +[git-semver]: http://semver.org/ |
| 163 | + |
| 164 | +<!-- GIT: commit --> |
| 165 | +[git-commit-angular]: https://gist.github.com/stephenparish/9941e89d80e2bc58a153 |
| 166 | +[git-commit-karma]: http://karma-runner.github.io/0.10/dev/git-commit-msg.html |
| 167 | +[git-commit-conventional]: https://www.conventionalcommits.org/en/v1.0.0/ |
0 commit comments