@lijuhong1981/jscheck 1.0.2 → 1.0.4

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,4 +1,6 @@
1
1
  import Check from "./src/Check.js";
2
+ import defined from "./src/defined.js";
3
+ import definedValue from "./src/definedValue.js";
2
4
  import isArray from "./src/isArray.js";
3
5
  import isBoolean from "./src/isBoolean.js";
4
6
  import isFunction from "./src/isFunction.js";
@@ -7,11 +9,13 @@ import isNumber from "./src/isNumber.js";
7
9
  import isObject from "./src/isObject.js";
8
10
  import isString from "./src/isString.js";
9
11
  import isTypedArray from "./src/isTypedArray.js";
10
- import isDefined from "./src/isDefined.js";
11
12
  import isValid from "./src/isValid.js";
13
+ import getValidValue from "./src/getValidValue.js";
12
14
 
13
15
  export default Check;
14
16
  export {
17
+ defined,
18
+ definedValue,
15
19
  isArray,
16
20
  isBoolean,
17
21
  isFunction,
@@ -20,6 +24,6 @@ export {
20
24
  isObject,
21
25
  isString,
22
26
  isTypedArray,
23
- isDefined,
24
27
  isValid,
28
+ getValidValue,
25
29
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lijuhong1981/jscheck",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
package/src/Check.js CHANGED
@@ -1,4 +1,4 @@
1
- import isDefined from "./isDefined.js";
1
+ import defined from "./defined.js";
2
2
  import isValid from "./isValid.js";
3
3
 
4
4
  const Check = {};
@@ -24,8 +24,8 @@ function getFailedTypeErrorMessage(actual, expected, name) {
24
24
  );
25
25
  }
26
26
 
27
- Check.isDefined = function (name, test) {
28
- if (!isDefined(test)) {
27
+ Check.defined = function (name, test) {
28
+ if (!defined(test)) {
29
29
  throw new Error(getUndefinedErrorMessage(name));
30
30
  }
31
31
  };
package/src/defined.js ADDED
@@ -0,0 +1,5 @@
1
+ function defined(value) {
2
+ return value !== undefined && value !== null;
3
+ };
4
+
5
+ export default defined;
@@ -0,0 +1,10 @@
1
+ import defined from "./defined.js";
2
+
3
+ function definedValue(...args) {
4
+ for (let i = 0; i < args.length; i++) {
5
+ if (defined(args[i]))
6
+ return args[i];
7
+ }
8
+ };
9
+
10
+ export default definedValue;
@@ -0,0 +1,10 @@
1
+ import isValid from "./isValid.js";
2
+
3
+ function getValidValue(...args) {
4
+ for (let i = 0; i < args.length; i++) {
5
+ if (isValid(args[i]))
6
+ return args[i];
7
+ }
8
+ };
9
+
10
+ export default getValidValue;
package/src/isDefined.js DELETED
@@ -1,5 +0,0 @@
1
- function isDefined(value) {
2
- return value !== undefined && value !== null;
3
- };
4
-
5
- export default isDefined;