Skip to content

Commit b2cabf1

Browse files
committed
feat: first release
1 parent e6a6fa6 commit b2cabf1

23 files changed

+8586
-0
lines changed

.eslintrc.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"env": {
3+
"es6": true,
4+
"node": true,
5+
"jest": true
6+
},
7+
"extends": ["airbnb-base", "prettier"],
8+
"globals": {
9+
"Atomics": "readonly",
10+
"SharedArrayBuffer": "readonly"
11+
},
12+
"parser": "@typescript-eslint/parser",
13+
"parserOptions": {
14+
"ecmaVersion": 2018,
15+
"sourceType": "module"
16+
},
17+
"plugins": ["@typescript-eslint", "prettier"],
18+
"rules": {
19+
"prettier/prettier": "error",
20+
"no-console": "off",
21+
"import/no-unresolved": "off",
22+
"import/extensions": "off",
23+
"comma-dangle": "off",
24+
"no-unused-vars": "off",
25+
"camelcase": "off"
26+
}
27+
}

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
## 👀What is this pr about?
2+
3+
Summary of what this is about
4+
5+
## 🚀 Changes
6+
7+
### Added
8+
9+
- [x] feature1
10+
- [x] feature2
11+
12+
### Fixed
13+
14+
### Updated
15+
16+
## 🖼 Screenshots
17+
18+
| Before | After |
19+
| ------ | ----- |
20+
| 🧟 | 😎 |

.gitignore

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
8+
# Runtime data
9+
pids
10+
*.pid
11+
*.seed
12+
*.pid.lock
13+
14+
# Directory for instrumented libs generated by jscoverage/JSCover
15+
lib-cov
16+
17+
# Coverage directory used by tools like istanbul
18+
coverage
19+
20+
# dist directory created by ts
21+
dist
22+
23+
# nyc test coverage
24+
.nyc_output
25+
26+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
27+
.grunt
28+
29+
# Bower dependency directory (https://bower.io/)
30+
bower_components
31+
32+
# node-waf configuration
33+
.lock-wscript
34+
35+
# Compiled binary addons (https://nodejs.org/api/addons.html)
36+
build/Release
37+
38+
# Dependency directories
39+
node_modules/
40+
jspm_packages/
41+
42+
# TypeScript v1 declaration files
43+
typings/
44+
45+
# Optional npm cache directory
46+
.npm
47+
48+
# Optional eslint cache
49+
.eslintcache
50+
51+
# Optional REPL history
52+
.node_repl_history
53+
54+
# Output of 'npm pack'
55+
*.tgz
56+
57+
# Yarn Integrity file
58+
.yarn-integrity
59+
60+
# dotenv environment variables file
61+
.env
62+
63+
# next.js build output
64+
.next

.huskyrc.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"hooks": {
3+
"pre-push": "pretty-quick --staged"
4+
}
5+
}

.npmignore

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
8+
# Runtime data
9+
pids
10+
*.pid
11+
*.seed
12+
*.pid.lock
13+
14+
# Directory for instrumented libs generated by jscoverage/JSCover
15+
lib-cov
16+
17+
# Coverage directory used by tools like istanbul
18+
coverage
19+
20+
# nyc test coverage
21+
.nyc_output
22+
23+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24+
.grunt
25+
26+
# Bower dependency directory (https://bower.io/)
27+
bower_components
28+
29+
# node-waf configuration
30+
.lock-wscript
31+
32+
# Compiled binary addons (https://nodejs.org/api/addons.html)
33+
build/Release
34+
35+
# Dependency directories
36+
node_modules/
37+
jspm_packages/
38+
39+
# TypeScript v1 declaration files
40+
typings/
41+
42+
# Optional npm cache directory
43+
.npm
44+
45+
# Optional eslint cache
46+
.eslintcache
47+
48+
# Optional REPL history
49+
.node_repl_history
50+
51+
# Output of 'npm pack'
52+
*.tgz
53+
54+
# Yarn Integrity file
55+
.yarn-integrity
56+
57+
# dotenv environment variables file
58+
.env
59+
60+
# next.js build output
61+
.next
62+
63+
# tests (not to add tests when publishing)
64+
test
65+
coverage
66+
67+
# jest configuration
68+
jestconfig.json
69+
70+
# ts configuration
71+
tsconfig.json
72+
73+
# other plugins
74+
renovate.json
75+
.travis.yml
76+
static-resources
77+
src
78+
index.ts
79+
.huskyrc.json
80+
.prettierrc
81+
.prettierignore

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package.json
2+
package-lock.json
3+
coverage
4+
dist

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"endOfLine": "lf",
3+
"semi": true,
4+
"singleQuote": true,
5+
"tabWidth": 2,
6+
"trailingComma": "es5"
7+
}

.releaserc.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"plugins": [
3+
"@semantic-release/commit-analyzer",
4+
"@semantic-release/release-notes-generator",
5+
"@semantic-release/changelog",
6+
["@semantic-release/git", {
7+
"assets": ["CHANGELOG.md"],
8+
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
9+
}],
10+
"@semantic-release/npm",
11+
"@semantic-release/github"
12+
]
13+
}

.travis.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
language: node_js
2+
node_js:
3+
- stable
4+
- '--lts'
5+
before_script:
6+
- yarn lint
7+
- yarn
8+
- yarn build
9+
after_success:
10+
- bash <(curl -s https://codecov.io/bash) -e TRAVIS_NODE_VERSION

README.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<h1 align="center">simple-wcswidth</h1>
2+
<h3 align="center"> 🖥️ 💬 Simplified JS/TS implementation of wcswidth() written by Markus Kuhn in C</h3>
3+
4+
<p align="center">
5+
<a href="https://codecov.io/gh/ayonious/simple-wcswidth">
6+
<img alt="codecov" src="https://codecov.io/gh/ayonious/simple-wcswidth/branch/master/graph/badge.svg">
7+
</a>
8+
<a href="https://badge.fury.io/js/simple-wcswidth">
9+
<img alt="npm version" src="https://badge.fury.io/js/simple-wcswidth.svg">
10+
</a>
11+
<a href="https://packagephobia.now.sh/result?p=simple-wcswidth">
12+
<img alt="install size" src="https://packagephobia.now.sh/badge?p=simple-wcswidth@latest">
13+
</a>
14+
</p>
15+
<p align="center">
16+
<a href="https://github.com/semantic-release/semantic-release">
17+
<img alt="semantic-release" src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg">
18+
</a>
19+
</p>
20+
21+
# Why another wcswidth?
22+
23+
1. 💙 Types included
24+
2. 🤏 Installation Size kept as min possible
25+
3. 🐒 No Unnecessary dependency added
26+
4. 🤖 Tested Automatically and Regularly on different versions of node, including current LTS and stable
27+
28+
# Example Usage
29+
30+
```js
31+
const { wcswidth } = require('simple-wcwidth');
32+
33+
console.log(wcswidth('Yes 重要')); // 8
34+
console.log(wcswidth('请你')); // 4
35+
console.log(wcswidth('Hi')); // 2
36+
```
37+
38+
# What is simplified here?
39+
40+
In the original [C code](https://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c) there were 2 versions of `wcswidth()` I have included here only for first one, which is applicable for general use.
41+
42+
About the second one(WHICH I DIDNT INCLUDE HERE), useful for users of CJK legacy encodings who want to migrate to UCS without changing the traditional terminal character-width behaviour. It is not otherwise recommended for general use.
43+
44+
# Info Taken from Markus Kuhn's [C code](https://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c)
45+
46+
This is an implementation of [wcwidth()](http://www.opengroup.org/onlinepubs/007904975/functions/wcwidth.html) and [wcswidth()](http://www.opengroup.org/onlinepubs/007904975/functions/wcswidth.html) (defined in
47+
IEEE Std 1002.1-2001) for Unicode.
48+
49+
In fixed-width output devices, Latin characters all occupy a single
50+
"cell" position of equal width, whereas ideographic CJK characters
51+
occupy two such cells. Interoperability between terminal-line
52+
applications and (teletype-style) character terminals using the
53+
UTF-8 encoding requires agreement on which character should advance
54+
the cursor by how many cell positions. No established formal
55+
standards exist at present on which Unicode character shall occupy
56+
how many cell positions on character terminals. These routines are
57+
a first attempt of defining such behavior based on simple rules
58+
applied to data provided by the Unicode Consortium.
59+
60+
For some graphical characters, the Unicode standard explicitly
61+
defines a character-cell width via the definition of the East Asian
62+
FullWidth (F), Wide (W), Half-width (H), and Narrow (Na) classes.
63+
In all these cases, there is no ambiguity about which width a
64+
terminal shall use. For characters in the East Asian Ambiguous (A)
65+
class, the width choice depends purely on a preference of backward
66+
compatibility with either historic CJK or Western practice.
67+
Choosing single-width for these characters is easy to justify as
68+
the appropriate long-term solution, as the CJK practice of
69+
displaying these characters as double-width comes from historic
70+
implementation simplicity (8-bit encoded characters were displayed
71+
single-width and 16-bit ones double-width, even for Greek,
72+
Cyrillic, etc.) and not any typographic considerations.
73+
74+
Much less clear is the choice of width for the Not East Asian
75+
(Neutral) class. Existing practice does not dictate a width for any
76+
of these characters. It would nevertheless make sense
77+
typographically to allocate two character cells to characters such
78+
as for instance EM SPACE or VOLUME INTEGRAL, which cannot be
79+
represented adequately with a single-width glyph. The following
80+
routines at present merely assign a single-cell width to all
81+
neutral characters, in the interest of simplicity. This is not
82+
entirely satisfactory and should be reconsidered before
83+
establishing a formal standard in this area. At the moment, the
84+
decision which Not East Asian (Neutral) characters should be
85+
represented by double-width glyphs cannot yet be answered by
86+
applying a simple rule from the Unicode database content. Setting
87+
up a proper standard for the behavior of UTF-8 character terminals
88+
will require a careful analysis not only of each Unicode character,
89+
but also of each presentation form, something the author of these
90+
routines has avoided to do so far.
91+
92+
http://www.unicode.org/unicode/reports/tr11/
93+
94+
# LICENSE
95+
96+
MIT
97+
98+
The original Code written in C was very permissive. You can find it here [Code](http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c)

0 commit comments

Comments
 (0)