Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
lint: format
Browse files Browse the repository at this point in the history
  • Loading branch information
AliMD committed Sep 19, 2023
1 parent 33bd3ef commit 67a3e5f
Show file tree
Hide file tree
Showing 37 changed files with 316 additions and 378 deletions.
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/1-bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ Note: Please search to see if an issue already exists for the bug you encountere
-->

### Current Behavior

<!-- A concise description of what you're experiencing. -->

### Expected Behavior

<!-- A concise description of what you expected to happen. -->

### Steps To Reproduce

<!--
Example: steps to reproduce the behavior:
1. In this environment...
Expand All @@ -26,6 +29,7 @@ Example: steps to reproduce the behavior:
-->

### Environment

<!--
Example:
- OS: Ubuntu 20.04
Expand All @@ -34,6 +38,7 @@ Example:
-->

### Anything else

<!--
Links? References? Anything that will give us more context about the issue that you are encountering!
-->
20 changes: 9 additions & 11 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

version: 2
updates:
-
package-ecosystem: github-actions
- package-ecosystem: github-actions
directory: /
open-pull-requests-limit: 20
reviewers:
Expand All @@ -17,10 +16,9 @@ updates:
groups:
github-actions:
patterns:
- "*"
- '*'

-
package-ecosystem: npm
- package-ecosystem: npm
directory: /
versioning-strategy: increase
open-pull-requests-limit: 20
Expand All @@ -35,15 +33,15 @@ updates:
- maintenance
groups:
production-dependencies:
dependency-type: "production"
dependency-type: 'production'
development-dependencies:
dependency-type: "development"
dependency-type: 'development'
exclude-patterns:
- "*lint*"
- '*lint*'
lint-dependencies:
patterns:
- "*lint*"
- '*lint*'
alwatr-dependencies:
patterns:
- "@alwatr/*"
- "fract"
- '@alwatr/*'
- 'fract'
10 changes: 2 additions & 8 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@
"cSpell.words": [],
"typescript.tsdk": "node_modules/typescript/lib",
"git.autoStash": true,
"git.branchProtection": [
"main",
"next"
],
"githubPullRequests.ignoredPullRequestBranches": [
"main",
"next"
]
"git.branchProtection": ["main", "next"],
"githubPullRequests.ignoredPullRequestBranches": ["main", "next"]
}
1 change: 0 additions & 1 deletion demo/crypto/rand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ const hashGenerator = new AlwatrHashGenerator(secretGeneratorPreConfig);
for (let i = 0; i <= 10; i++) {
console.log('hash: %s', hashGenerator.randomSelfValidate());
}

6 changes: 4 additions & 2 deletions demo/es-bench/bench.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
if (globalThis.process && (globalThis.process?.env.NODE_ENV !== 'production' || typeof globalThis.gc !== 'function')) {
console.warn('Please run node in production with `--expose-gc` for benchmark\nNODE_ENV=production node --expose-gc demo/...');
console.warn(
'Please run node in production with `--expose-gc` for benchmark\nNODE_ENV=production node --expose-gc demo/...',
);
}

export const bench = (name: string, func: () => void, count = 1_000_000): void => {
Expand All @@ -19,7 +21,7 @@ export const bench = (name: string, func: () => void, count = 1_000_000): void =
console.log(
`run ${name} ${runPerSec.toLocaleString()}/s with ${
globalThis.process?.memoryUsage.rss !== undefined ? memoryUsage.toLocaleString() : '?'
}kb`
}kb`,
);
globalThis.gc?.();
};
7 changes: 2 additions & 5 deletions demo/es-bench/compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,19 @@ const value = undefined;
function test_1(): boolean {
if (value === true) {
return true;
}
else {
} else {
return false;
}
}

function test_2(): boolean {
if (value) {
return true;
}
else {
} else {
return false;
}
}


bench('test_1', test_1);
bench('test_2', test_2);

Expand Down
14 changes: 6 additions & 8 deletions demo/es-bench/flat-str.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import {bench} from './bench.js';

function flatstr (s: string) {
function flatstr(s: string) {
// @ts-ignore
s | 0
return s
s | 0;
return s;
}

let temp = '';

function test_1(): void {
let s = '';
let n = 1_000_000;
while(n--) {
while (n--) {
s += 'ali';
}
temp = s;
Expand All @@ -20,13 +20,12 @@ function test_1(): void {
function test_2(): void {
let s = '';
let n = 1_000_000;
while(n--) {
while (n--) {
s += 'ali';
}
temp = flatstr(s);
}


bench('test_1', test_1, 10);
bench('test_2', test_2, 10);

Expand All @@ -36,5 +35,4 @@ bench('test_2', test_2, 10);
bench('test_1', test_1, 10);
bench('test_2', test_2, 10);


console.log(temp.length)
console.log(temp.length);
2 changes: 1 addition & 1 deletion demo/es-bench/import-tmp.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export {}
export {};

console.log('test');
2 changes: 1 addition & 1 deletion demo/es-bench/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
Expand Down
1 change: 0 additions & 1 deletion demo/es-bench/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,4 @@ bench('test_without_logger 1st', () => test_without_logger(getUserList()));
bench('test_with_logger 2nd', () => test_with_logger(getUserList()));
bench('test_without_logger 2nd', () => test_without_logger(getUserList()));


globalThis.document?.body.append(' Done. Check the console.');
16 changes: 8 additions & 8 deletions demo/es-bench/many-bind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ function test3(id: string): void {
console.log(id);
}

const bind = (id: string) => ({
id,
test1: test1.bind(null, id),
test2: test2.bind(null, id),
test3: test3.bind(null, id),
} as const);
const bind = (id: string) =>
({
id,
test1: test1.bind(null, id),
test2: test2.bind(null, id),
test3: test3.bind(null, id),
}) as const;

class MyClass {
constructor(public id: string) {
}
constructor(public id: string) {}

test1(): void {
console.log(this.id);
Expand Down
11 changes: 5 additions & 6 deletions demo/es-bench/node-exist.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {accessSync, existsSync, constants} from 'node:fs';
import { bench } from './bench.js';
import {bench} from './bench.js';

const filePath = './temp-file.txt';
function exist(): boolean {
Expand All @@ -10,14 +10,13 @@ function access(): boolean {
try {
accessSync(filePath, constants.F_OK);
return true;
}
catch {
return false
} catch {
return false;
}
}

console.log('exist(%s) => %s', filePath, exist())
console.log('access(%s) => %s', filePath, access())
console.log('exist(%s) => %s', filePath, exist());
console.log('access(%s) => %s', filePath, access());

bench('exist', exist);
bench('access', access);
2 changes: 1 addition & 1 deletion demo/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
{"path": "../packages/crypto"},
{"path": "../packages/math"},
{"path": "../packages/util"},
{"path": "../packages/validator"},
{"path": "../packages/validator"}
]
}
57 changes: 8 additions & 49 deletions demo/validator/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,31 @@ import {validator} from '@alwatr/validator';

console.log('basic test');
console.log(
validator<
{num: number; str: string; bool: boolean; _null: null; ali: 'ali'; five: 5; true: true}
>(
validator<{num: number; str: string; bool: boolean; _null: null; ali: 'ali'; five: 5; true: true}>(
{num: Number, str: String, bool: Boolean, _null: null, ali: 'ali', five: 5, true: true},
{num: 123, str: 'test', bool: false, _null: null, ali: 'ali', five: 5, true: true},
),
);

console.log('sanitize value test');
console.log(
validator<
{num: number; str: string; bool: boolean; _null: null; ali: 'ali'; five: 5; true: true}
>(
validator<{num: number; str: string; bool: boolean; _null: null; ali: 'ali'; five: 5; true: true}>(
{num: Number, str: String, bool: Boolean, _null: null, ali: 'ali', five: 5, true: true},
{num: '123', str: 'test', bool: 'false', _null: null, ali: 'ali', five: 5, true: true},
),
);

console.log('nested value test');
console.log(
validator<
{a: {num: number; str: string; bool: boolean; _null: null; ali: 'ali'; five: 5; true: true}}
>(
validator<{a: {num: number; str: string; bool: boolean; _null: null; ali: 'ali'; five: 5; true: true}}>(
{a: {num: Number, str: String, bool: Boolean, _null: null, ali: 'ali', five: 5, true: true}},
{a: {num: '123', str: 'test', bool: 'false', _null: null, ali: 'ali', five: 5, true: true}},
),
);

console.log('not valid test');
try {
console.log(
validator<
{num: number}
>(
{num: Number},
{num: 'test'},
),
);
console.log(validator<{num: number}>({num: Number}, {num: 'test'}));
throw new Error('validator_not_work');
}
catch (err) {
Expand All @@ -52,14 +39,7 @@ catch (err) {
}

try {
console.log(
validator<
{num: boolean}
>(
{num: Boolean},
{num: 'true'},
),
);
console.log(validator<{num: boolean}>({num: Boolean}, {num: 'true'}));
throw new Error('validator_not_work');
}
catch (err) {
Expand All @@ -72,14 +52,7 @@ catch (err) {
}

try {
console.log(
validator<
{num: null}
>(
{num: null},
{num: 'test'},
),
);
console.log(validator<{num: null}>({num: null}, {num: 'test'}));
throw new Error('validator_not_work');
}
catch (err) {
Expand All @@ -92,14 +65,7 @@ catch (err) {
}

try {
console.log(
validator<
{num: number}
>(
{num: Number},
{num: 'test'},
),
);
console.log(validator<{num: number}>({num: Number}, {num: 'test'}));
throw new Error('validator_not_work');
}
catch (err) {
Expand All @@ -112,14 +78,7 @@ catch (err) {
}

try {
console.log(
validator<
{num: string}
>(
{num: 'test'},
{num: 'tes'},
),
);
console.log(validator<{num: string}>({num: 'test'}, {num: 'tes'}));
throw new Error('validator_not_work');
}
catch (err) {
Expand Down
8 changes: 4 additions & 4 deletions packages/crypto/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

### Features

* **crypto:** add some pre config ([4b960c5](https://github.com/AliMD/alwatr/commit/4b960c5cb3f7495c0689adcb65c62a1032ae2650))
- **crypto:** add some pre config ([4b960c5](https://github.com/AliMD/alwatr/commit/4b960c5cb3f7495c0689adcb65c62a1032ae2650))

### Performance Improvements

* **crypto/hash:** enhance crc generator ([ba8c4bc](https://github.com/AliMD/alwatr/commit/ba8c4bcf8f9ec9767b0bd3b6c3fd5c4f503a84dd))
- **crypto/hash:** enhance crc generator ([ba8c4bc](https://github.com/AliMD/alwatr/commit/ba8c4bcf8f9ec9767b0bd3b6c3fd5c4f503a84dd))

# 0.31.0 (2023-05-08)

### Bug Fixes

* **crypto:** package ([866c5f4](https://github.com/AliMD/alwatr/commit/866c5f490ea2eaa75bf177f35b3f4711931e13d2))
- **crypto:** package ([866c5f4](https://github.com/AliMD/alwatr/commit/866c5f490ea2eaa75bf177f35b3f4711931e13d2))

### Features

* **crypto:** make prefix for userId ([5baa00a](https://github.com/AliMD/alwatr/commit/5baa00aafb16a4c6ed1d77913edddd090f732dad))
- **crypto:** make prefix for userId ([5baa00a](https://github.com/AliMD/alwatr/commit/5baa00aafb16a4c6ed1d77913edddd090f732dad))

# [1.0.0](https://github.com/AliMD/alwatr/compare/v0.32.0...v1.0.0) (2023-06-14)

Expand Down
Loading

0 comments on commit 67a3e5f

Please sign in to comment.