Skip to content

Commit f1847ef

Browse files
committed
fix(encoding): renamed base62 to base62x
1 parent 4c6c83c commit f1847ef

24 files changed

+3078
-376
lines changed

.eslintignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/*.js
2+
/lib/
3+
/benchmarks/
4+
/examples/
5+
/node_modules/

.eslintrc

+186
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es6": true
5+
},
6+
"extends": [
7+
"eslint:recommended",
8+
"plugin:@typescript-eslint/eslint-recommended"
9+
],
10+
"globals": {
11+
"Atomics": "readonly",
12+
"SharedArrayBuffer": "readonly"
13+
},
14+
"parser": "@typescript-eslint/parser",
15+
"parserOptions": {
16+
"ecmaVersion": 2020,
17+
"sourceType": "module",
18+
"project": "./tsconfig.json"
19+
},
20+
"plugins": [
21+
"@typescript-eslint"
22+
],
23+
"rules": {
24+
"brace-style": "off",
25+
"@typescript-eslint/brace-style": ["error", "stroustrup", { "allowSingleLine": true }],
26+
"camelcase": "off",
27+
"@typescript-eslint/camelcase": ["error", {
28+
"properties": "always",
29+
"genericType": "always",
30+
"ignoreDestructuring": false
31+
}],
32+
"@typescript-eslint/ban-types": ["error", {
33+
"types": {
34+
35+
"String": {
36+
"message": "Use string instead",
37+
"fixWith": "string"
38+
},
39+
"Number": {
40+
"message": "Use number instead",
41+
"fixWith": "number"
42+
},
43+
"Boolean": {
44+
"message": "Use number instead",
45+
"fixWith": "boolean"
46+
},
47+
"Object": {
48+
"message": "Use {} instead",
49+
"fixWith": "{}"
50+
}
51+
}
52+
}],
53+
"no-extra-semi": "off",
54+
"@typescript-eslint/no-extra-semi": ["error"],
55+
"@typescript-eslint/no-base-to-string": ["warn"],
56+
"@typescript-eslint/await-thenable": ["error"],
57+
"@typescript-eslint/array-type": ["error", { "default": "array-simple" }],
58+
"@typescript-eslint/prefer-as-const": "error",
59+
"@typescript-eslint/no-extraneous-class": "error",
60+
"@typescript-eslint/no-floating-promises": ["error", { "ignoreVoid": false }],
61+
"@typescript-eslint/no-array-constructor": "error",
62+
"@typescript-eslint/no-empty-function": "error",
63+
"@typescript-eslint/no-empty-interface": "error",
64+
"@typescript-eslint/prefer-for-of": "error",
65+
"@typescript-eslint/prefer-nullish-coalescing": "error",
66+
"@typescript-eslint/prefer-function-type": "error",
67+
"@typescript-eslint/prefer-includes": "error",
68+
"@typescript-eslint/prefer-string-starts-ends-with": "error",
69+
"@typescript-eslint/prefer-regexp-exec": "error",
70+
"@typescript-eslint/prefer-optional-chain": "error",
71+
"@typescript-eslint/no-extra-parens": "off",
72+
"@typescript-eslint/class-name-casing": "error",
73+
"@typescript-eslint/no-extra-non-null-assertion": "error",
74+
"@typescript-eslint/adjacent-overload-signatures": "error",
75+
"@typescript-eslint/no-for-in-array": "error",
76+
"@typescript-eslint/default-param-last": "error",
77+
"@typescript-eslint/explicit-member-accessibility": "error",
78+
"@typescript-eslint/explicit-function-return-type": ["error", {
79+
"allowExpressions": true
80+
}],
81+
"@typescript-eslint/explicit-module-boundary-types": "error",
82+
"@typescript-eslint/no-misused-new": "error",
83+
"@typescript-eslint/no-misused-promises": "error",
84+
"@typescript-eslint/no-require-imports": "warn",
85+
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
86+
"func-call-spacing": "off",
87+
"@typescript-eslint/func-call-spacing": ["error", "never"],
88+
"@typescript-eslint/no-namespace": ["error", {
89+
90+
"allowDeclarations": true,
91+
"allowDefinitionFiles": true
92+
}],
93+
"@typescript-eslint/consistent-type-assertions": ["error", {
94+
"assertionStyle": "as"
95+
}],
96+
"no-unused-vars": "off",
97+
"@typescript-eslint/no-unused-vars": ["error", {
98+
"vars": "all",
99+
"args": "after-used",
100+
"ignoreRestSiblings": false,
101+
"caughtErrors": "all"
102+
}],
103+
"no-unused-expressions": "off",
104+
"@typescript-eslint/no-unused-expressions": ["error"],
105+
"no-useless-constructor": "off",
106+
"@typescript-eslint/no-useless-constructor": ["error"],
107+
"no-constant-condition":"off",
108+
"comma-spacing": "off",
109+
"@typescript-eslint/comma-spacing": ["error"],
110+
"@typescript-eslint/unified-signatures": ["error"],
111+
"semi": "off",
112+
"@typescript-eslint/semi": ["error"],
113+
"@typescript-eslint/no-use-before-define": ["error"],
114+
"@typescript-eslint/no-unnecessary-type-assertion": ["error"],
115+
"@typescript-eslint/no-unnecessary-type-arguments": ["error"],
116+
"@typescript-eslint/unbound-method": ["error"],
117+
"@typescript-eslint/type-annotation-spacing": ["error"],
118+
"@typescript-eslint/no-unnecessary-condition": ["off"],
119+
"@typescript-eslint/no-magic-numbers": ["off", {
120+
"ignoreEnums": true
121+
}],
122+
"@typescript-eslint/no-unnecessary-boolean-literal-compare": ["warn"],
123+
"@typescript-eslint/member-ordering": ["off"],
124+
"@typescript-eslint/no-this-alias": [
125+
"warn",
126+
{
127+
"allowDestructuring": true,
128+
"allowedNames": ["_this"]
129+
}
130+
],
131+
"@typescript-eslint/member-naming": ["error", {
132+
"private": "^_",
133+
"protected": "^_"
134+
}],
135+
"@typescript-eslint/no-explicit-any": ["off", {
136+
"fixToUnknown": true,
137+
"ignoreRestArgs": true
138+
}],
139+
"space-before-function-paren": "off",
140+
"@typescript-eslint/space-before-function-paren": ["error", {
141+
"anonymous": "never",
142+
"named": "never",
143+
"asyncArrow": "always"
144+
}],
145+
"@typescript-eslint/member-delimiter-style": ["error", {
146+
"multiline": {
147+
"delimiter": "semi",
148+
"requireLast": true
149+
},
150+
"singleline": {
151+
"delimiter": "semi",
152+
"requireLast": true
153+
}
154+
}],
155+
"@typescript-eslint/interface-name-prefix": ["warn", {
156+
"prefixWithI": "always",
157+
"allowUnderscorePrefix": false
158+
}],
159+
"key-spacing": ["error", { "beforeColon": false, "afterColon": true }],
160+
"no-multiple-empty-lines": ["error", {"max": 1, "maxEOF": 0, "maxBOF": 0}],
161+
"no-trailing-spaces": "error",
162+
"block-spacing":"error",
163+
"eol-last":"error",
164+
"space-before-blocks": "error",
165+
"indent": "off",
166+
"@typescript-eslint/indent": ["error", 4, {
167+
"SwitchCase": 1,
168+
"MemberExpression": 1,
169+
"ArrayExpression": 1,
170+
"ObjectExpression": 1,
171+
"ImportDeclaration": 1,
172+
"flatTernaryExpressions": true,
173+
"CallExpression": {"arguments": 1},
174+
"FunctionDeclaration": {"body": 1, "parameters": 1},
175+
"ignoredNodes": ["TSTypeParameterInstantiation", "TemplateLiteral *"]
176+
}],
177+
"linebreak-style": [
178+
"error",
179+
"unix"
180+
],
181+
"quotes": [
182+
"error",
183+
"single"
184+
]
185+
}
186+
}

.npmignore

+3
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@
88
/tslint.json
99
/docs/
1010
/examples/
11+
/commitlint.config.js
12+
/.eslintrc
13+
/.eslintignore

.npmrc

-1
This file was deleted.

CHANGES.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changes Logs
22

3+
## v2.2.0
4+
5+
- Renamed `base62` to `base62x`.
6+
7+
> Original `base62` API is reserved but deprecated, and will be removed in next major version.
8+
39
## v2.1.0
410

511
- Added encoding `base32`.

README.md

+5-7
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,11 @@ Name | Description | Binary-Safe
4949
> ### Encoding `base62x`
5050
>
5151
> This is a variation of `base64`. **And it is a binary-safe encoding.**
52-
>
53-
5452
5553
## Installation
5654

5755
```sh
58-
npm install @litert/encodings --save
56+
npm i @litert/encodings -S
5957
```
6058

6159
## Usage
@@ -64,7 +62,7 @@ npm install @litert/encodings --save
6462
import * as Enc from "@litert/encodings";
6563

6664
const hex = Enc.stringToHex("hello world"); // Encode a string into hex
67-
const b62 = Enc.stringToBase62("hello world"); // Encode a string into BASE62
65+
const b62 = Enc.stringToBase62x("hello world"); // Encode a string into BASE62x
6866
const b64 = Enc.stringToBase64("hello world"); // Encode a string into BASE64
6967
const b64url = Enc.stringToBase64Url("hello world"); // Encode a string into BASE64URL
7068
const b32 = Enc.stringToBase32("hello world"); // Encode a string into BASE32
@@ -74,23 +72,23 @@ const strict = Enc.stringToStrictUri("hello world"); // Encode a string into
7472
// Also, buffer is accepted as input.
7573

7674
Enc.bufferToHex(Buffer.from("hello world"));
77-
Enc.bufferToBase62(Buffer.from("hello world"));
75+
Enc.bufferToBase62x(Buffer.from("hello world"));
7876
Enc.bufferToBase64(Buffer.from("hello world"));
7977
Enc.bufferToBase64Url(Buffer.from("hello world"));
8078
Enc.bufferToBase32(Buffer.from("hello world"));
8179
Enc.bufferToUrlencode(Buffer.from("hello world"));
8280
Enc.bufferToStrictUri(Buffer.from("hello world"));
8381

8482
Enc.stringFromHex(hex); // Decode a hex-encoded data as a string
85-
Enc.stringFromBase62(b62); // Decode a BASE62-encoded data as a string
83+
Enc.stringFromBase62x(b62); // Decode a BASE62x-encoded data as a string
8684
Enc.stringFromBase64(b64); // Decode a BASE64-encoded data as a string
8785
Enc.stringFromBase64Url(b64url); // Decode a BASE64URL-encoded data as a string
8886
Enc.stringFromBase32(b32); // Decode a BASE32-encoded data as a string
8987
Enc.stringFromUrlencode(url); // Decode a urlencoded data as a string
9088
Enc.stringFromStrictUri(strict); // Decode a Strict-URI-encoded data as a string
9189

9290
Enc.bufferFromHex(hex);
93-
Enc.bufferFromBase62(b62);
91+
Enc.bufferFromBase62x(b62);
9492
Enc.bufferFromBase64(b64);
9593
Enc.bufferFromBase64Url(b64url);
9694
Enc.bufferFromBase32(b32);

commitlint.config.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
module.exports = {
2+
'extends': ['@commitlint/config-conventional'],
3+
'defaultIgnores': false,
4+
'rules': {
5+
'type-enum': [2, 'always', [
6+
'feat',
7+
'fix',
8+
'add',
9+
'test',
10+
'refactor',
11+
'perf',
12+
'style',
13+
'config',
14+
'merge'
15+
]],
16+
'scope-enum': [2, 'always', [
17+
'encoding',
18+
'doc',
19+
'lint',
20+
'branch',
21+
'global'
22+
]],
23+
'scope-empty': [2, 'never'],
24+
'subject-min-length': [2, 'always', 5],
25+
'subject-max-length': [2, 'always', 50],
26+
}
27+
};

0 commit comments

Comments
 (0)