str_shorten
Version:
Shorten string by character length with word boundary supported
2 lines • 2.91 kB
JavaScript
webpackJsonp([0],{588:function(n,t,e){var r=e(6),s=e(32),o=e(210).PageRenderer;o.__esModule&&(o=o.default);var i=s({displayName:"WrappedPageRenderer",getInitialState:function(){return{content:e(589)}},componentWillMount:function(){},render:function(){return r.createElement(o,Object.assign({},this.props,{content:this.state.content}))}});i.__catalog_loader__=!0,n.exports=i},589:function(n,t){n.exports='# str_shorten\n[](https://travis-ci.org/binhqd/str_shorten)\n[](https://www.bithound.io/github/binhqd/str_shorten)\n[](https://coveralls.io/r/binhqd/str_shorten?branch=master)\n[](https://www.bithound.io/github/binhqd/str_shorten/master/dependencies/npm)\n[](https://www.npmjs.com/package/str_shorten)\n[](https://www.npmjs.com/package/str_shorten)\n\nShorten string by character length with word boundary supported\n## NPM\nInstall the module with:\n```\nnpm install --save str_shorten\n```\n\n## Yarn\nInstall the module with:\n```\nyarn add str_shorten\n```\n\n## Usage\n```\nstr_shorten(string, maxChars, options)\n```\n\n### Options\n\n| name | default | required | type | description |\n|--------------|----------|--------|----------|-----------------------------------------------------------------------------------------------------------------|\n| wordBoundary | true | false | boolean | Indicate whether using word boundary or not. |\n| endSymbols | \'...\' | false | string | Symbols indicate there is more text. |\n\n## Example\n### Basic\n```javascript\nvar strShorten = require("str_shorten")\nvar str = "We will win if we want";\nvar shortenStr = strShorten(str, 11);\n```\nThe return value will be "We will win..."\n### Customize end symbols\n```javascript\nvar strShorten = require("str_shorten")\nvar str = "We will win if we want";\nvar shortenStr = strShorten(str, 11, {endSymbols: \' --\x3e\'});\n```\nThe return value will be "We will win --\x3e"\n### Without end symbols\n```javascript\nvar strShorten = require("str_shorten")\nvar str = "We will win if we want";\nvar shortenStr = strShorten(str, 11, {endSymbols: \'\'});\n```\nThe return value will be "We will win"\n\n[See Demo](https://runkit.com/binhqd/runkit-str-shorten)\n\n## License\nCopyright (c) 2018 Binh Quan\n\nLicensed under the MIT license.\n'}});
//# sourceMappingURL=0.900be5bf.chunk.js.map