Skip to content

Commit 223a8b7

Browse files
committed
feat: 优化代码
1 parent 3524edd commit 223a8b7

File tree

4 files changed

+4
-2
lines changed

4 files changed

+4
-2
lines changed

build/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
99
};
1010
Object.defineProperty(exports, "__esModule", { value: true });
1111
const curd_1 = require("./curd");
12+
const mysql2 = require("mysql2");
1213
let connection = null;
1314
let ispool = true;
1415
//建立sql对象
@@ -27,7 +28,6 @@ mysql.prototype.exec = exec;
2728
* @param {Config} config
2829
*/
2930
function init(config) {
30-
const mysql2 = require('mysql2');
3131
ispool = typeof (config.ispool) === 'boolean' ? config.ispool : true;
3232
if (ispool) {
3333
connection = mysql2.createPool({

build/uitl.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ function sortArray(data) {
201201
const item = Object.keys(data[0]);
202202
for (let i = 1; i < data.length; i++) {
203203
for (let j = 0; j < item.length; j++) {
204+
// @ts-ignore
204205
if (!Object.keys(data[i]).includes(item[j])) {
205206
item.splice(j, 1);
206207
}

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88
import { Config } from './types'
99
import CURD from './curd'
10+
import * as mysql2 from 'mysql2'
1011

1112

1213
let connection: any = null;
@@ -38,7 +39,6 @@ mysql.prototype.exec = exec;
3839
* @param {Config} config
3940
*/
4041
export function init(config: Config) {
41-
const mysql2 = require('mysql2');
4242
ispool = typeof(config.ispool) === 'boolean' ? config.ispool : true;
4343
if (ispool) {
4444
connection = mysql2.createPool({

src/uitl.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ function sortArray(data: AnyOpt[]){
201201
const item = Object.keys(data[0])
202202
for (let i = 1; i < data.length; i++) {
203203
for (let j = 0; j < item.length; j++) {
204+
// @ts-ignore
204205
if (!Object.keys(data[i]).includes(item[j])){
205206
item.splice(j, 1);
206207
}

0 commit comments

Comments
 (0)