@wizhut_tech/wizjs 0.0.5 → 0.0.6

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,6 +1,7 @@
1
1
  const t = require('tap');
2
2
 
3
- const { isNil } = require('../src/lang/checks.js');
3
+ const { isNil, isArray, isObject, isNumber, isString } = require('../src/lang/checks.js');
4
+
4
5
 
5
6
 
6
7
  t.test('checks/isNil', (t) => {
@@ -10,4 +11,46 @@ t.test('checks/isNil', (t) => {
10
11
  t.equal(isNil(1.0), false);
11
12
  t.equal(isNil('not-null-string'), false);
12
13
  t.end();
13
- });
14
+ });
15
+
16
+ t.test('checks/isArray', (t) => {
17
+ t.equal(isArray([]), true);
18
+ t.equal(isArray(1), false);
19
+ t.equal(isArray('misc'), false);
20
+ t.equal(isArray(null), false);
21
+ t.equal(isArray(undefined), false);
22
+ t.equal(isArray({}), false);
23
+ t.end();
24
+ });
25
+
26
+ t.test('checks/isObject', (t) => {
27
+ t.equal(isObject(null), false);
28
+ t.equal(isObject(undefined), false);
29
+ t.equal(isObject(1), false);
30
+ t.equal(isObject('misc'), false);
31
+ t.equal(isObject({}), true);
32
+ t.equal(isObject([]), false);
33
+ t.end();
34
+ });
35
+
36
+ t.test('checks/isNumber', (t) => {
37
+ t.equal(isNumber(null), false);
38
+ t.equal(isNumber(undefined), false);
39
+ t.equal(isNumber({}), false);
40
+ t.equal(isNumber([]), false);
41
+ t.equal(isNumber(1), true);
42
+ t.equal(isNumber(1.1), true);
43
+ t.equal(isNumber('misc'), false);
44
+ t.end();
45
+ });
46
+
47
+ t.test('checks/isString', (t) => {
48
+ t.equal(isString(null), false);
49
+ t.equal(isString(undefined), false);
50
+ t.equal(isString({}), false);
51
+ t.equal(isString([]), false);
52
+ t.equal(isString(1), false);
53
+ t.equal(isString(1.1), false);
54
+ t.equal(isString('misc'), true);
55
+ t.end();
56
+ })
@@ -0,0 +1,9 @@
1
+ const t = require('tap');
2
+
3
+ const { reflexive } = require('../src/lang/functools.js');
4
+
5
+
6
+ t.test('functools/reflexive', (t) => {
7
+ t.equal(reflexive(null), null);
8
+ t.end();
9
+ });
@@ -1,3 +1,7 @@
1
1
  # Lang / Checks
2
2
 
3
- * **isNil(arg)**: Check if the `arg` is `undefined` or `null` and returns `true` (or `false` otherwise).
3
+ * **isNil(arg)**: Checks if the `arg` is `undefined` or `null` and returns `true` (or `false` otherwise).
4
+ * **isArray(arg)**: Checks if the `arg` is an `array` and return `true` else `false`
5
+ * **isObject(arg)**: Checks if the `arg` is an `object` and return `true` else `false`
6
+ * **isString(arg)**: Checks if the `arg` is a `string` and return `true` else `false`
7
+ * **isNumber(arg)**: Checks if the `arg` is a `number` and return `true` else `false`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wizhut_tech/wizjs",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "main": "index.js",
5
5
  "devDependencies": {
6
6
  "tap": "21.0.1"
@@ -3,7 +3,37 @@ function isNil(value) {
3
3
  return value === null || value === undefined;
4
4
  }
5
5
 
6
+ function isArray(value) {
7
+ return Array.isArray(value);
8
+ }
9
+
10
+ function isObject(value) {
11
+ if (isNil(value)) {
12
+ return false;
13
+ }
14
+
15
+ if (isArray(value)) {
16
+ return false;
17
+ }
18
+
19
+ return typeof value === 'object';
20
+ }
21
+
22
+
23
+ function isString(value) {
24
+ return typeof value === 'string';
25
+ }
26
+
27
+
28
+ function isNumber(value) {
29
+ return typeof value === 'number';
30
+ }
31
+
6
32
 
7
33
  module.exports = {
8
- isNil
34
+ isNil,
35
+ isArray,
36
+ isObject,
37
+ isString,
38
+ isNumber
9
39
  }