@zwa73/utils 1.0.91 → 1.0.93

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,35 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
2
28
  Object.defineProperty(exports, "__esModule", { value: true });
3
29
  exports.SLogger = void 0;
4
- const path = require("path");
5
- const winston = require("winston");
6
- const DailyRotateFile = require("winston-daily-rotate-file");
30
+ const path = __importStar(require("path"));
31
+ const winston = __importStar(require("winston"));
32
+ const winston_daily_rotate_file_1 = __importDefault(require("winston-daily-rotate-file"));
7
33
  const util_1 = require("util");
8
34
  const logLevels = {
9
35
  fatal: 0,
@@ -56,7 +82,7 @@ class SLogger {
56
82
  let messageList = message.split("\n");
57
83
  return `[${info.timestamp}] [${level.toUpperCase()}]: ${messageList.join("\n")}`;
58
84
  }));
59
- transports.push(new DailyRotateFile({
85
+ transports.push(new winston_daily_rotate_file_1.default({
60
86
  filename: path.join(outFloder, 'log-%DATE%.txt'),
61
87
  datePattern: 'YYYY-MM-DD',
62
88
  level: fileLevel,
@@ -232,18 +258,18 @@ class SLogger {
232
258
  let format = '';
233
259
  let acc = 0;
234
260
  const maxAcc = 3;
235
- let concat = function (num, sep, formatText, resultText) {
236
- let hasResult = result.length > 0;
237
- let need = (hasResult || num > 0) && (acc < maxAcc);
238
- if (need) {
239
- if (result.length > 0)
240
- result += sep;
241
- if (format.length > 0)
242
- format += sep;
243
- result += resultText;
244
- format += formatText;
245
- acc++;
246
- }
261
+ const concat = (num, sep, formatText, resultText) => {
262
+ const hasResult = result.length > 0;
263
+ const need = (hasResult || num > 0) && (acc < maxAcc);
264
+ if (!need)
265
+ return;
266
+ if (result.length > 0)
267
+ result += sep;
268
+ if (format.length > 0)
269
+ format += sep;
270
+ result += resultText;
271
+ format += formatText;
272
+ acc++;
247
273
  };
248
274
  concat(Days, ':', 'dd', `${Days.toString()}`);
249
275
  concat(hours, ':', 'HH', `${hours.toString().padStart(2, '0')}`);
@@ -261,7 +287,7 @@ class SLogger {
261
287
  out = `${totalMilliseconds.toFixed(3)}ms`;
262
288
  }
263
289
  if (level !== null)
264
- this.log(level, flag + ": " + out);
290
+ this.log(level, `${flag}: ${out}`);
265
291
  delete SLogger.timeTable[flag];
266
292
  return out;
267
293
  }
@@ -274,7 +300,7 @@ class SLogger {
274
300
  }
275
301
  /**让名称为default的logger 产生一条对应等级的log 返回自身
276
302
  * @param level - log等级
277
- * @param messages - log消息
303
+ * @param messages - log消息
278
304
  * @returns 自身
279
305
  */
280
306
  static log(level, ...messages) {
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@zwa73/utils",
3
- "version": "1.0.91",
3
+ "version": "1.0.93",
4
4
  "description": "my utils",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "test": "call npm run compile && jest",
8
8
  "postinstall": "start node ./scripts/postinstall.js",
9
- "release": "call release.bat",
9
+ "release": "call npm run compile && call node release.js && call npm publish --access public",
10
10
  "compile": "call tsc -p tsconfig.compile.json && call tsc-alias -p tsconfig.compile.json",
11
11
  "watch": "start tsc-alias -w -p tsconfig.compile.json && start tsc -w -p tsconfig.compile.json"
12
12
  },
package/release.bat CHANGED
@@ -1,4 +1,2 @@
1
- call npm run compile
2
- call node build.js
3
- call npm publish --access public
1
+ call npm run release
4
2
  pause
@@ -9,6 +9,8 @@ export const {
9
9
  isFailed,
10
10
  isSafeNumber,
11
11
  isSuccess,
12
+ likeNone,
13
+ expect,
12
14
  assertType,
13
15
  assertLiteral,
14
16
  deepClone,