@unikue/ts-lang-utils 1.2.11 → 1.2.12

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.
@@ -9,6 +9,7 @@ export { isAlphanumericLower } from './isAlphanumericLower';
9
9
  export { isAlphanumericUpper } from './isAlphanumericUpper';
10
10
  export { isCompilable } from './isCompilable';
11
11
  export { isEmail } from './isEmail';
12
+ export { isMobile } from './isMobile';
12
13
  export { isNumeric } from './isNumeric';
13
14
  export { normalizePattern } from './normalizePattern';
14
15
  export { testResetting } from './testResetting';
@@ -30,6 +30,7 @@ __export(RegexUtils_exports, {
30
30
  isAlphanumericUpper: () => import_isAlphanumericUpper.isAlphanumericUpper,
31
31
  isCompilable: () => import_isCompilable.isCompilable,
32
32
  isEmail: () => import_isEmail.isEmail,
33
+ isMobile: () => import_isMobile.isMobile,
33
34
  isNumeric: () => import_isNumeric.isNumeric,
34
35
  normalizePattern: () => import_normalizePattern.normalizePattern,
35
36
  testResetting: () => import_testResetting.testResetting,
@@ -47,6 +48,7 @@ var import_isAlphanumericLower = require("./isAlphanumericLower");
47
48
  var import_isAlphanumericUpper = require("./isAlphanumericUpper");
48
49
  var import_isCompilable = require("./isCompilable");
49
50
  var import_isEmail = require("./isEmail");
51
+ var import_isMobile = require("./isMobile");
50
52
  var import_isNumeric = require("./isNumeric");
51
53
  var import_normalizePattern = require("./normalizePattern");
52
54
  var import_testResetting = require("./testResetting");
@@ -64,6 +66,7 @@ var import_unescapePattern = require("./unescapePattern");
64
66
  isAlphanumericUpper,
65
67
  isCompilable,
66
68
  isEmail,
69
+ isMobile,
67
70
  isNumeric,
68
71
  normalizePattern,
69
72
  testResetting,
@@ -1 +1,2 @@
1
+ export declare const EMAIL_REGEX: RegExp;
1
2
  export declare function isEmail(text?: string | null): boolean;
@@ -19,13 +19,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // src/util/RegexUtils/isEmail.ts
20
20
  var isEmail_exports = {};
21
21
  __export(isEmail_exports, {
22
+ EMAIL_REGEX: () => EMAIL_REGEX,
22
23
  isEmail: () => isEmail
23
24
  });
24
25
  module.exports = __toCommonJS(isEmail_exports);
26
+ var EMAIL_REGEX = /^[^\s@]+@[A-Za-z0-9\u00A0-\uFFFF-]+(?:\.[A-Za-z0-9\u00A0-\uFFFF-]+)*\.[A-Za-z\u00A0-\uFFFF]{2,}$/;
25
27
  function isEmail(text) {
26
- return !!text && /^[A-Za-z0-9._%+-]+@[-A-Za-z0-9.]+\.[A-Za-z]{2,}$/.test(text);
28
+ return !!text && EMAIL_REGEX.test(text);
27
29
  }
28
30
  // Annotate the CommonJS export names for ESM import in node:
29
31
  0 && (module.exports = {
32
+ EMAIL_REGEX,
30
33
  isEmail
31
34
  });
@@ -0,0 +1,2 @@
1
+ export declare const CHINA_MOBILE_REGEX: RegExp;
2
+ export declare function isMobile(text?: string | null, pattern?: string | RegExp): boolean;
@@ -0,0 +1,42 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/util/RegexUtils/isMobile.ts
20
+ var isMobile_exports = {};
21
+ __export(isMobile_exports, {
22
+ CHINA_MOBILE_REGEX: () => CHINA_MOBILE_REGEX,
23
+ isMobile: () => isMobile
24
+ });
25
+ module.exports = __toCommonJS(isMobile_exports);
26
+ var import_compilePattern = require("./compilePattern");
27
+ var CHINA_MOBILE_REGEX = /^1[3-9]\d{9}$/;
28
+ function isMobile(text, pattern = CHINA_MOBILE_REGEX) {
29
+ if (!text) {
30
+ return false;
31
+ }
32
+ if (typeof pattern === "string") {
33
+ const regex = (0, import_compilePattern.compilePattern)(pattern);
34
+ return !!regex && regex.test(text);
35
+ }
36
+ return pattern.test(text);
37
+ }
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {
40
+ CHINA_MOBILE_REGEX,
41
+ isMobile
42
+ });
@@ -9,6 +9,7 @@ export { isAlphanumericLower } from './isAlphanumericLower';
9
9
  export { isAlphanumericUpper } from './isAlphanumericUpper';
10
10
  export { isCompilable } from './isCompilable';
11
11
  export { isEmail } from './isEmail';
12
+ export { isMobile } from './isMobile';
12
13
  export { isNumeric } from './isNumeric';
13
14
  export { normalizePattern } from './normalizePattern';
14
15
  export { testResetting } from './testResetting';
@@ -9,6 +9,7 @@ export { isAlphanumericLower } from "./isAlphanumericLower";
9
9
  export { isAlphanumericUpper } from "./isAlphanumericUpper";
10
10
  export { isCompilable } from "./isCompilable";
11
11
  export { isEmail } from "./isEmail";
12
+ export { isMobile } from "./isMobile";
12
13
  export { isNumeric } from "./isNumeric";
13
14
  export { normalizePattern } from "./normalizePattern";
14
15
  export { testResetting } from "./testResetting";
@@ -1 +1,2 @@
1
+ export declare const EMAIL_REGEX: RegExp;
1
2
  export declare function isEmail(text?: string | null): boolean;
@@ -1,3 +1,4 @@
1
+ export var EMAIL_REGEX = /^[^\s@]+@[A-Za-z0-9\u00A0-\uFFFF-]+(?:\.[A-Za-z0-9\u00A0-\uFFFF-]+)*\.[A-Za-z\u00A0-\uFFFF]{2,}$/;
1
2
  export function isEmail(text) {
2
- return !!text && /^[A-Za-z0-9._%+-]+@[-A-Za-z0-9.]+\.[A-Za-z]{2,}$/.test(text);
3
+ return !!text && EMAIL_REGEX.test(text);
3
4
  }
@@ -0,0 +1,2 @@
1
+ export declare const CHINA_MOBILE_REGEX: RegExp;
2
+ export declare function isMobile(text?: string | null, pattern?: string | RegExp): boolean;
@@ -0,0 +1,13 @@
1
+ import { compilePattern } from "./compilePattern";
2
+ export var CHINA_MOBILE_REGEX = /^1[3-9]\d{9}$/;
3
+ export function isMobile(text) {
4
+ var pattern = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : CHINA_MOBILE_REGEX;
5
+ if (!text) {
6
+ return false;
7
+ }
8
+ if (typeof pattern === 'string') {
9
+ var regex = compilePattern(pattern);
10
+ return !!regex && regex.test(text);
11
+ }
12
+ return pattern.test(text);
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unikue/ts-lang-utils",
3
- "version": "1.2.11",
3
+ "version": "1.2.12",
4
4
  "title": "TsLangUtils",
5
5
  "description": "Common lang utilities for typescript",
6
6
  "homepage": "https://unikueltd.github.io/ts-lang-utils",
@@ -55,28 +55,28 @@
55
55
  "@babel/runtime": "^7.29.7",
56
56
  "@imranbarbhuiya/duration": "^5.1.8",
57
57
  "lodash": "^4.18.1",
58
- "nanoid": "^3.3.16",
58
+ "nanoid": "^3.3.18",
59
59
  "universal-cookie": "^8.1.2"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@eslint/eslintrc": "^3.3.6",
63
63
  "@eslint/js": "^10.0.1",
64
64
  "@types/jest": "^30.0.0",
65
- "@types/lodash": "^4.17.24",
65
+ "@types/lodash": "^4.17.25",
66
66
  "@unikue/babel-plugin-remove-comment": "^1.2.1",
67
67
  "@unikue/typedoc-plugin-raw-content": "^1.1.1",
68
68
  "@unikue/typedoc-theme-dumi": "^1.1.3",
69
69
  "del-cli": "^7.0.0",
70
- "eslint": "^10.7.0",
71
- "eslint-plugin-jest": "^29.15.4",
72
- "father": "^4.6.31",
70
+ "eslint": "^10.9.1",
71
+ "eslint-plugin-jest": "^29.16.5",
72
+ "father": "^4.6.36",
73
73
  "gh-pages": "^6.3.0",
74
- "globals": "^17.7.0",
75
- "jest-environment-jsdom": "^30.4.1",
76
- "ts-jest": "^29.4.11",
74
+ "globals": "^17.11.0",
75
+ "jest-environment-jsdom": "^30.5.0",
76
+ "ts-jest": "^29.4.12",
77
77
  "typedoc": "~0.28.20",
78
78
  "typescript": "^6.0.3",
79
- "typescript-eslint": "^8.64.0"
79
+ "typescript-eslint": "^8.68.0"
80
80
  },
81
81
  "peerDependencies": {
82
82
  "typescript": ">=4.0.0"