update socials section
This commit is contained in:
116
node_modules/cli-truncate/index.d.ts
generated
vendored
Normal file
116
node_modules/cli-truncate/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,116 @@
|
||||
export interface Options {
|
||||
/**
|
||||
The position to truncate the string.
|
||||
|
||||
@default 'end'
|
||||
*/
|
||||
readonly position?: 'start' | 'middle' | 'end';
|
||||
|
||||
/**
|
||||
Add a space between the text and the ellipsis.
|
||||
|
||||
@default false
|
||||
|
||||
@example
|
||||
```
|
||||
import cliTruncate from 'cli-truncate';
|
||||
|
||||
cliTruncate('unicorns', 5, {position: 'end', space: true});
|
||||
//=> 'uni …'
|
||||
|
||||
cliTruncate('unicorns', 5, {position: 'end', space: false});
|
||||
//=> 'unic…'
|
||||
|
||||
cliTruncate('unicorns', 6, {position: 'start', space: true});
|
||||
//=> '… orns'
|
||||
|
||||
cliTruncate('unicorns', 7, {position: 'middle', space: true});
|
||||
//=> 'uni … s'
|
||||
```
|
||||
*/
|
||||
readonly space?: boolean;
|
||||
|
||||
/**
|
||||
Truncate the string from a whitespace if it is within 3 characters from the actual breaking point.
|
||||
|
||||
@default false
|
||||
|
||||
@example
|
||||
```
|
||||
import cliTruncate from 'cli-truncate';
|
||||
|
||||
cliTruncate('unicorns rainbow dragons', 20, {position: 'start', preferTruncationOnSpace: true});
|
||||
//=> '…rainbow dragons'
|
||||
|
||||
cliTruncate('unicorns rainbow dragons', 20, {position: 'middle', preferTruncationOnSpace: true});
|
||||
//=> 'unicorns…dragons'
|
||||
|
||||
cliTruncate('unicorns rainbow dragons', 6, {position: 'end', preferTruncationOnSpace: true});
|
||||
//=> 'unico…'
|
||||
````
|
||||
*/
|
||||
readonly preferTruncationOnSpace?: boolean;
|
||||
|
||||
/**
|
||||
The character to use at the breaking point.
|
||||
|
||||
@default '…'
|
||||
|
||||
@example
|
||||
```
|
||||
import cliTruncate from 'cli-truncate';
|
||||
|
||||
cliTruncate('unicorns', 5, {position: 'end'});
|
||||
//=> 'unic…'
|
||||
|
||||
cliTruncate('unicorns', 5, {position: 'end', truncationCharacter: '.'});
|
||||
//=> 'unic.'
|
||||
|
||||
cliTruncate('unicorns', 5, {position: 'end', truncationCharacter: ''});
|
||||
//=> 'unico'
|
||||
*/
|
||||
readonly truncationCharacter?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
Truncate a string to a specific width in the terminal.
|
||||
|
||||
@param text - Text to truncate.
|
||||
@param columns - The number of columns to occupy in the terminal.
|
||||
|
||||
@example
|
||||
```
|
||||
import cliTruncate from 'cli-truncate';
|
||||
|
||||
cliTruncate('unicorn', 4);
|
||||
//=> 'uni…'
|
||||
|
||||
// Truncate at different positions
|
||||
cliTruncate('unicorn', 4, {position: 'start'});
|
||||
//=> '…orn'
|
||||
|
||||
cliTruncate('unicorn', 4, {position: 'middle'});
|
||||
//=> 'un…n'
|
||||
|
||||
cliTruncate('\u001B[31municorn\u001B[39m', 4);
|
||||
//=> '\u001B[31muni\u001B[39m…'
|
||||
|
||||
// Truncate Unicode surrogate pairs
|
||||
cliTruncate('uni\uD83C\uDE00corn', 5);
|
||||
//=> 'uni\uD83C\uDE00…'
|
||||
|
||||
// Truncate fullwidth characters
|
||||
cliTruncate('안녕하세요', 3);
|
||||
//=> '안…'
|
||||
|
||||
// Truncate the paragraph to the terminal width
|
||||
const paragraph = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa.';
|
||||
cliTruncate(paragraph, process.stdout.columns));
|
||||
//=> 'Lorem ipsum dolor sit amet, consectetuer adipiscing…'
|
||||
```
|
||||
*/
|
||||
export default function cliTruncate(
|
||||
text: string,
|
||||
columns: number,
|
||||
options?: Options
|
||||
): string;
|
102
node_modules/cli-truncate/index.js
generated
vendored
Normal file
102
node_modules/cli-truncate/index.js
generated
vendored
Normal file
@ -0,0 +1,102 @@
|
||||
import sliceAnsi from 'slice-ansi';
|
||||
import stringWidth from 'string-width';
|
||||
|
||||
function getIndexOfNearestSpace(string, wantedIndex, shouldSearchRight) {
|
||||
if (string.charAt(wantedIndex) === ' ') {
|
||||
return wantedIndex;
|
||||
}
|
||||
|
||||
for (let index = 1; index <= 3; index++) {
|
||||
if (shouldSearchRight) {
|
||||
if (string.charAt(wantedIndex + index) === ' ') {
|
||||
return wantedIndex + index;
|
||||
}
|
||||
} else if (string.charAt(wantedIndex - index) === ' ') {
|
||||
return wantedIndex - index;
|
||||
}
|
||||
}
|
||||
|
||||
return wantedIndex;
|
||||
}
|
||||
|
||||
export default function cliTruncate(text, columns, options) {
|
||||
options = {
|
||||
position: 'end',
|
||||
preferTruncationOnSpace: false,
|
||||
truncationCharacter: '…',
|
||||
...options,
|
||||
};
|
||||
|
||||
const {position, space, preferTruncationOnSpace} = options;
|
||||
let {truncationCharacter} = options;
|
||||
|
||||
if (typeof text !== 'string') {
|
||||
throw new TypeError(`Expected \`input\` to be a string, got ${typeof text}`);
|
||||
}
|
||||
|
||||
if (typeof columns !== 'number') {
|
||||
throw new TypeError(`Expected \`columns\` to be a number, got ${typeof columns}`);
|
||||
}
|
||||
|
||||
if (columns < 1) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (columns === 1) {
|
||||
return truncationCharacter;
|
||||
}
|
||||
|
||||
const length = stringWidth(text);
|
||||
|
||||
if (length <= columns) {
|
||||
return text;
|
||||
}
|
||||
|
||||
if (position === 'start') {
|
||||
if (preferTruncationOnSpace) {
|
||||
const nearestSpace = getIndexOfNearestSpace(text, length - columns + 1, true);
|
||||
return truncationCharacter + sliceAnsi(text, nearestSpace, length).trim();
|
||||
}
|
||||
|
||||
if (space === true) {
|
||||
truncationCharacter += ' ';
|
||||
}
|
||||
|
||||
return truncationCharacter + sliceAnsi(text, length - columns + stringWidth(truncationCharacter), length);
|
||||
}
|
||||
|
||||
if (position === 'middle') {
|
||||
if (space === true) {
|
||||
truncationCharacter = ` ${truncationCharacter} `;
|
||||
}
|
||||
|
||||
const half = Math.floor(columns / 2);
|
||||
|
||||
if (preferTruncationOnSpace) {
|
||||
const spaceNearFirstBreakPoint = getIndexOfNearestSpace(text, half);
|
||||
const spaceNearSecondBreakPoint = getIndexOfNearestSpace(text, length - (columns - half) + 1, true);
|
||||
return sliceAnsi(text, 0, spaceNearFirstBreakPoint) + truncationCharacter + sliceAnsi(text, spaceNearSecondBreakPoint, length).trim();
|
||||
}
|
||||
|
||||
return (
|
||||
sliceAnsi(text, 0, half)
|
||||
+ truncationCharacter
|
||||
+ sliceAnsi(text, length - (columns - half) + stringWidth(truncationCharacter), length)
|
||||
);
|
||||
}
|
||||
|
||||
if (position === 'end') {
|
||||
if (preferTruncationOnSpace) {
|
||||
const nearestSpace = getIndexOfNearestSpace(text, columns - 1);
|
||||
return sliceAnsi(text, 0, nearestSpace) + truncationCharacter;
|
||||
}
|
||||
|
||||
if (space === true) {
|
||||
truncationCharacter = ` ${truncationCharacter}`;
|
||||
}
|
||||
|
||||
return sliceAnsi(text, 0, columns - stringWidth(truncationCharacter)) + truncationCharacter;
|
||||
}
|
||||
|
||||
throw new Error(`Expected \`options.position\` to be either \`start\`, \`middle\` or \`end\`, got ${position}`);
|
||||
}
|
9
node_modules/cli-truncate/license
generated
vendored
Normal file
9
node_modules/cli-truncate/license
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
48
node_modules/cli-truncate/package.json
generated
vendored
Normal file
48
node_modules/cli-truncate/package.json
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
{
|
||||
"name": "cli-truncate",
|
||||
"version": "3.1.0",
|
||||
"description": "Truncate a string to a specific width in the terminal",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/cli-truncate",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"type": "module",
|
||||
"exports": "./index.js",
|
||||
"engines": {
|
||||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"truncate",
|
||||
"ellipsis",
|
||||
"text",
|
||||
"limit",
|
||||
"slice",
|
||||
"cli",
|
||||
"terminal",
|
||||
"term",
|
||||
"shell",
|
||||
"width",
|
||||
"ansi",
|
||||
"string"
|
||||
],
|
||||
"dependencies": {
|
||||
"slice-ansi": "^5.0.0",
|
||||
"string-width": "^5.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^3.15.0",
|
||||
"tsd": "^0.17.0",
|
||||
"xo": "^0.44.0"
|
||||
}
|
||||
}
|
162
node_modules/cli-truncate/readme.md
generated
vendored
Normal file
162
node_modules/cli-truncate/readme.md
generated
vendored
Normal file
@ -0,0 +1,162 @@
|
||||
# cli-truncate
|
||||
|
||||
> Truncate a string to a specific width in the terminal
|
||||
|
||||
Gracefully handles [ANSI escapes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles). Like a string styled with [`chalk`](https://github.com/chalk/chalk). It also supports Unicode surrogate pairs and fullwidth characters.
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install cli-truncate
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import cliTruncate from 'cli-truncate';
|
||||
|
||||
cliTruncate('unicorn', 4);
|
||||
//=> 'uni…'
|
||||
|
||||
// Truncate at different positions
|
||||
cliTruncate('unicorn', 4, {position: 'start'});
|
||||
//=> '…orn'
|
||||
|
||||
cliTruncate('unicorn', 4, {position: 'middle'});
|
||||
//=> 'un…n'
|
||||
|
||||
cliTruncate('unicorns rainbow dragons', 6, {position: 'end'})
|
||||
//=> 'unico…'
|
||||
|
||||
cliTruncate('\u001B[31municorn\u001B[39m', 4);
|
||||
//=> '\u001B[31muni\u001B[39m…'
|
||||
|
||||
// Truncate Unicode surrogate pairs
|
||||
cliTruncate('uni\uD83C\uDE00corn', 5);
|
||||
//=> 'uni\uD83C\uDE00…'
|
||||
|
||||
// Truncate fullwidth characters
|
||||
cliTruncate('안녕하세요', 3);
|
||||
//=> '안…'
|
||||
|
||||
// Truncate the paragraph to the terminal width
|
||||
const paragraph = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa.';
|
||||
cliTruncate(paragraph, process.stdout.columns));
|
||||
//=> 'Lorem ipsum dolor sit amet, consectetuer adipiscing…'
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### cliTruncate(text, columns, options?)
|
||||
|
||||
#### text
|
||||
|
||||
Type: `string`
|
||||
|
||||
Text to truncate.
|
||||
|
||||
#### columns
|
||||
|
||||
Type: `number`
|
||||
|
||||
The number of columns to occupy in the terminal.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### position
|
||||
|
||||
Type: `string`\
|
||||
Default: `'end'`\
|
||||
Values: `'start'` `'middle'` `'end'`
|
||||
|
||||
The position to truncate the string.
|
||||
|
||||
##### space
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
Add a space between the text and the ellipsis.
|
||||
|
||||
```js
|
||||
import cliTruncate from 'cli-truncate';
|
||||
|
||||
cliTruncate('unicorns', 5, {space: false});
|
||||
//=> 'unic…'
|
||||
|
||||
cliTruncate('unicorns', 5, {space: true});
|
||||
//=> 'uni …'
|
||||
|
||||
cliTruncate('unicorns', 6, {position: 'start', space: true});
|
||||
//=> '… orns'
|
||||
|
||||
cliTruncate('unicorns', 7, {position: 'middle', space: true});
|
||||
//=> 'uni … s'
|
||||
```
|
||||
|
||||
##### preferTruncationOnSpace
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
Truncate the string from a whitespace if it is within 3 characters from the actual breaking point.
|
||||
|
||||
```js
|
||||
import cliTruncate from 'cli-truncate';
|
||||
|
||||
cliTruncate('unicorns rainbow dragons', 20, {position: 'start', preferTruncationOnSpace: true})
|
||||
//=> '…rainbow dragons'
|
||||
|
||||
// without preferTruncationOnSpace
|
||||
cliTruncate('unicorns rainbow dragons', 20, {position: 'start'})
|
||||
//=> '…rns rainbow dragons'
|
||||
|
||||
cliTruncate('unicorns rainbow dragons', 20, {position: 'middle', preferTruncationOnSpace: true})
|
||||
//=> 'unicorns…dragons'
|
||||
|
||||
cliTruncate('unicorns rainbow dragons', 6, {position: 'end', preferTruncationOnSpace: true})
|
||||
//=> 'unico…'
|
||||
|
||||
// preferTruncationOnSpace would have no effect if space isn't found within next 3 indexes
|
||||
cliTruncate('unicorns rainbow dragons', 6, {position: 'middle', preferTruncationOnSpace: true})
|
||||
//=> 'uni…ns'
|
||||
```
|
||||
|
||||
##### truncationCharacter
|
||||
|
||||
Type: `string`\
|
||||
Default: `…`
|
||||
|
||||
The character to use at the breaking point.
|
||||
|
||||
```js
|
||||
import cliTruncate from 'cli-truncate';
|
||||
|
||||
cliTruncate('unicorns', 5, {position: 'end'});
|
||||
//=> 'unic…'
|
||||
|
||||
cliTruncate('unicorns', 5, {position: 'end', truncationCharacter: '.'});
|
||||
//=> 'unic.'
|
||||
|
||||
cliTruncate('unicorns', 5, {position: 'end', truncationCharacter: ''});
|
||||
//=> 'unico'
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
- [wrap-ansi](https://github.com/chalk/wrap-ansi) - Wordwrap a string with ANSI escape codes
|
||||
- [slice-ansi](https://github.com/chalk/slice-ansi) - Slice a string with ANSI escape codes
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-cli-truncate?utm_source=npm-cli-truncate&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
||||
</b>
|
||||
<br>
|
||||
<sub>
|
||||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||
</sub>
|
||||
</div>
|
Reference in New Issue
Block a user