@icreate/core
Advanced tools
Comparing version 0.0.22 to 0.0.23
@@ -170,3 +170,3 @@ /* | ||
* @LastEditors: 文贝 | ||
* @LastEditTime: 2022-03-11 10:03:58 | ||
* @LastEditTime: 2022-03-28 13:56:55 | ||
* @Descripttion: | ||
@@ -178,12 +178,4 @@ * @FilePath: \src\core\logger.ts | ||
this.level = LogLevels.DEBUG; | ||
this.color = { | ||
debug: '#6e6e6e', | ||
info: '#2a53cd', | ||
warn: '#f4bd00', | ||
error: '#ce9178', | ||
fatal: '#eb3941' | ||
}; | ||
} | ||
Logger.prototype.log = function (logObject, logLevel, color) { | ||
if (color === void 0) { color = null; } | ||
Logger.prototype.log = function (logObject, logLevel) { | ||
if (typeof window === 'undefined' || !window.console || !window.console.log) { | ||
@@ -195,8 +187,3 @@ return; | ||
} | ||
if (color) { | ||
console.log(logObject, "color: " + color + ";font-size: 14px;font-weight: bold;line-height: 19px;font-family: Consolas, \"Courier New\", monospace;"); | ||
} | ||
else { | ||
console.log(logObject); | ||
} | ||
console.log(logObject); | ||
}; | ||
@@ -207,7 +194,5 @@ /** | ||
*/ | ||
Logger.prototype.debug = function (logObject, message) { | ||
if (message === void 0) { message = ''; } | ||
this.log("%c" + new Date().toLocaleString() + " [DEBUG] (" + message + ")", LogLevels.DEBUG, this.color.debug); | ||
Logger.prototype.debug = function (logObject) { | ||
this.log('DEBUG: ', LogLevels.DEBUG); | ||
this.log(logObject, LogLevels.DEBUG); | ||
this.log('', LogLevels.DEBUG); | ||
}; | ||
@@ -218,7 +203,5 @@ /** | ||
*/ | ||
Logger.prototype.info = function (logObject, message) { | ||
if (message === void 0) { message = ''; } | ||
this.log("%c" + new Date().toLocaleString() + " [INFO] (" + message + ")", LogLevels.INFO, this.color.info); | ||
Logger.prototype.info = function (logObject) { | ||
this.log('INFO: ', LogLevels.INFO); | ||
this.log(logObject, LogLevels.INFO); | ||
this.log('', LogLevels.INFO); | ||
}; | ||
@@ -229,7 +212,5 @@ /** | ||
*/ | ||
Logger.prototype.warn = function (logObject, message) { | ||
if (message === void 0) { message = ''; } | ||
this.log("%c" + new Date().toLocaleString() + " [WARN] (" + message + ")", LogLevels.WARN, this.color.warn); | ||
Logger.prototype.warn = function (logObject) { | ||
this.log('WARN: ', LogLevels.WARN); | ||
this.log(logObject, LogLevels.WARN); | ||
this.log('', LogLevels.WARN); | ||
}; | ||
@@ -240,7 +221,5 @@ /** | ||
*/ | ||
Logger.prototype.error = function (logObject, message) { | ||
if (message === void 0) { message = ''; } | ||
this.log("%c" + new Date().toLocaleString() + " [ERROR] (" + message + ")", LogLevels.ERROR, this.color.error); | ||
Logger.prototype.error = function (logObject) { | ||
this.log('ERROR: ', LogLevels.ERROR); | ||
this.log(logObject, LogLevels.ERROR); | ||
this.log('', LogLevels.ERROR); | ||
}; | ||
@@ -251,7 +230,5 @@ /** | ||
*/ | ||
Logger.prototype.fatal = function (logObject, message) { | ||
if (message === void 0) { message = ''; } | ||
this.log("%c" + new Date().toLocaleString() + " [FATAL] (" + message + ")", LogLevels.FATAL, this.color.fatal); | ||
Logger.prototype.fatal = function (logObject) { | ||
this.log('FATAL: ', LogLevels.FATAL); | ||
this.log(logObject, LogLevels.FATAL); | ||
this.log('', LogLevels.FATAL); | ||
}; | ||
@@ -287,2 +264,3 @@ return Logger; | ||
var md5 = require('js-md5'); | ||
var Utils = /** @class */ (function () { | ||
@@ -349,2 +327,14 @@ function Utils() { | ||
}; | ||
//驼峰转短横线 | ||
Utils.CamelCasetoKebab = function (value) { | ||
return value.replace(/([A-Z])/g, '-$1').toLowerCase(); | ||
}; | ||
//短横线转小驼峰 | ||
Utils.KebabtoCamelCase = function (value) { | ||
return value.replace(/-(\w)/g, function ($0, $1) { return $1.toUpperCase(); }); | ||
}; | ||
//短横线转大驼峰 | ||
Utils.KebabtoPascalCase = function (value) { | ||
return value[0].toUpperCase() + value.slice(1).replace(/-(\w)/g, function ($0, $1) { return $1.toUpperCase(); }); | ||
}; | ||
Utils.truncateString = function (str, maxLength) { | ||
@@ -370,3 +360,4 @@ if (!str || !str.length || str.length <= maxLength) { | ||
Utils.isString = function (obj) { | ||
return Object.prototype.toString.call(obj) === "[object String]"; | ||
//判断对象是否是字符串 | ||
return Object.prototype.toString.call(obj) === '[object String]'; | ||
}; | ||
@@ -465,2 +456,5 @@ /** | ||
}; | ||
Utils.md5 = function (message) { | ||
return md5(message); | ||
}; | ||
Utils.function = function (opts) { | ||
@@ -467,0 +461,0 @@ var _this = this; |
@@ -175,3 +175,3 @@ (function (global, factory) { | ||
* @LastEditors: 文贝 | ||
* @LastEditTime: 2022-03-11 10:03:58 | ||
* @LastEditTime: 2022-03-28 13:56:55 | ||
* @Descripttion: | ||
@@ -183,12 +183,4 @@ * @FilePath: \src\core\logger.ts | ||
this.level = exports.LogLevels.DEBUG; | ||
this.color = { | ||
debug: '#6e6e6e', | ||
info: '#2a53cd', | ||
warn: '#f4bd00', | ||
error: '#ce9178', | ||
fatal: '#eb3941' | ||
}; | ||
} | ||
Logger.prototype.log = function (logObject, logLevel, color) { | ||
if (color === void 0) { color = null; } | ||
Logger.prototype.log = function (logObject, logLevel) { | ||
if (typeof window === 'undefined' || !window.console || !window.console.log) { | ||
@@ -200,8 +192,3 @@ return; | ||
} | ||
if (color) { | ||
console.log(logObject, "color: " + color + ";font-size: 14px;font-weight: bold;line-height: 19px;font-family: Consolas, \"Courier New\", monospace;"); | ||
} | ||
else { | ||
console.log(logObject); | ||
} | ||
console.log(logObject); | ||
}; | ||
@@ -212,7 +199,5 @@ /** | ||
*/ | ||
Logger.prototype.debug = function (logObject, message) { | ||
if (message === void 0) { message = ''; } | ||
this.log("%c" + new Date().toLocaleString() + " [DEBUG] (" + message + ")", exports.LogLevels.DEBUG, this.color.debug); | ||
Logger.prototype.debug = function (logObject) { | ||
this.log('DEBUG: ', exports.LogLevels.DEBUG); | ||
this.log(logObject, exports.LogLevels.DEBUG); | ||
this.log('', exports.LogLevels.DEBUG); | ||
}; | ||
@@ -223,7 +208,5 @@ /** | ||
*/ | ||
Logger.prototype.info = function (logObject, message) { | ||
if (message === void 0) { message = ''; } | ||
this.log("%c" + new Date().toLocaleString() + " [INFO] (" + message + ")", exports.LogLevels.INFO, this.color.info); | ||
Logger.prototype.info = function (logObject) { | ||
this.log('INFO: ', exports.LogLevels.INFO); | ||
this.log(logObject, exports.LogLevels.INFO); | ||
this.log('', exports.LogLevels.INFO); | ||
}; | ||
@@ -234,7 +217,5 @@ /** | ||
*/ | ||
Logger.prototype.warn = function (logObject, message) { | ||
if (message === void 0) { message = ''; } | ||
this.log("%c" + new Date().toLocaleString() + " [WARN] (" + message + ")", exports.LogLevels.WARN, this.color.warn); | ||
Logger.prototype.warn = function (logObject) { | ||
this.log('WARN: ', exports.LogLevels.WARN); | ||
this.log(logObject, exports.LogLevels.WARN); | ||
this.log('', exports.LogLevels.WARN); | ||
}; | ||
@@ -245,7 +226,5 @@ /** | ||
*/ | ||
Logger.prototype.error = function (logObject, message) { | ||
if (message === void 0) { message = ''; } | ||
this.log("%c" + new Date().toLocaleString() + " [ERROR] (" + message + ")", exports.LogLevels.ERROR, this.color.error); | ||
Logger.prototype.error = function (logObject) { | ||
this.log('ERROR: ', exports.LogLevels.ERROR); | ||
this.log(logObject, exports.LogLevels.ERROR); | ||
this.log('', exports.LogLevels.ERROR); | ||
}; | ||
@@ -256,7 +235,5 @@ /** | ||
*/ | ||
Logger.prototype.fatal = function (logObject, message) { | ||
if (message === void 0) { message = ''; } | ||
this.log("%c" + new Date().toLocaleString() + " [FATAL] (" + message + ")", exports.LogLevels.FATAL, this.color.fatal); | ||
Logger.prototype.fatal = function (logObject) { | ||
this.log('FATAL: ', exports.LogLevels.FATAL); | ||
this.log(logObject, exports.LogLevels.FATAL); | ||
this.log('', exports.LogLevels.FATAL); | ||
}; | ||
@@ -292,2 +269,3 @@ return Logger; | ||
var md5 = require('js-md5'); | ||
var Utils = /** @class */ (function () { | ||
@@ -354,2 +332,14 @@ function Utils() { | ||
}; | ||
//驼峰转短横线 | ||
Utils.CamelCasetoKebab = function (value) { | ||
return value.replace(/([A-Z])/g, '-$1').toLowerCase(); | ||
}; | ||
//短横线转小驼峰 | ||
Utils.KebabtoCamelCase = function (value) { | ||
return value.replace(/-(\w)/g, function ($0, $1) { return $1.toUpperCase(); }); | ||
}; | ||
//短横线转大驼峰 | ||
Utils.KebabtoPascalCase = function (value) { | ||
return value[0].toUpperCase() + value.slice(1).replace(/-(\w)/g, function ($0, $1) { return $1.toUpperCase(); }); | ||
}; | ||
Utils.truncateString = function (str, maxLength) { | ||
@@ -375,3 +365,4 @@ if (!str || !str.length || str.length <= maxLength) { | ||
Utils.isString = function (obj) { | ||
return Object.prototype.toString.call(obj) === "[object String]"; | ||
//判断对象是否是字符串 | ||
return Object.prototype.toString.call(obj) === '[object String]'; | ||
}; | ||
@@ -470,2 +461,5 @@ /** | ||
}; | ||
Utils.md5 = function (message) { | ||
return md5(message); | ||
}; | ||
Utils.function = function (opts) { | ||
@@ -472,0 +466,0 @@ var _this = this; |
@@ -7,3 +7,3 @@ "use strict"; | ||
* @LastEditors: 文贝 | ||
* @LastEditTime: 2022-03-11 10:03:58 | ||
* @LastEditTime: 2022-03-28 13:56:55 | ||
* @Descripttion: | ||
@@ -16,12 +16,4 @@ * @FilePath: \src\core\logger.ts | ||
this.level = interfaces_1.LogLevels.DEBUG; | ||
this.color = { | ||
debug: '#6e6e6e', | ||
info: '#2a53cd', | ||
warn: '#f4bd00', | ||
error: '#ce9178', | ||
fatal: '#eb3941' | ||
}; | ||
} | ||
Logger.prototype.log = function (logObject, logLevel, color) { | ||
if (color === void 0) { color = null; } | ||
Logger.prototype.log = function (logObject, logLevel) { | ||
if (typeof window === 'undefined' || !window.console || !window.console.log) { | ||
@@ -33,8 +25,3 @@ return; | ||
} | ||
if (color) { | ||
console.log(logObject, "color: " + color + ";font-size: 14px;font-weight: bold;line-height: 19px;font-family: Consolas, \"Courier New\", monospace;"); | ||
} | ||
else { | ||
console.log(logObject); | ||
} | ||
console.log(logObject); | ||
}; | ||
@@ -45,7 +32,5 @@ /** | ||
*/ | ||
Logger.prototype.debug = function (logObject, message) { | ||
if (message === void 0) { message = ''; } | ||
this.log("%c" + new Date().toLocaleString() + " [DEBUG] (" + message + ")", interfaces_1.LogLevels.DEBUG, this.color.debug); | ||
Logger.prototype.debug = function (logObject) { | ||
this.log('DEBUG: ', interfaces_1.LogLevels.DEBUG); | ||
this.log(logObject, interfaces_1.LogLevels.DEBUG); | ||
this.log('', interfaces_1.LogLevels.DEBUG); | ||
}; | ||
@@ -56,7 +41,5 @@ /** | ||
*/ | ||
Logger.prototype.info = function (logObject, message) { | ||
if (message === void 0) { message = ''; } | ||
this.log("%c" + new Date().toLocaleString() + " [INFO] (" + message + ")", interfaces_1.LogLevels.INFO, this.color.info); | ||
Logger.prototype.info = function (logObject) { | ||
this.log('INFO: ', interfaces_1.LogLevels.INFO); | ||
this.log(logObject, interfaces_1.LogLevels.INFO); | ||
this.log('', interfaces_1.LogLevels.INFO); | ||
}; | ||
@@ -67,7 +50,5 @@ /** | ||
*/ | ||
Logger.prototype.warn = function (logObject, message) { | ||
if (message === void 0) { message = ''; } | ||
this.log("%c" + new Date().toLocaleString() + " [WARN] (" + message + ")", interfaces_1.LogLevels.WARN, this.color.warn); | ||
Logger.prototype.warn = function (logObject) { | ||
this.log('WARN: ', interfaces_1.LogLevels.WARN); | ||
this.log(logObject, interfaces_1.LogLevels.WARN); | ||
this.log('', interfaces_1.LogLevels.WARN); | ||
}; | ||
@@ -78,7 +59,5 @@ /** | ||
*/ | ||
Logger.prototype.error = function (logObject, message) { | ||
if (message === void 0) { message = ''; } | ||
this.log("%c" + new Date().toLocaleString() + " [ERROR] (" + message + ")", interfaces_1.LogLevels.ERROR, this.color.error); | ||
Logger.prototype.error = function (logObject) { | ||
this.log('ERROR: ', interfaces_1.LogLevels.ERROR); | ||
this.log(logObject, interfaces_1.LogLevels.ERROR); | ||
this.log('', interfaces_1.LogLevels.ERROR); | ||
}; | ||
@@ -89,7 +68,5 @@ /** | ||
*/ | ||
Logger.prototype.fatal = function (logObject, message) { | ||
if (message === void 0) { message = ''; } | ||
this.log("%c" + new Date().toLocaleString() + " [FATAL] (" + message + ")", interfaces_1.LogLevels.FATAL, this.color.fatal); | ||
Logger.prototype.fatal = function (logObject) { | ||
this.log('FATAL: ', interfaces_1.LogLevels.FATAL); | ||
this.log(logObject, interfaces_1.LogLevels.FATAL); | ||
this.log('', interfaces_1.LogLevels.FATAL); | ||
}; | ||
@@ -96,0 +73,0 @@ return Logger; |
@@ -18,3 +18,3 @@ "use strict"; | ||
* @LastEditors: 文贝 | ||
* @LastEditTime: 2022-03-10 15:59:20 | ||
* @LastEditTime: 2022-03-28 13:17:46 | ||
* @Descripttion: | ||
@@ -24,2 +24,3 @@ * @FilePath: \src\core\utils.ts | ||
var interfaces_1 = require("../interfaces/interfaces"); | ||
var md5 = require('js-md5'); | ||
var Utils = /** @class */ (function () { | ||
@@ -86,2 +87,14 @@ function Utils() { | ||
}; | ||
//驼峰转短横线 | ||
Utils.CamelCasetoKebab = function (value) { | ||
return value.replace(/([A-Z])/g, '-$1').toLowerCase(); | ||
}; | ||
//短横线转小驼峰 | ||
Utils.KebabtoCamelCase = function (value) { | ||
return value.replace(/-(\w)/g, function ($0, $1) { return $1.toUpperCase(); }); | ||
}; | ||
//短横线转大驼峰 | ||
Utils.KebabtoPascalCase = function (value) { | ||
return value[0].toUpperCase() + value.slice(1).replace(/-(\w)/g, function ($0, $1) { return $1.toUpperCase(); }); | ||
}; | ||
Utils.truncateString = function (str, maxLength) { | ||
@@ -107,3 +120,4 @@ if (!str || !str.length || str.length <= maxLength) { | ||
Utils.isString = function (obj) { | ||
return Object.prototype.toString.call(obj) === "[object String]"; | ||
//判断对象是否是字符串 | ||
return Object.prototype.toString.call(obj) === '[object String]'; | ||
}; | ||
@@ -202,2 +216,5 @@ /** | ||
}; | ||
Utils.md5 = function (message) { | ||
return md5(message); | ||
}; | ||
Utils.function = function (opts) { | ||
@@ -204,0 +221,0 @@ var _this = this; |
import { ILogger, LogLevels } from '../interfaces/interfaces'; | ||
export default class Logger implements ILogger { | ||
level: LogLevels; | ||
private color; | ||
private log; | ||
@@ -10,3 +9,3 @@ /** | ||
*/ | ||
debug(logObject: any, message?: string): void; | ||
debug(logObject: any): void; | ||
/** | ||
@@ -16,3 +15,3 @@ * @description: 输出信息日志 | ||
*/ | ||
info(logObject: any, message?: string): void; | ||
info(logObject: any): void; | ||
/** | ||
@@ -22,3 +21,3 @@ * @description: 输出警告日志 | ||
*/ | ||
warn(logObject: any, message?: string): void; | ||
warn(logObject: any): void; | ||
/** | ||
@@ -28,3 +27,3 @@ * @description: 输出错误日志 | ||
*/ | ||
error(logObject: any, message?: string): void; | ||
error(logObject: any): void; | ||
/** | ||
@@ -34,3 +33,3 @@ * @description: 输出致命错误日志 | ||
*/ | ||
fatal(logObject: any, message?: string): void; | ||
fatal(logObject: any): void; | ||
} |
@@ -10,2 +10,5 @@ import { ExecOptons } from '../interfaces/interfaces'; | ||
static toCamelCase(str: string): string; | ||
static CamelCasetoKebab(value: string): string; | ||
static KebabtoCamelCase(value: string): string; | ||
static KebabtoPascalCase(value: string): string; | ||
static truncateString(str: string, maxLength: number): string; | ||
@@ -46,2 +49,3 @@ static truncateStringWithPostfix(str: string, maxLength: number, postfix: string): string; | ||
static command(opts: ExecOptons): void; | ||
static md5(message: string): string; | ||
static function(opts: ExecOptons): Promise<any>; | ||
@@ -48,0 +52,0 @@ private static _ajax; |
{ | ||
"name": "@icreate/core", | ||
"version": "0.0.22", | ||
"version": "0.0.23", | ||
"description": "Ics核心包封装", | ||
@@ -24,3 +24,4 @@ "keywords": [], | ||
"prebuild": "rimraf dist", | ||
"build": "tsc --module commonjs && rollup -c rollup.config.ts && typedoc --out docs --target es6 --theme minimal --mode file src", | ||
"build": "tsc --module commonjs && rollup -c rollup.config.ts", | ||
"build:doc": "tsc --module commonjs && rollup -c rollup.config.ts && typedoc --out docs --target es6 --theme minimal --mode file src", | ||
"start": "rollup -c rollup.config.ts -w", | ||
@@ -27,0 +28,0 @@ "test": "jest --coverage", |
@@ -5,3 +5,3 @@ <!-- | ||
* @LastEditors: 文贝 | ||
* @LastEditTime: 2022-02-12 02:25:50 | ||
* @LastEditTime: 2022-02-12 02:10:59 | ||
* @Descripttion: | ||
@@ -79,13 +79,1 @@ * @FilePath: \README.md | ||
``` | ||
### ics | ||
```javascript | ||
appPath: string = '/' | ||
pageLoadTime = new Date() | ||
toAbsAppPath(path: string): string | ||
event: IEvent | ||
ui: IBlockUI | ||
log: ILogger | ||
utils: Utils | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
152686
1921
78