# add dist

This commit is contained in:
Mario Romano
2016-04-21 11:56:31 +01:00
parent 5914688467
commit 07807e7bc3
13499 changed files with 1808930 additions and 5 deletions

View File

@@ -0,0 +1,32 @@
'use strict';
var stripAnsi = require('strip-ansi');
var codePointAt = require('code-point-at');
var isFullwidthCodePoint = require('is-fullwidth-code-point');
// https://github.com/nodejs/io.js/blob/cff7300a578be1b10001f2d967aaedc88aee6402/lib/readline.js#L1345
module.exports = function (str) {
if (typeof str !== 'string' || str.length === 0) {
return 0;
}
var width = 0;
str = stripAnsi(str);
for (var i = 0; i < str.length; i++) {
var code = codePointAt(str, i);
// surrogates
if (code >= 0x10000) {
i++;
}
if (isFullwidthCodePoint(code)) {
width += 2;
} else {
width++;
}
}
return width;
};

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (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.

View File

@@ -0,0 +1,114 @@
{
"_args": [
[
"string-width@^1.0.1",
"/Users/mromano/dev/dev-platform-webcomponents/ng2-components/ng2-alfresco-documentslist/node_modules/cliui"
]
],
"_from": "string-width@>=1.0.1 <2.0.0",
"_id": "string-width@1.0.1",
"_inCache": true,
"_installable": true,
"_location": "/string-width",
"_nodeVersion": "0.12.5",
"_npmUser": {
"email": "sindresorhus@gmail.com",
"name": "sindresorhus"
},
"_npmVersion": "2.11.2",
"_phantomChildren": {},
"_requested": {
"name": "string-width",
"raw": "string-width@^1.0.1",
"rawSpec": "^1.0.1",
"scope": null,
"spec": ">=1.0.1 <2.0.0",
"type": "range"
},
"_requiredBy": [
"/boxen",
"/browser-sync/yargs",
"/cliui",
"/widest-line",
"/wrap-ansi"
],
"_resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.1.tgz",
"_shasum": "c92129b6f1d7f52acf9af424a26e3864a05ceb0a",
"_shrinkwrap": null,
"_spec": "string-width@^1.0.1",
"_where": "/Users/mromano/dev/dev-platform-webcomponents/ng2-components/ng2-alfresco-documentslist/node_modules/cliui",
"author": {
"email": "sindresorhus@gmail.com",
"name": "Sindre Sorhus",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/sindresorhus/string-width/issues"
},
"dependencies": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
"strip-ansi": "^3.0.0"
},
"description": "Get the visual width of a string - the number of columns required to display it",
"devDependencies": {
"ava": "0.0.4"
},
"directories": {},
"dist": {
"shasum": "c92129b6f1d7f52acf9af424a26e3864a05ceb0a",
"tarball": "https://registry.npmjs.org/string-width/-/string-width-1.0.1.tgz"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"gitHead": "f279cfd14835f0a3c8df69ba18e9a3960156e135",
"homepage": "https://github.com/sindresorhus/string-width",
"keywords": [
"string",
"str",
"character",
"char",
"unicode",
"width",
"visual",
"column",
"columns",
"fullwidth",
"full-width",
"full",
"ansi",
"escape",
"codes",
"cli",
"command-line",
"terminal",
"console",
"cjk",
"chinese",
"japanese",
"korean",
"fixed-width"
],
"license": "MIT",
"maintainers": [
{
"email": "sindresorhus@gmail.com",
"name": "sindresorhus"
}
],
"name": "string-width",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/string-width.git"
},
"scripts": {
"test": "node test.js"
},
"version": "1.0.1"
}

View File

@@ -0,0 +1,41 @@
# string-width [![Build Status](https://travis-ci.org/sindresorhus/string-width.svg?branch=master)](https://travis-ci.org/sindresorhus/string-width)
> Get the visual width of a string - the number of columns required to display it
Some Unicode characters are [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) and use double the normal width.
Useful to be able to measure the actual width of command-line output.
## Install
```
$ npm install --save string-width
```
## Usage
```js
var stringWidth = require('string-width');
stringWidth('古');
//=> 2
stringWidth('\u001b[1m古\u001b[22m');
//=> 2
stringWidth('a');
//=> 1
```
## Related
- [string-width-cli](https://github.com/sindresorhus/string-width-cli) - CLI for this module
- [string-length](https://github.com/sindresorhus/string-length) - Get the real length of a string
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)