tuijs-util 1.2.0 → 1.2.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/README.md CHANGED
@@ -11,13 +11,13 @@ All utilities are provide both in ESM and CJS formats. Simply specific utility y
11
11
 
12
12
  ## ESM
13
13
  ```javascript
14
- import { utilFunctionName, utilFunctionName2 } from 'ttbjs';
14
+ import { utilFunctionName, utilFunctionName2 } from 'tuijs-util';
15
15
  utilFunctionName();
16
16
  utilFunctionName2();
17
17
  ```
18
18
  ## CJS
19
19
  ```javascript
20
- const { utilFunctionName, utilFunctionName2 } = require('ttbjs');
20
+ const { utilFunctionName, utilFunctionName2 } = require('tuijs-util');
21
21
  utilFunctionName();
22
22
  utilFunctionName2();
23
23
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tuijs-util",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "module": "src/esm/index.js",
5
5
  "main": "src/cjs/index.cjs",
6
6
  "exports": {
@@ -41,10 +41,15 @@ export function checkSpecialChar(str) {
41
41
  }
42
42
  }
43
43
 
44
- // Checks for a valid Email (uses regex)
44
+ /**
45
+ * Determines if an input string is a valid email address using RegEx.
46
+ * @param {string} str - String input
47
+ * @returns {boolean} - Return false if the string is not an email and true if it is.
48
+ * @throws {Error} - Throws Error if input is not a string or if another error occurs.
49
+ */
45
50
  export function checkEmail(str) {
46
51
  try {
47
- if (str === null || typeof str !== "string") {
52
+ if (str === null || typeof str !== 'string') {
48
53
  throw new Error(`Invalid input.`);
49
54
  };
50
55
  var validRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
@@ -53,7 +58,7 @@ export function checkEmail(str) {
53
58
  }
54
59
  return false;
55
60
  } catch (er) {
56
- throw new Error(er);
61
+ throw new Error(er.message);
57
62
  }
58
63
  }
59
64