Skip to content

Commit

Permalink
feat: first release
Browse files Browse the repository at this point in the history
  • Loading branch information
ayonious committed Dec 8, 2020
1 parent e6a6fa6 commit b2cabf1
Show file tree
Hide file tree
Showing 23 changed files with 8,586 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .eslintrc.json
@@ -0,0 +1,27 @@
{
"env": {
"es6": true,
"node": true,
"jest": true
},
"extends": ["airbnb-base", "prettier"],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": ["@typescript-eslint", "prettier"],
"rules": {
"prettier/prettier": "error",
"no-console": "off",
"import/no-unresolved": "off",
"import/extensions": "off",
"comma-dangle": "off",
"no-unused-vars": "off",
"camelcase": "off"
}
}
20 changes: 20 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,20 @@
## 👀What is this pr about?

Summary of what this is about

## 🚀 Changes

### Added

- [x] feature1
- [x] feature2

### Fixed

### Updated

## 🖼 Screenshots

| Before | After |
| ------ | ----- |
| 🧟 | 😎 |
64 changes: 64 additions & 0 deletions .gitignore
@@ -0,0 +1,64 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# dist directory created by ts
dist

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# next.js build output
.next
5 changes: 5 additions & 0 deletions .huskyrc.json
@@ -0,0 +1,5 @@
{
"hooks": {
"pre-push": "pretty-quick --staged"
}
}
81 changes: 81 additions & 0 deletions .npmignore
@@ -0,0 +1,81 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# next.js build output
.next

# tests (not to add tests when publishing)
test
coverage

# jest configuration
jestconfig.json

# ts configuration
tsconfig.json

# other plugins
renovate.json
.travis.yml
static-resources
src
index.ts
.huskyrc.json
.prettierrc
.prettierignore
4 changes: 4 additions & 0 deletions .prettierignore
@@ -0,0 +1,4 @@
package.json
package-lock.json
coverage
dist
7 changes: 7 additions & 0 deletions .prettierrc
@@ -0,0 +1,7 @@
{
"endOfLine": "lf",
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5"
}
13 changes: 13 additions & 0 deletions .releaserc.json
@@ -0,0 +1,13 @@
{
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
["@semantic-release/git", {
"assets": ["CHANGELOG.md"],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}],
"@semantic-release/npm",
"@semantic-release/github"
]
}
10 changes: 10 additions & 0 deletions .travis.yml
@@ -0,0 +1,10 @@
language: node_js
node_js:
- stable
- '--lts'
before_script:
- yarn lint
- yarn
- yarn build
after_success:
- bash <(curl -s https://codecov.io/bash) -e TRAVIS_NODE_VERSION
98 changes: 98 additions & 0 deletions README.md
@@ -0,0 +1,98 @@
<h1 align="center">simple-wcswidth</h1>
<h3 align="center"> 🖥️ 💬 Simplified JS/TS implementation of wcswidth() written by Markus Kuhn in C</h3>

<p align="center">
<a href="https://codecov.io/gh/ayonious/simple-wcswidth">
<img alt="codecov" src="https://codecov.io/gh/ayonious/simple-wcswidth/branch/master/graph/badge.svg">
</a>
<a href="https://badge.fury.io/js/simple-wcswidth">
<img alt="npm version" src="https://badge.fury.io/js/simple-wcswidth.svg">
</a>
<a href="https://packagephobia.now.sh/result?p=simple-wcswidth">
<img alt="install size" src="https://packagephobia.now.sh/badge?p=simple-wcswidth@latest">
</a>
</p>
<p align="center">
<a href="https://github.com/semantic-release/semantic-release">
<img alt="semantic-release" src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg">
</a>
</p>

# Why another wcswidth?

1. 💙 Types included
2. 🤏 Installation Size kept as min possible
3. 🐒 No Unnecessary dependency added
4. 🤖 Tested Automatically and Regularly on different versions of node, including current LTS and stable

# Example Usage

```js
const { wcswidth } = require('simple-wcwidth');

console.log(wcswidth('Yes 重要')); // 8
console.log(wcswidth('请你')); // 4
console.log(wcswidth('Hi')); // 2
```

# What is simplified here?

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.

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.

# Info Taken from Markus Kuhn's [C code](https://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c)

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
IEEE Std 1002.1-2001) for Unicode.

In fixed-width output devices, Latin characters all occupy a single
"cell" position of equal width, whereas ideographic CJK characters
occupy two such cells. Interoperability between terminal-line
applications and (teletype-style) character terminals using the
UTF-8 encoding requires agreement on which character should advance
the cursor by how many cell positions. No established formal
standards exist at present on which Unicode character shall occupy
how many cell positions on character terminals. These routines are
a first attempt of defining such behavior based on simple rules
applied to data provided by the Unicode Consortium.

For some graphical characters, the Unicode standard explicitly
defines a character-cell width via the definition of the East Asian
FullWidth (F), Wide (W), Half-width (H), and Narrow (Na) classes.
In all these cases, there is no ambiguity about which width a
terminal shall use. For characters in the East Asian Ambiguous (A)
class, the width choice depends purely on a preference of backward
compatibility with either historic CJK or Western practice.
Choosing single-width for these characters is easy to justify as
the appropriate long-term solution, as the CJK practice of
displaying these characters as double-width comes from historic
implementation simplicity (8-bit encoded characters were displayed
single-width and 16-bit ones double-width, even for Greek,
Cyrillic, etc.) and not any typographic considerations.

Much less clear is the choice of width for the Not East Asian
(Neutral) class. Existing practice does not dictate a width for any
of these characters. It would nevertheless make sense
typographically to allocate two character cells to characters such
as for instance EM SPACE or VOLUME INTEGRAL, which cannot be
represented adequately with a single-width glyph. The following
routines at present merely assign a single-cell width to all
neutral characters, in the interest of simplicity. This is not
entirely satisfactory and should be reconsidered before
establishing a formal standard in this area. At the moment, the
decision which Not East Asian (Neutral) characters should be
represented by double-width glyphs cannot yet be answered by
applying a simple rule from the Unicode database content. Setting
up a proper standard for the behavior of UTF-8 character terminals
will require a careful analysis not only of each Unicode character,
but also of each presentation form, something the author of these
routines has avoided to do so far.

http://www.unicode.org/unicode/reports/tr11/

# LICENSE

MIT

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)
4 changes: 4 additions & 0 deletions index.ts
@@ -0,0 +1,4 @@
import wcswidth from './src/wcswidth';
import wcwidth from './src/wcwidth';

export { wcwidth, wcswidth };
4 changes: 4 additions & 0 deletions jestconfig.json
@@ -0,0 +1,4 @@
{
"collectCoverage": true,
"preset": "ts-jest"
}
44 changes: 44 additions & 0 deletions package.json
@@ -0,0 +1,44 @@
{
"name": "simple-wcswidth",
"version": "0.0.0",
"description": "Simplified JS/TS implementation of wcswidth() written by Markus Kuhn in C",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"repository": "git@github.com:ayonious/simple-wcswidth.git",
"author": "Nahiyan Kamal <noyanayihan@gmail.com>",
"license": "MIT",
"scripts": {
"setup": "yarn",
"build": "tsc",
"format": "prettier --write \"**/*.{json,md,ts,tsx,yml,js,jsx}\"",
"test": "jest --config jestconfig.json",
"lint": "eslint --ext=js,ts ."
},
"keywords": [
"wcwidth",
"wcswidth",
"console-width"
],
"files": [
"dist"
],
"devDependencies": {
"@semantic-release/changelog": "^5.0.1",
"@semantic-release/git": "^9.0.0",
"@types/jest": "^26.0.16",
"@typescript-eslint/eslint-plugin": "^4.9.0",
"@typescript-eslint/parser": "^4.9.0",
"eslint": "^7.15.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-prettier": "^3.2.0",
"husky": "^4.3.0",
"jest": "^26.6.3",
"prettier": "^2.2.1",
"pretty-quick": "^3.1.0",
"semantic-release": "^17.3.0",
"ts-jest": "^26.4.4",
"typescript": "^4.1.2"
}
}

0 comments on commit b2cabf1

Please sign in to comment.