@maiyunnet/kebab 2.0.1 → 2.0.2

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.
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MOD_CWD = exports.FTMP_CWD = exports.IND_CWD = exports.WWW_CWD = exports.LOG_CWD = exports.LIB_CWD = exports.VHOST_CWD = exports.CERT_CWD = exports.CONF_CWD = exports.ROOT_CWD = exports.SYS_PATH = exports.LIB_PATH = exports.ROOT_PATH = exports.VER = void 0;
4
- exports.VER = '2.0.1';
4
+ exports.VER = '2.0.2';
5
5
  const dirname = __dirname.replace(/\\/g, '/');
6
6
  exports.ROOT_PATH = dirname + '/';
7
7
  exports.LIB_PATH = exports.ROOT_PATH + 'lib/';
package/index.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  /** --- 当前系统版本号 --- */
9
- export const VER = '2.0.1';
9
+ export const VER = '2.0.2';
10
10
 
11
11
  // --- 服务端用的路径 ---
12
12
 
package/lib/text.js CHANGED
@@ -56,6 +56,7 @@ exports.getFilename = getFilename;
56
56
  exports.stringifyResult = stringifyResult;
57
57
  exports.parseJson = parseJson;
58
58
  exports.stringifyJson = stringifyJson;
59
+ exports.isFalsy = isFalsy;
59
60
  exports.str2int = str2int;
60
61
  exports.int2str = int2str;
61
62
  const kebab = __importStar(require("~/index"));
@@ -427,6 +428,9 @@ function stringifyJson(obj, space) {
427
428
  return v;
428
429
  }, space).replace(/"-mybigint-([-+0-9]+?)"/g, '$1');
429
430
  }
431
+ function isFalsy(val) {
432
+ return (val === null || val === undefined || val === '' || val === false || val === 0) ? true : false;
433
+ }
430
434
  function str2int(str, digits = 3) {
431
435
  const num = parseFloat(str);
432
436
  const factor = Math.pow(10, digits);
package/lib/text.ts CHANGED
@@ -551,6 +551,14 @@ export function stringifyJson(obj: types.Json, space?: string | number): string
551
551
  }, space).replace(/"-mybigint-([-+0-9]+?)"/g, '$1');
552
552
  }
553
553
 
554
+ /**
555
+ * --- 判断一个值是否是虚假的(为 null/undefined/空字符串/false/0 等) ---
556
+ * @param val 要判断的值
557
+ */
558
+ export function isFalsy(val: any): boolean {
559
+ return (val === null || val === undefined || val === '' || val === false || val === 0) ? true : false;
560
+ }
561
+
554
562
  /**
555
563
  * --- 为解决精度问题,将字符串数字转换为整数显示 ---
556
564
  * --- 以下几个示例都是当 digits 为 2 时 ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maiyunnet/kebab",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "Simple, easy-to-use, and fully-featured Node.js framework that is ready-to-use out of the box.",
5
5
  "keywords": [
6
6
  "kebab",