加入了pako和axios的测试。

This commit is contained in:
Kane Wang 2023-02-13 16:52:44 +08:00
parent 946cf852d2
commit db0ac8c960
28 changed files with 2048 additions and 1587 deletions

View File

@ -0,0 +1,4 @@
node_modules
dist
target
tsconfig.json

60
code/ts/pako/.eslintrc.js Normal file
View File

@ -0,0 +1,60 @@
/*
* @Author: Kane
* @Date: 2023-02-09 15:26:18
* @LastEditors: Kane
* @LastEditTime: 2023-02-10 10:25:42
* @FilePath: /后端辅助工具/.eslintrc.js
* @Description:
*
* Copyright (c) ${2022} by Kane, All Rights Reserved.
*/
module.exports = {
root: true,
env: {
browser: true,
es2021: true,
node: true,
},
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
// project: ["./tsconfig.json",],
tsconfigRootDir: __dirname,
},
plugins: [
"@typescript-eslint",
],
extends: [
// "standard-with-typescript",
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
],
rules: {
"no-console": "warn",
"quote-props": ["warn", "as-needed",],
quotes: ["warn", "double", { allowTemplateLiterals: true, },],
indent: ["warn", 4,],
"no-unused-vars": "off",
semi: ["error", "always",], // 控制行尾部分号
"comma-dangle": ["error", {
arrays: "always",
objects: "always",
imports: "never",
exports: "never",
functions: "never",
},], // 数组和对象键值对最后一个逗号
"comma-style": ["error", "last",], // 逗号在行位
"array-bracket-spacing": ["error", "never",],
"no-undef-init": "error",
"no-invalid-this": "error",
"no-use-before-define": "error",
"no-shadow-restricted-names": "error", // 禁止对一些关键字或者保留字进行赋值操作比如NaN、Infinity、undefined、eval、arguments等
// "comma-spacing": ["error", { "before": false, "after": true, },],
"brace-style": ["error", "allman", { allowSingleLine: true, },],
"prefer-const": "warn",
"@typescript-eslint/no-extra-semi": "off",
"@typescript-eslint/no-inferrable-types": "off",
},
};

21
code/ts/pako/package-lock.json generated Normal file
View File

@ -0,0 +1,21 @@
{
"name": "pako",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "pako",
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"pako": "^2.1.0"
}
},
"node_modules/pako": {
"version": "2.1.0",
"resolved": "https://registry.npmmirror.com/pako/-/pako-2.1.0.tgz",
"integrity": "sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug=="
}
}
}

19
code/ts/pako/package.json Normal file
View File

@ -0,0 +1,19 @@
{
"name": "pako",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "node index.js"
},
"keywords": [
"pako"
],
"type": "module",
"author": "Kane",
"license": "ISC",
"dependencies": {
"pako": "^2.1.0"
}
}

22
code/ts/pako/src/index.js Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,37 @@
/*
* @Author: Kane
* @Date: 2023-02-13 14:54:46
* @LastEditors: Kane
* @LastEditTime: 2023-02-13 14:55:19
* @FilePath: /pako/src/utils/StringConverter.js
* @Description:
*
* Copyright (c) ${2022} by Kane, All Rights Reserved.
*/
function Uint8ArrayToString(fileData)
{
var dataString = "";
for (var i = 0; i < fileData.length; i++)
{
dataString += String.fromCharCode(fileData[i]);
}
return dataString;
}
function stringToUint8Array(str)
{
var arr = [];
for (var i = 0, j = str.length; i < j; ++i)
{
arr.push(str.charCodeAt(i));
}
var tmpUint8Array = new Uint8Array(arr);
return tmpUint8Array;
}
export { Uint8ArrayToString, stringToUint8Array };

File diff suppressed because it is too large Load Diff

View File

@ -3,5 +3,9 @@
"@typescript-eslint/eslint-plugin": "^5.51.0", "@typescript-eslint/eslint-plugin": "^5.51.0",
"@typescript-eslint/parser": "^5.51.0", "@typescript-eslint/parser": "^5.51.0",
"eslint": "^8.33.0" "eslint": "^8.33.0"
},
"dependencies": {
"axios": "^1.3.2",
"pako": "^2.1.0"
} }
} }

View File

@ -2,7 +2,7 @@
* @Author: Kane * @Author: Kane
* @Date: 2023-02-10 15:08:53 * @Date: 2023-02-10 15:08:53
* @LastEditors: Kane * @LastEditors: Kane
* @LastEditTime: 2023-02-13 00:40:30 * @LastEditTime: 2023-02-13 10:04:33
* @FilePath: //src/DataType/DataType.ts * @FilePath: //src/DataType/DataType.ts
* @Description: * @Description:
* *
@ -61,6 +61,12 @@ function dataTypes()
overplusArugsWithTuple(1, 2, 3, "test"); overplusArugsWithTuple(1, 2, 3, "test");
console.log(overplusArgusWithArray(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); console.log(overplusArgusWithArray(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
//测试null
const nulltest: null = null;
let var_2: { x: string; } = { x: "test", };
// var_2 = null;
} }

View File

@ -0,0 +1,11 @@
/*
* @Author: Kane
* @Date: 2023-02-13 15:46:17
* @LastEditors: Kane
* @LastEditTime: 2023-02-13 15:46:17
* @FilePath: //src/axios/AxiosTest.js
* @Description:
*
* Copyright (c) ${2022} by Kane, All Rights Reserved.
*/
import axios from "axios";

View File

@ -0,0 +1,19 @@
/*
* @Author: Kane
* @Date: 2023-02-13 15:53:45
* @LastEditors: Kane
* @LastEditTime: 2023-02-13 15:56:26
* @FilePath: //src/axios/request.ts
* @Description:
*
* Copyright (c) ${2022} by Kane, All Rights Reserved.
*/
import axios, { AxiosInstance } from "axios";
const service = axios.create({
baseURL: "",
timeout: 10000,
timeoutErrorMessage: "请求超时!",
});

File diff suppressed because one or more lines are too long

View File

@ -2,7 +2,7 @@
* @Author: Kane * @Author: Kane
* @Date: 2023-02-09 22:14:30 * @Date: 2023-02-09 22:14:30
* @LastEditors: Kane * @LastEditors: Kane
* @LastEditTime: 2023-02-12 23:52:33 * @LastEditTime: 2023-02-13 15:59:43
* @FilePath: //src/main.ts * @FilePath: //src/main.ts
* @Description: * @Description:
* *
@ -10,10 +10,12 @@
*/ */
import { dataTypes } from "./DataType/DataType"; import { dataTypes } from "./DataType/DataType";
import { pakoTest } from "./gzip/PakoTest";
const greetings = "hello, this is kane's typescript!"; const greetings = "hello, this is kane's typescript!";
console.log(greetings); console.log(greetings);
console.log("all"); console.log("all");
dataTypes(); //dataTypes();
pakoTest();

View File

@ -0,0 +1,38 @@
/*
* @Author: Kane
* @Date: 2023-02-13 14:54:46
* @LastEditors: Kane
* @LastEditTime: 2023-02-13 14:55:19
* @FilePath: /pako/src/utils/StringConverter.js
* @Description:
*
* Copyright (c) ${2022} by Kane, All Rights Reserved.
*/
function Uint8ArrayToString(fileData: Uint8Array): string
{
let dataString: string = "";
for (let i = 0; i < fileData.length; i++)
{
dataString += String.fromCharCode(fileData[i]);
}
return dataString;
}
function stringToUint8Array(str: string): Uint8Array
{
const arr: number[] = [];
for (let i = 0, j = str.length; i < j; ++i)
{
arr.push(str.charCodeAt(i));
}
const tmpUint8Array: Uint8Array = new Uint8Array(arr);
return tmpUint8Array;
}
export { Uint8ArrayToString, stringToUint8Array };

View File

@ -3,7 +3,7 @@
* @Author: Kane * @Author: Kane
* @Date: 2023-02-10 15:08:53 * @Date: 2023-02-10 15:08:53
* @LastEditors: Kane * @LastEditors: Kane
* @LastEditTime: 2023-02-13 00:40:30 * @LastEditTime: 2023-02-13 10:04:33
* @FilePath: //src/DataType/DataType.ts * @FilePath: //src/DataType/DataType.ts
* @Description: * @Description:
* *
@ -11,39 +11,48 @@
*/ */
/*eslint no-unused-vars: "off" */ /*eslint no-unused-vars: "off" */
/*eslint @typescript-eslint/no-unused-vars: "off" */ /*eslint @typescript-eslint/no-unused-vars: "off" */
Object.defineProperty(exports, "__esModule", { value: true }); exports.__esModule = true;
exports.dataTypes = void 0; exports.dataTypes = void 0;
//Tuple //Tuple
function dataTypes() function dataTypes() {
{ var tu = [1, 1, 2,];
const tu = [1, 1, 2,]; var toArray = [1, 2, "3",];
const toArray = [1, 2, "3",]; var v1 = toArray;
const v1 = toArray; var s1 = "string";
const s1 = "string";
console.log(typeof s1); console.log(typeof s1);
let point; var point;
point = { x: 0, y: 0, }; point = { x: 0, y: 0 };
function addOne(x, y = 1) function addOne(x, y) {
{ if (y === void 0) { y = 1; }
return x + y; return x + y;
} }
console.log(addOne(1)); console.log(addOne(1));
function allParams(x, y) function allParams(x, y) {
{ var z = x + y;
const z = x + y;
} }
//剩余参数,数组形式 //剩余参数,数组形式
function overplusArgusWithArray(x, ...argus) function overplusArgusWithArray(x) {
{ var argus = [];
for (var _i = 1; _i < arguments.length; _i++) {
argus[_i - 1] = arguments[_i];
}
return argus.length; return argus.length;
} }
function overplusArugsWithTuple(x, ...argus) function overplusArugsWithTuple(x) {
{ var argus = [];
console.log(`元组形式的参数表${argus},剩余参数的数量${argus.length}`); for (var _i = 1; _i < arguments.length; _i++) {
argus[_i - 1] = arguments[_i];
}
console.log("\u5143\u7EC4\u5F62\u5F0F\u7684\u53C2\u6570\u8868".concat(argus, ",\u5269\u4F59\u53C2\u6570\u7684\u6570\u91CF").concat(argus.length, "\u3002"));
console.log(argus[2]); console.log(argus[2]);
return argus.length; return argus.length;
} }
overplusArugsWithTuple(1, 2, 3, "test"); overplusArugsWithTuple(1, 2, 3, "test");
console.log(overplusArgusWithArray(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); console.log(overplusArgusWithArray(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
//测试null
var nulltest = null;
var var_2 = { x: "test" };
// var_2 = null;
} }
exports.dataTypes = dataTypes; exports.dataTypes = dataTypes;
//# sourceMappingURL=DataType.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"DataType.js","sourceRoot":"","sources":["../../src/DataType/DataType.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;AACH,iCAAiC;AACjC,oDAAoD;;;AAGpD,OAAO;AACP,SAAS,SAAS;IAEd,IAAM,EAAE,GAAsC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IAEzD,IAAM,OAAO,GAA6B,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;IACvD,IAAM,EAAE,GAAwB,OAAO,CAAC;IAExC,IAAM,EAAE,GAAG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C;IAC5B,IAAI,KAAK,GAAmB,EAAE,CAAC,EAAE,MAAM,EAAG,CAAC;IAE3C,gBAAgB;AACpB,CAAC;AAGQ,8BAAS"}

View File

@ -0,0 +1,3 @@
"use strict";
exports.__esModule = true;
//# sourceMappingURL=AxiosTest.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"AxiosTest.js","sourceRoot":"","sources":["../../src/axios/AxiosTest.ts"],"names":[],"mappings":""}

View File

@ -0,0 +1,19 @@
"use strict";
exports.__esModule = true;
/*
* @Author: Kane
* @Date: 2023-02-13 15:53:45
* @LastEditors: Kane
* @LastEditTime: 2023-02-13 15:56:26
* @FilePath: //src/axios/request.ts
* @Description:
*
* Copyright (c) ${2022} by Kane, All Rights Reserved.
*/
var axios_1 = require("axios");
var service = axios_1["default"].create({
baseURL: "",
timeout: 10000,
timeoutErrorMessage: "请求超时!"
});
//# sourceMappingURL=request.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/axios/request.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;GASG;AACH,+BAA6C;AAE7C,IAAM,OAAO,GAAG,kBAAK,CAAC,MAAM,CAAC;IACzB,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,KAAK;IACd,mBAAmB,EAAE,OAAO;CAC/B,CAAC,CAAC"}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
{"version":3,"file":"PakoTest.js","sourceRoot":"","sources":["../../src/gzip/PakoTest.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAEH,6BAAwC;AACxC,wDAAgF;AAEhF,SAAS,QAAQ;IAEb,IAAM,QAAQ,GAAW,45MAA4pI,CAAC;IACtrI,IAAM,OAAO,GAAG,IAAA,kCAAkB,EAAC,QAAQ,CAAC,CAAC;IAE7C,IAAM,UAAU,GAAG,IAAA,cAAO,EAAC,OAAO,CAAC,CAAC;IACpC,IAAM,YAAY,GAAG,IAAA,kCAAkB,EAAC,IAAA,cAAO,EAAC,UAAU,CAAC,CAAC,CAAC;IAE7D,OAAO,CAAC,GAAG,CAAC,8CAAS,UAAU,CAAE,CAAC,CAAC;IACnC,uCAAuC;AAC3C,CAAC;AAEQ,4BAAQ"}

View File

@ -3,15 +3,17 @@
* @Author: Kane * @Author: Kane
* @Date: 2023-02-09 22:14:30 * @Date: 2023-02-09 22:14:30
* @LastEditors: Kane * @LastEditors: Kane
* @LastEditTime: 2023-02-13 09:31:28 * @LastEditTime: 2023-02-13 15:59:43
* @FilePath: //target/main.js * @FilePath: //src/main.ts
* @Description: * @Description:
* *
* Copyright (c) ${2022} by Kane, All Rights Reserved. * Copyright (c) ${2022} by Kane, All Rights Reserved.
*/ */
Object.defineProperty(exports, "__esModule", { value: true }); exports.__esModule = true;
const DataType_1 = require("./DataType/DataType"); var PakoTest_1 = require("./gzip/PakoTest");
const greetings = "hello, this is kane's typescript!"; var greetings = "hello, this is kane's typescript!";
console.log(greetings); console.log(greetings);
console.log("all"); console.log("all");
(0, DataType_1.dataTypes)(); //dataTypes();
(0, PakoTest_1.pakoTest)();
//# sourceMappingURL=main.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;AAGH,4CAA2C;AAE3C,IAAM,SAAS,GAAG,mCAAmC,CAAC;AAEtD,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AACvB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAEnB,cAAc;AACd,IAAA,mBAAQ,GAAE,CAAC"}

View File

@ -0,0 +1,31 @@
"use strict";
/*
* @Author: Kane
* @Date: 2023-02-13 14:54:46
* @LastEditors: Kane
* @LastEditTime: 2023-02-13 14:55:19
* @FilePath: /pako/src/utils/StringConverter.js
* @Description:
*
* Copyright (c) ${2022} by Kane, All Rights Reserved.
*/
exports.__esModule = true;
exports.stringToUint8Array = exports.Uint8ArrayToString = void 0;
function Uint8ArrayToString(fileData) {
var dataString = "";
for (var i = 0; i < fileData.length; i++) {
dataString += String.fromCharCode(fileData[i]);
}
return dataString;
}
exports.Uint8ArrayToString = Uint8ArrayToString;
function stringToUint8Array(str) {
var arr = [];
for (var i = 0, j = str.length; i < j; ++i) {
arr.push(str.charCodeAt(i));
}
var tmpUint8Array = new Uint8Array(arr);
return tmpUint8Array;
}
exports.stringToUint8Array = stringToUint8Array;
//# sourceMappingURL=StringConvert.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"StringConvert.js","sourceRoot":"","sources":["../../src/utils/StringConvert.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAEH,SAAS,kBAAkB,CAAC,QAAoB;IAE5C,IAAI,UAAU,GAAW,EAAE,CAAC;IAE5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EACxC;QACI,UAAU,IAAI,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;KAClD;IAED,OAAO,UAAU,CAAC;AACtB,CAAC;AAgBQ,gDAAkB;AAd3B,SAAS,kBAAkB,CAAC,GAAW;IAEnC,IAAM,GAAG,GAAa,EAAE,CAAC;IAEzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,EAC1C;QACI,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;KAC/B;IAED,IAAM,aAAa,GAAe,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC;IAEtD,OAAO,aAAa,CAAC;AACzB,CAAC;AAE4B,gDAAkB"}

View File

@ -2,7 +2,7 @@
* @Author: Kane * @Author: Kane
* @Date: 2023-02-09 15:24:20 * @Date: 2023-02-09 15:24:20
* @LastEditors: Kane * @LastEditors: Kane
* @LastEditTime: 2023-02-10 10:16:40 * @LastEditTime: 2023-02-13 15:58:39
* @FilePath: //tsconfig.json * @FilePath: //tsconfig.json
* @Description: * @Description:
* *
@ -13,6 +13,7 @@
"outDir": "./target", "outDir": "./target",
"strict": false, "strict": false,
"strictNullChecks": true, "strictNullChecks": true,
"sourceMap": true,
}, },
// "files": [ // "files": [
// "./src/main.ts", // "./src/main.ts",

File diff suppressed because one or more lines are too long