jis 1.0.36 → 2.0.1
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/.gitlab-ci.yml +55 -0
- package/package.json +23 -16
- package/src/Is.ts +17 -15
- package/src/interfaces/main.ts +3 -0
- package/src/main.ts +2 -1
- package/test/array.test.ts +19 -0
- package/test/boolean.test.ts +19 -0
- package/test/empty.test.ts +63 -0
- package/test/function.test.ts +15 -0
- package/test/is.test.ts +59 -0
- package/test/null.test.ts +19 -0
- package/test/number.test.ts +15 -0
- package/test/numeric.test.ts +63 -0
- package/test/object.test.ts +15 -0
- package/test/primitive.test.ts +47 -0
- package/test/string.test.ts +18 -0
- package/test/undefined.test.ts +14 -0
- package/tsconfig.json +23 -12
- package/vite.config.ts +28 -0
- package/dist/jis.js +0 -160
- package/dist/jis.min.js +0 -1
- package/index.html +0 -10
- package/test.js +0 -143
- package/types/index.d.ts +0 -3
- package/webpack.config.js +0 -41
package/.gitlab-ci.yml
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
|
|
2
|
+
image: node:20
|
|
3
|
+
|
|
4
|
+
workflow:
|
|
5
|
+
rules:
|
|
6
|
+
- when: always
|
|
7
|
+
|
|
8
|
+
stages:
|
|
9
|
+
- setup
|
|
10
|
+
- test
|
|
11
|
+
- deploy
|
|
12
|
+
|
|
13
|
+
.default_rules:
|
|
14
|
+
rules:
|
|
15
|
+
- if: $CI_COMMIT_BRANCH
|
|
16
|
+
- if: $CI_MERGE_REQUEST_ID
|
|
17
|
+
- if: $CI_COMMIT_TAG
|
|
18
|
+
|
|
19
|
+
install_and_build:
|
|
20
|
+
stage: setup
|
|
21
|
+
extends: .default_rules
|
|
22
|
+
script:
|
|
23
|
+
- yarn install --frozen-lockfile
|
|
24
|
+
- yarn build
|
|
25
|
+
artifacts:
|
|
26
|
+
paths:
|
|
27
|
+
- node_modules/
|
|
28
|
+
- .yarn/
|
|
29
|
+
- yarn.lock
|
|
30
|
+
- dist/
|
|
31
|
+
expire_in: 15 mins
|
|
32
|
+
|
|
33
|
+
run_tests:
|
|
34
|
+
stage: test
|
|
35
|
+
extends: .default_rules
|
|
36
|
+
dependencies:
|
|
37
|
+
- install_and_build
|
|
38
|
+
script:
|
|
39
|
+
- yarn test
|
|
40
|
+
|
|
41
|
+
publish_npm:
|
|
42
|
+
stage: deploy
|
|
43
|
+
rules:
|
|
44
|
+
- if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+/
|
|
45
|
+
dependencies:
|
|
46
|
+
- install_and_build
|
|
47
|
+
script:
|
|
48
|
+
- PACKAGE_VERSION=$(node -p "require('./package.json').version")
|
|
49
|
+
- |
|
|
50
|
+
if [ "$PACKAGE_VERSION" != "${CI_COMMIT_TAG#v}" ]; then
|
|
51
|
+
echo "Error: Version mismatch ($PACKAGE_VERSION vs $CI_COMMIT_TAG)"
|
|
52
|
+
exit 1
|
|
53
|
+
fi
|
|
54
|
+
- echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
|
|
55
|
+
- npm publish --access public
|
package/package.json
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jis",
|
|
3
|
-
"
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "2.0.1",
|
|
4
5
|
"description": "When you need validate the variable data type",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/jis.umd.cjs",
|
|
8
|
+
"module": "./dist/jis.js",
|
|
9
|
+
"types": "./dist/main.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/main.d.ts",
|
|
13
|
+
"import": "./dist/jis.js",
|
|
14
|
+
"require": "./dist/jis.umd.cjs"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
7
17
|
"scripts": {
|
|
8
|
-
"
|
|
9
|
-
"build": "
|
|
18
|
+
"dev": "vite",
|
|
19
|
+
"build": "tsc && vite build",
|
|
20
|
+
"preview": "vite preview",
|
|
21
|
+
"test": "vitest run"
|
|
10
22
|
},
|
|
11
23
|
"keywords": [
|
|
12
24
|
"Is",
|
|
@@ -20,20 +32,15 @@
|
|
|
20
32
|
],
|
|
21
33
|
"repository": {
|
|
22
34
|
"type": "git",
|
|
23
|
-
"url": "https://gitlab.com/
|
|
35
|
+
"url": "git+https://gitlab.com/josebasmtzdev/jis.git"
|
|
24
36
|
},
|
|
25
37
|
"author": "Jose Can <joseluisgpecanmtz@gmail.com>",
|
|
26
38
|
"license": "ISC",
|
|
27
39
|
"devDependencies": {
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"typescript": "^4.0.5",
|
|
34
|
-
"webpack-cli": "^4.7.0"
|
|
35
|
-
},
|
|
36
|
-
"dependencies": {
|
|
37
|
-
"webpack": "^5.37.1"
|
|
40
|
+
"@types/node": "^25.0.3",
|
|
41
|
+
"typescript": "~5.9.3",
|
|
42
|
+
"vite": "^7.2.4",
|
|
43
|
+
"vite-plugin-dts": "^4.5.4",
|
|
44
|
+
"vitest": "^4.0.16"
|
|
38
45
|
}
|
|
39
46
|
}
|
package/src/Is.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type {Gen} from "./interfaces/main.ts";
|
|
2
|
+
|
|
1
3
|
export default class Is{
|
|
2
4
|
private static callToString(arg:any) {
|
|
3
5
|
return Object.prototype.toString.call(arg)
|
|
@@ -7,7 +9,7 @@ export default class Is{
|
|
|
7
9
|
return Is.callToString(arg) === '[object String]';
|
|
8
10
|
}
|
|
9
11
|
|
|
10
|
-
static is(arg:any, type){
|
|
12
|
+
static is(arg: any, type : any){
|
|
11
13
|
if(Is.$function(type))
|
|
12
14
|
{
|
|
13
15
|
return arg instanceof type;
|
|
@@ -21,47 +23,47 @@ export default class Is{
|
|
|
21
23
|
return arg === type;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
static $array(arg:any){
|
|
26
|
+
static $array(arg: any){
|
|
25
27
|
return Is.is(arg, 'Array');
|
|
26
28
|
}
|
|
27
29
|
|
|
28
|
-
static $null(arg:any){
|
|
30
|
+
static $null(arg: any){
|
|
29
31
|
return Is.is(arg, 'Null');
|
|
30
32
|
}
|
|
31
33
|
|
|
32
|
-
static $number(arg:any){
|
|
34
|
+
static $number(arg: any){
|
|
33
35
|
return Is.is(arg, 'Number');
|
|
34
36
|
}
|
|
35
37
|
|
|
36
|
-
static $object(arg:any){
|
|
38
|
+
static $object(arg: any){
|
|
37
39
|
return Is.is(arg, 'Object');
|
|
38
40
|
}
|
|
39
41
|
|
|
40
|
-
static $undefined(arg:any){
|
|
42
|
+
static $undefined(arg: any){
|
|
41
43
|
return Is.is(arg, 'Undefined');
|
|
42
44
|
}
|
|
43
45
|
|
|
44
|
-
static $boolean(arg:any){
|
|
46
|
+
static $boolean(arg: any){
|
|
45
47
|
return Is.is(arg, 'Boolean');
|
|
46
48
|
}
|
|
47
49
|
|
|
48
|
-
static $function(arg:any){
|
|
50
|
+
static $function(arg: any){
|
|
49
51
|
return Is.callToString(arg) === '[object Function]';
|
|
50
52
|
}
|
|
51
53
|
|
|
52
|
-
static objectIsValid(data:
|
|
54
|
+
static objectIsValid(data: Gen, rules: Gen) {
|
|
53
55
|
if (!Is.$object(data)) throw new Error('The data parameter must be an Object');
|
|
54
56
|
if (!Is.$object(rules)) throw new Error('The rules parameter must be an Object');
|
|
55
57
|
|
|
56
58
|
let $response = true;
|
|
57
59
|
let $keys = Object.getOwnPropertyNames(rules);
|
|
58
60
|
|
|
59
|
-
$keys.forEach((key) => {
|
|
61
|
+
$keys.forEach((key: string) => {
|
|
60
62
|
let rule = rules[key];
|
|
61
63
|
if (Is.$array(rule)) {
|
|
62
64
|
if (rule.length < 1) return;
|
|
63
65
|
let parcial = false;
|
|
64
|
-
rule.forEach((_rule) => {
|
|
66
|
+
rule.forEach((_rule: any) => {
|
|
65
67
|
parcial = parcial || Is.is(data[key], _rule);
|
|
66
68
|
});
|
|
67
69
|
return $response = $response && parcial;
|
|
@@ -92,7 +94,7 @@ export default class Is{
|
|
|
92
94
|
Is.$boolean,
|
|
93
95
|
Is.$number,
|
|
94
96
|
Is.$string,
|
|
95
|
-
(arg) => Is.is(arg, 'Symbol')
|
|
97
|
+
(arg: any) => Is.is(arg, 'Symbol')
|
|
96
98
|
]
|
|
97
99
|
|
|
98
100
|
return validations.some(item => item(arg))
|
|
@@ -104,9 +106,9 @@ export default class Is{
|
|
|
104
106
|
Is.$undefined,
|
|
105
107
|
Is.$null,
|
|
106
108
|
|
|
107
|
-
(arg) => Is.$boolean(arg) && !arg,
|
|
108
|
-
(arg) => Is.$number(arg) && arg === 0,
|
|
109
|
-
(arg) => (Is.$array(arg) || Is.$string(arg)) && (arg === "0" || (arg as any[]|string).length === 0)
|
|
109
|
+
(arg: any) => Is.$boolean(arg) && !arg,
|
|
110
|
+
(arg: any) => Is.$number(arg) && arg === 0,
|
|
111
|
+
(arg: any) => (Is.$array(arg) || Is.$string(arg)) && (arg === "0" || (arg as any[]|string).length === 0)
|
|
110
112
|
]
|
|
111
113
|
|
|
112
114
|
return validations.some(item => item(arg))
|
package/src/main.ts
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
import {expect, test, describe} from "vitest";
|
|
3
|
+
import jis from "jis";
|
|
4
|
+
|
|
5
|
+
const { $array } = jis;
|
|
6
|
+
|
|
7
|
+
describe("$array method", () => {
|
|
8
|
+
test("jis.$array('') returns false", () => {
|
|
9
|
+
expect($array('')).toBe(false);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test("jis.$array(1) returns false", () => {
|
|
13
|
+
expect($array(1)).toBe(false);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test("jis.$array([]) returns true", () => {
|
|
17
|
+
expect($array([])).toBe(true);
|
|
18
|
+
});
|
|
19
|
+
})
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
import {describe, test, expect} from "vitest";
|
|
3
|
+
import jis from "jis";
|
|
4
|
+
|
|
5
|
+
const { $boolean } = jis;
|
|
6
|
+
|
|
7
|
+
describe("$boolean method", () => {
|
|
8
|
+
test("jis.$boolean('') returns false", () => {
|
|
9
|
+
expect($boolean('')).toBe(false)
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test("jis.$boolean(false) returns false", () => {
|
|
13
|
+
expect($boolean(false)).toBe(true)
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
test("jis.$boolean(true) returns false", () => {
|
|
17
|
+
expect($boolean(true)).toBe(true)
|
|
18
|
+
})
|
|
19
|
+
})
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
|
+
import jis from "jis";
|
|
3
|
+
|
|
4
|
+
const { $empty } = jis;
|
|
5
|
+
|
|
6
|
+
describe("$empty method", () => {
|
|
7
|
+
test("jis.$empty(null) returns true", () => {
|
|
8
|
+
expect($empty(null)).toBe(true);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test("jis.$empty(undefined) returns true", () => {
|
|
12
|
+
expect($empty(undefined)).toBe(true);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test("jis.$empty(false) returns true", () => {
|
|
16
|
+
expect($empty(false)).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("jis.$empty(0) returns true", () => {
|
|
20
|
+
expect($empty(0)).toBe(true);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test("jis.$empty(0.0) returns true", () => {
|
|
24
|
+
expect($empty(0.0)).toBe(true);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("jis.$empty('') returns true", () => {
|
|
28
|
+
expect($empty('')).toBe(true);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test("jis.$empty('0') returns true", () => {
|
|
32
|
+
expect($empty('0')).toBe(true);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test("jis.$empty([]) returns true", () => {
|
|
36
|
+
expect($empty([])).toBe(true);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
test("jis.$empty(true) returns false", () => {
|
|
41
|
+
expect($empty(true)).toBe(false);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test("jis.$empty(12) returns false", () => {
|
|
45
|
+
expect($empty(12)).toBe(false);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test("jis.$empty(12.0) returns false", () => {
|
|
49
|
+
expect($empty(12.0)).toBe(false);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test("jis.$empty('something') returns false", () => {
|
|
53
|
+
expect($empty('something')).toBe(false);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test("jis.$empty('012') returns false", () => {
|
|
57
|
+
expect($empty('012')).toBe(false);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test("jis.$empty([1, 2, 3]) returns false", () => {
|
|
61
|
+
expect($empty([1, 2, 3])).toBe(false);
|
|
62
|
+
});
|
|
63
|
+
})
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
import {expect, test, describe} from "vitest";
|
|
3
|
+
import jis from "jis";
|
|
4
|
+
|
|
5
|
+
const { $function } = jis;
|
|
6
|
+
|
|
7
|
+
describe("$function method", () => {
|
|
8
|
+
test("jis.$function('') returns false", () => {
|
|
9
|
+
expect($function('')).toBe(false)
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test("jis.$function(function(){}) returns true", () => {
|
|
13
|
+
expect($function(function(){})).toBe(true)
|
|
14
|
+
});
|
|
15
|
+
});
|
package/test/is.test.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {describe, expect, test} from "vitest";
|
|
2
|
+
import jis from "jis";
|
|
3
|
+
|
|
4
|
+
const { is } = jis;
|
|
5
|
+
|
|
6
|
+
describe('"is" method', () => {
|
|
7
|
+
test("jis.is([], 'Array') returns true", () => {
|
|
8
|
+
expect(is([], 'Array')).toBe(true);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test("jis.is(false, 'Boolean') returns true", () => {
|
|
12
|
+
expect(is(false, 'Boolean')).toBe(true);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test("jis.is(true, 'Boolean') returns true", () => {
|
|
16
|
+
expect(is(true, 'Boolean')).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("jis.is(function() {}, 'Function' returns true", () => {
|
|
20
|
+
expect(is(function() {}, 'Function')).toBe(true);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test("jis.is(null, 'Null') returns true", () => {
|
|
24
|
+
expect(is(null, 'Null')).toBe(true);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("jis.is(12, 'Number') returns true", () => {
|
|
28
|
+
expect(is(12, 'Number')).toBe(true);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test("jis.is({}, 'Object') returns true", () => {
|
|
32
|
+
expect(is({}, 'Object')).toBe(true);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test("jis.is('Text','String') returns true", () => {
|
|
36
|
+
expect(is('Text','String')).toBe(true);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test("jis.is(undefined, 'Undefined') returns true", () => {
|
|
40
|
+
expect(is(undefined, 'Undefined')).toBe(true);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test("jis.is(date, Date) returns true", () => {
|
|
44
|
+
const date = new Date();
|
|
45
|
+
expect(is(date, Date)).toBe(true);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test("jis.is(/^$/g, RegExp) returns true", () => {
|
|
49
|
+
expect(is(/^$/g, RegExp)).toBe(true);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test("jis.is(/^$/g, 'RegExp') returns true", () => {
|
|
53
|
+
expect(is(/^$/g, 'RegExp')).toBe(true);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test("jis.is(12, 12) returns true", () => {
|
|
57
|
+
expect(is(12, 12)).toBe(true);
|
|
58
|
+
});
|
|
59
|
+
})
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
import {test, expect, describe} from "vitest";
|
|
3
|
+
import jis from "jis";
|
|
4
|
+
|
|
5
|
+
const { $null } = jis;
|
|
6
|
+
|
|
7
|
+
describe("$null method", () => {
|
|
8
|
+
test("jis.$null(true) returns false", () => {
|
|
9
|
+
expect($null(true)).toBe(false);
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
test("jis.$null([]) returns false", () => {
|
|
13
|
+
expect($null([])).toBe(false);
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
test("jis.$null(null) returns true", () => {
|
|
17
|
+
expect($null(null)).toBe(true);
|
|
18
|
+
})
|
|
19
|
+
})
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
import {describe, test, expect} from "vitest";
|
|
3
|
+
import jis from "jis";
|
|
4
|
+
|
|
5
|
+
const { $number } = jis;
|
|
6
|
+
|
|
7
|
+
describe("$number method", () => {
|
|
8
|
+
test("jis.$number('12') returns false", () => {
|
|
9
|
+
expect($number('12')).toBe(false);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test("jis.$number(12) returns true", () => {
|
|
13
|
+
expect($number(12)).toBe(true);
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {describe, expect, test} from "vitest";
|
|
2
|
+
import jis from "jis";
|
|
3
|
+
|
|
4
|
+
const {$numeric} = jis;
|
|
5
|
+
|
|
6
|
+
describe("$numeric method", () => {
|
|
7
|
+
test("jis.$numeric(12) returns true", () => {
|
|
8
|
+
expect($numeric(12)).toBe(true);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test("jis.$numeric('12') returns true", () => {
|
|
12
|
+
expect($numeric('12')).toBe(true);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test("jis.$numeric('-12') returns true", () => {
|
|
16
|
+
expect($numeric('-12')).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("jis.$numeric('+12') returns true", () => {
|
|
20
|
+
expect($numeric('+12')).toBe(true);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test("jis.$numeric('12.') returns true", () => {
|
|
24
|
+
expect($numeric('12.')).toBe(true);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("jis.$numeric('12.e5') returns true", () => {
|
|
28
|
+
expect($numeric('12.e5')).toBe(true);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test("jis.$numeric('12.E5') returns true", () => {
|
|
32
|
+
expect($numeric('12.E5')).toBe(true);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test("jis.$numeric('12.E-5') returns true", () => {
|
|
36
|
+
expect($numeric('12.E-5')).toBe(true);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test("jis.$numeric('-12.E-5') returns true", () => {
|
|
40
|
+
expect($numeric('-12.E-5')).toBe(true);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test("jis.$numeric('+12.E-5') returns true", () => {
|
|
44
|
+
expect($numeric('+12.E-5')).toBe(true);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
test("jis.$numeric('12.E-') returns false", () => {
|
|
49
|
+
expect($numeric('12.E-')).toBe(false);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test("jis.$numeric('A3B') returns false", () => {
|
|
53
|
+
expect($numeric('A3B')).toBe(false);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test("jis.$numeric(undefined) returns false", () => {
|
|
57
|
+
expect($numeric(undefined)).toBe(false);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test("jis.$numeric(null) returns false", () => {
|
|
61
|
+
expect($numeric(null)).toBe(false);
|
|
62
|
+
});
|
|
63
|
+
})
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
import {describe, test, expect} from "vitest";
|
|
3
|
+
import jis from "jis";
|
|
4
|
+
|
|
5
|
+
const { $object } = jis;
|
|
6
|
+
|
|
7
|
+
describe("$object method", () => {
|
|
8
|
+
test("jis.$object(undefined) returns false", () => {
|
|
9
|
+
expect($object(undefined)).toBe(false);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test("jis.$object({}) returns true", () => {
|
|
13
|
+
expect($object({})).toBe(true);
|
|
14
|
+
});
|
|
15
|
+
})
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { describe, test, expect } from "vitest";
|
|
2
|
+
import jis from "jis";
|
|
3
|
+
|
|
4
|
+
const { $primitive } = jis;
|
|
5
|
+
|
|
6
|
+
describe("$primitive method", () => {
|
|
7
|
+
test("jis.$primitive(undefined) returns true", () => {
|
|
8
|
+
expect($primitive(undefined)).toBe(true);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test("jis.$primitive(null) returns true", () => {
|
|
12
|
+
expect($primitive(null)).toBe(true);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test("jis.$primitive('something') returns true", () => {
|
|
16
|
+
expect($primitive('something')).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("jis.$primitive(true) returns true", () => {
|
|
20
|
+
expect($primitive(true)).toBe(true);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test("jis.$primitive(false) returns true", () => {
|
|
24
|
+
expect($primitive(false)).toBe(true);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("jis.$primitive(12) returns true", () => {
|
|
28
|
+
expect($primitive(12)).toBe(true);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test("jis.$primitive(Symbol()) returns true", () => {
|
|
32
|
+
expect($primitive(Symbol())).toBe(true);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
test("jis.$primitive({}) returns false", () => {
|
|
37
|
+
expect($primitive({})).toBe(false);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("jis.$primitive([]) returns false", () => {
|
|
41
|
+
expect($primitive([])).toBe(false);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test("jis.$primitive(new Date()) returns false", () => {
|
|
45
|
+
expect($primitive(new Date())).toBe(false);
|
|
46
|
+
});
|
|
47
|
+
})
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { describe, test, expect } from "vitest";
|
|
2
|
+
import jis from "jis";
|
|
3
|
+
|
|
4
|
+
const { $string } = jis;
|
|
5
|
+
|
|
6
|
+
describe("$string method", () => {
|
|
7
|
+
test("jis.$string(12) returns false", () => {
|
|
8
|
+
expect($string(12)).toBe(false);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test("jis.$string([]) returns false", () => {
|
|
12
|
+
expect($string([])).toBe(false);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test("jis.$string('') returns true", () => {
|
|
16
|
+
expect($string('')).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
})
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { describe, test, expect } from "vitest";
|
|
2
|
+
import jis from "jis";
|
|
3
|
+
|
|
4
|
+
const { $undefined } = jis;
|
|
5
|
+
|
|
6
|
+
describe("$undefined method", () => {
|
|
7
|
+
test("jis.$undefined({}) returns false", () => {
|
|
8
|
+
expect($undefined({})).toBe(false);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test("jis.$undefined(undefined) returns true", () => {
|
|
12
|
+
expect($undefined(undefined)).toBe(true);
|
|
13
|
+
});
|
|
14
|
+
})
|
package/tsconfig.json
CHANGED
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"lib": [ "
|
|
7
|
-
"
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"useDefineForClassFields": true,
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
7
|
+
"types": ["vite/client"],
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
|
|
10
|
+
/* Bundler mode */
|
|
11
|
+
"moduleResolution": "bundler",
|
|
12
|
+
"allowImportingTsExtensions": true,
|
|
13
|
+
"verbatimModuleSyntax": true,
|
|
14
|
+
"moduleDetection": "force",
|
|
15
|
+
"noEmit": true,
|
|
16
|
+
|
|
17
|
+
/* Linting */
|
|
18
|
+
"strict": true,
|
|
19
|
+
"noUnusedLocals": true,
|
|
20
|
+
"noUnusedParameters": true,
|
|
21
|
+
"erasableSyntaxOnly": true,
|
|
22
|
+
"noFallthroughCasesInSwitch": true,
|
|
23
|
+
"noUncheckedSideEffectImports": true
|
|
8
24
|
},
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
],
|
|
12
|
-
"include": [
|
|
13
|
-
"src/*.ts"
|
|
14
|
-
]
|
|
15
|
-
}
|
|
25
|
+
"include": ["src"]
|
|
26
|
+
}
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { resolve } from 'path';
|
|
2
|
+
import { defineConfig } from 'vitest/config';
|
|
3
|
+
import dts from 'vite-plugin-dts';
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
build: {
|
|
7
|
+
lib: {
|
|
8
|
+
// Entry point for your library
|
|
9
|
+
entry: resolve(import.meta.dirname, 'src/main.ts'),
|
|
10
|
+
name: 'jis',
|
|
11
|
+
// Format to output (es, umd, etc.)
|
|
12
|
+
fileName: 'jis',
|
|
13
|
+
},
|
|
14
|
+
rollupOptions: {
|
|
15
|
+
// Externalize dependencies you don't want bundled
|
|
16
|
+
external: [],
|
|
17
|
+
output: {
|
|
18
|
+
globals: {},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
plugins: [dts()],
|
|
23
|
+
test: {
|
|
24
|
+
environment: 'node',
|
|
25
|
+
globals: true,
|
|
26
|
+
reporters: ['verbose']
|
|
27
|
+
}
|
|
28
|
+
});
|
package/dist/jis.js
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
(function webpackUniversalModuleDefinition(root, factory) {
|
|
2
|
-
if(typeof exports === 'object' && typeof module === 'object')
|
|
3
|
-
module.exports = factory();
|
|
4
|
-
else if(typeof define === 'function' && define.amd)
|
|
5
|
-
define("jis", [], factory);
|
|
6
|
-
else if(typeof exports === 'object')
|
|
7
|
-
exports["jis"] = factory();
|
|
8
|
-
else
|
|
9
|
-
root["jis"] = factory();
|
|
10
|
-
})(this, function() {
|
|
11
|
-
return /******/ (() => { // webpackBootstrap
|
|
12
|
-
/******/ "use strict";
|
|
13
|
-
/******/ var __webpack_modules__ = ({
|
|
14
|
-
|
|
15
|
-
/***/ 138:
|
|
16
|
-
/***/ ((__unused_webpack_module, exports) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
20
|
-
var Is = /** @class */ (function () {
|
|
21
|
-
function Is() {
|
|
22
|
-
}
|
|
23
|
-
Is.callToString = function (arg) {
|
|
24
|
-
return Object.prototype.toString.call(arg);
|
|
25
|
-
};
|
|
26
|
-
Is.$string = function (arg) {
|
|
27
|
-
return Is.callToString(arg) === '[object String]';
|
|
28
|
-
};
|
|
29
|
-
Is.is = function (arg, type) {
|
|
30
|
-
if (Is.$function(type)) {
|
|
31
|
-
return arg instanceof type;
|
|
32
|
-
}
|
|
33
|
-
if (Is.$string(type)) {
|
|
34
|
-
return Is.callToString(arg) === "[object " + type + "]";
|
|
35
|
-
}
|
|
36
|
-
return arg === type;
|
|
37
|
-
};
|
|
38
|
-
Is.$array = function (arg) {
|
|
39
|
-
return Is.is(arg, 'Array');
|
|
40
|
-
};
|
|
41
|
-
Is.$null = function (arg) {
|
|
42
|
-
return Is.is(arg, 'Null');
|
|
43
|
-
};
|
|
44
|
-
Is.$number = function (arg) {
|
|
45
|
-
return Is.is(arg, 'Number');
|
|
46
|
-
};
|
|
47
|
-
Is.$object = function (arg) {
|
|
48
|
-
return Is.is(arg, 'Object');
|
|
49
|
-
};
|
|
50
|
-
Is.$undefined = function (arg) {
|
|
51
|
-
return Is.is(arg, 'Undefined');
|
|
52
|
-
};
|
|
53
|
-
Is.$boolean = function (arg) {
|
|
54
|
-
return Is.is(arg, 'Boolean');
|
|
55
|
-
};
|
|
56
|
-
Is.$function = function (arg) {
|
|
57
|
-
return Is.callToString(arg) === '[object Function]';
|
|
58
|
-
};
|
|
59
|
-
Is.objectIsValid = function (data, rules) {
|
|
60
|
-
if (!Is.$object(data))
|
|
61
|
-
throw new Error('The data parameter must be an Object');
|
|
62
|
-
if (!Is.$object(rules))
|
|
63
|
-
throw new Error('The rules parameter must be an Object');
|
|
64
|
-
var $response = true;
|
|
65
|
-
var $keys = Object.getOwnPropertyNames(rules);
|
|
66
|
-
$keys.forEach(function (key) {
|
|
67
|
-
var rule = rules[key];
|
|
68
|
-
if (Is.$array(rule)) {
|
|
69
|
-
if (rule.length < 1)
|
|
70
|
-
return;
|
|
71
|
-
var parcial_1 = false;
|
|
72
|
-
rule.forEach(function (_rule) {
|
|
73
|
-
parcial_1 = parcial_1 || Is.is(data[key], _rule);
|
|
74
|
-
});
|
|
75
|
-
return $response = $response && parcial_1;
|
|
76
|
-
}
|
|
77
|
-
$response = $response && Is.is(data[key], rule);
|
|
78
|
-
});
|
|
79
|
-
return $response;
|
|
80
|
-
};
|
|
81
|
-
Is.$numeric = function (arg) {
|
|
82
|
-
if (Is.$number(arg)) {
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
var $arg = String(arg || '');
|
|
86
|
-
var regex = /^[-+]?(([0-9]+)|([0-9]*(\.[0-9]+))|([0-9]+\.))([Ee]([-+]?[0-9]+))?$/g;
|
|
87
|
-
return regex.test($arg);
|
|
88
|
-
};
|
|
89
|
-
Is.$primitive = function (arg) {
|
|
90
|
-
var validations = [
|
|
91
|
-
Is.$undefined,
|
|
92
|
-
Is.$null,
|
|
93
|
-
Is.$boolean,
|
|
94
|
-
Is.$number,
|
|
95
|
-
Is.$string,
|
|
96
|
-
function (arg) { return Is.is(arg, 'Symbol'); }
|
|
97
|
-
];
|
|
98
|
-
return validations.some(function (item) { return item(arg); });
|
|
99
|
-
};
|
|
100
|
-
Is.$empty = function (arg) {
|
|
101
|
-
var validations = [
|
|
102
|
-
Is.$undefined,
|
|
103
|
-
Is.$null,
|
|
104
|
-
function (arg) { return Is.$boolean(arg) && !arg; },
|
|
105
|
-
function (arg) { return Is.$number(arg) && arg === 0; },
|
|
106
|
-
function (arg) { return (Is.$array(arg) || Is.$string(arg)) && (arg === "0" || arg.length === 0); }
|
|
107
|
-
];
|
|
108
|
-
return validations.some(function (item) { return item(arg); });
|
|
109
|
-
};
|
|
110
|
-
return Is;
|
|
111
|
-
}());
|
|
112
|
-
exports["default"] = Is;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
/***/ })
|
|
116
|
-
|
|
117
|
-
/******/ });
|
|
118
|
-
/************************************************************************/
|
|
119
|
-
/******/ // The module cache
|
|
120
|
-
/******/ var __webpack_module_cache__ = {};
|
|
121
|
-
/******/
|
|
122
|
-
/******/ // The require function
|
|
123
|
-
/******/ function __webpack_require__(moduleId) {
|
|
124
|
-
/******/ // Check if module is in cache
|
|
125
|
-
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
126
|
-
/******/ if (cachedModule !== undefined) {
|
|
127
|
-
/******/ return cachedModule.exports;
|
|
128
|
-
/******/ }
|
|
129
|
-
/******/ // Create a new module (and put it into the cache)
|
|
130
|
-
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
131
|
-
/******/ // no module.id needed
|
|
132
|
-
/******/ // no module.loaded needed
|
|
133
|
-
/******/ exports: {}
|
|
134
|
-
/******/ };
|
|
135
|
-
/******/
|
|
136
|
-
/******/ // Execute the module function
|
|
137
|
-
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
138
|
-
/******/
|
|
139
|
-
/******/ // Return the exports of the module
|
|
140
|
-
/******/ return module.exports;
|
|
141
|
-
/******/ }
|
|
142
|
-
/******/
|
|
143
|
-
/************************************************************************/
|
|
144
|
-
var __webpack_exports__ = {};
|
|
145
|
-
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
|
146
|
-
(() => {
|
|
147
|
-
var exports = __webpack_exports__;
|
|
148
|
-
var __webpack_unused_export__;
|
|
149
|
-
|
|
150
|
-
__webpack_unused_export__ = ({ value: true });
|
|
151
|
-
var Is_1 = __webpack_require__(138);
|
|
152
|
-
exports["default"] = Is_1.default;
|
|
153
|
-
|
|
154
|
-
})();
|
|
155
|
-
|
|
156
|
-
__webpack_exports__ = __webpack_exports__["default"];
|
|
157
|
-
/******/ return __webpack_exports__;
|
|
158
|
-
/******/ })()
|
|
159
|
-
;
|
|
160
|
-
});
|
package/dist/jis.min.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
!function(n,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("jis",[],t):"object"==typeof exports?exports.jis=t():n.jis=t()}(this,(function(){return(()=>{"use strict";var n={138:(n,t)=>{Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function n(){}return n.callToString=function(n){return Object.prototype.toString.call(n)},n.$string=function(t){return"[object String]"===n.callToString(t)},n.is=function(t,r){return n.$function(r)?t instanceof r:n.$string(r)?n.callToString(t)==="[object "+r+"]":t===r},n.$array=function(t){return n.is(t,"Array")},n.$null=function(t){return n.is(t,"Null")},n.$number=function(t){return n.is(t,"Number")},n.$object=function(t){return n.is(t,"Object")},n.$undefined=function(t){return n.is(t,"Undefined")},n.$boolean=function(t){return n.is(t,"Boolean")},n.$function=function(t){return"[object Function]"===n.callToString(t)},n.objectIsValid=function(t,r){if(!n.$object(t))throw new Error("The data parameter must be an Object");if(!n.$object(r))throw new Error("The rules parameter must be an Object");var e=!0;return Object.getOwnPropertyNames(r).forEach((function(o){var u=r[o];if(n.$array(u)){if(u.length<1)return;var i=!1;return u.forEach((function(r){i=i||n.is(t[o],r)})),e=e&&i}e=e&&n.is(t[o],u)})),e},n.$numeric=function(t){if(n.$number(t))return!0;var r=String(t||"");return/^[-+]?(([0-9]+)|([0-9]*(\.[0-9]+))|([0-9]+\.))([Ee]([-+]?[0-9]+))?$/g.test(r)},n.$primitive=function(t){var r=[n.$undefined,n.$null,n.$boolean,n.$number,n.$string,function(t){return n.is(t,"Symbol")}];return r.some((function(n){return n(t)}))},n.$empty=function(t){var r=[n.$undefined,n.$null,function(t){return n.$boolean(t)&&!t},function(t){return n.$number(t)&&0===t},function(t){return(n.$array(t)||n.$string(t))&&("0"===t||0===t.length)}];return r.some((function(n){return n(t)}))},n}();t.default=r}},t={};function r(e){var o=t[e];if(void 0!==o)return o.exports;var u=t[e]={exports:{}};return n[e](u,u.exports,r),u.exports}var e={};return(()=>{var n=e;var t=r(138);n.default=t.default})(),e=e.default})()}));
|
package/index.html
DELETED
package/test.js
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
require('mocha');
|
|
2
|
-
let assert = require('chai').assert;
|
|
3
|
-
let jis = require('./')
|
|
4
|
-
|
|
5
|
-
describe('Jis types test', () => {
|
|
6
|
-
|
|
7
|
-
it('$array method', () => {
|
|
8
|
-
|
|
9
|
-
assert.equal( jis.$array(''), false, "$array('') must be false");
|
|
10
|
-
assert.equal( jis.$array(1), false, "$array(1) must be false");
|
|
11
|
-
assert.equal( jis.$array([]), true, "$array([]) must be true");
|
|
12
|
-
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('$boolean method', () => {
|
|
16
|
-
|
|
17
|
-
assert.equal( jis.$boolean(''), false, "$boolean('') must be false" );
|
|
18
|
-
assert.equal( jis.$boolean(true), true, "$boolean('') must be true" );
|
|
19
|
-
assert.equal( jis.$boolean(false), true, "$boolean('') must be true" );
|
|
20
|
-
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
it('$function method', () => {
|
|
24
|
-
|
|
25
|
-
assert.equal( jis.$function(''), false, "$function('') must be false" )
|
|
26
|
-
assert.equal( jis.$function(() => {}), true, "$function(function(){}) must be true" )
|
|
27
|
-
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('$null method', () => {
|
|
31
|
-
|
|
32
|
-
assert.equal(jis.$null(true), false, '$null(true) must be false');
|
|
33
|
-
assert.equal(jis.$null([]), false, '$null([]) must be false');
|
|
34
|
-
assert.equal(jis.$null(null), true, '$null(null) must be true');
|
|
35
|
-
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
it('$number method', function () {
|
|
39
|
-
|
|
40
|
-
assert.equal( jis.$number('12'), false, "$number('12') must be false" )
|
|
41
|
-
assert.equal( jis.$number(12), true, "$number('12') must be true" )
|
|
42
|
-
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('$object method', () => {
|
|
46
|
-
|
|
47
|
-
assert.equal( jis.$object(undefined), false, '$object(undefined) must be false' )
|
|
48
|
-
assert.equal( jis.$object({}), true, '$object({}) must be true' )
|
|
49
|
-
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('$string method', () => {
|
|
53
|
-
|
|
54
|
-
assert.equal( jis.$string(12), false, '$string(12) must be false' )
|
|
55
|
-
assert.equal( jis.$string([]), false, '$string([]) must be false' )
|
|
56
|
-
assert.equal( jis.$string(""), true, '$string("") must be true' )
|
|
57
|
-
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('$undefined method', function () {
|
|
61
|
-
|
|
62
|
-
assert.equal( jis.$undefined({}), false, '$undefined({}) must be false')
|
|
63
|
-
assert.equal( jis.$undefined(undefined), true, '$undefined({}) must be true')
|
|
64
|
-
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('$numeric method', function () {
|
|
68
|
-
|
|
69
|
-
assert.equal( jis.$numeric(12), true, '$numeric(12) must be true' );
|
|
70
|
-
assert.equal( jis.$numeric('12'), true, "$numeric('12') must be true" );
|
|
71
|
-
assert.equal( jis.$numeric('-12'), true, "$numeric('-12') must be true" );
|
|
72
|
-
assert.equal( jis.$numeric('+12'), true, "$numeric('+12') must be true" );
|
|
73
|
-
assert.equal( jis.$numeric('12.'), true, "$numeric('12.') must be true" );
|
|
74
|
-
assert.equal( jis.$numeric('12.e5'), true, "$numeric('12.e5') must be true" );
|
|
75
|
-
assert.equal( jis.$numeric('12.E5'), true, "$numeric('12.E5') must be true" );
|
|
76
|
-
assert.equal( jis.$numeric('12.E-5'), true, "$numeric('12.E-5') must be true" );
|
|
77
|
-
assert.equal( jis.$numeric('-12.E-5'), true, "$numeric('-12.E-5') must be true" );
|
|
78
|
-
assert.equal( jis.$numeric('+12.E-5'), true, "$numeric('+12.E-5') must be true" );
|
|
79
|
-
|
|
80
|
-
assert.equal( jis.$numeric('12.E-'), false, "$numeric('12.E-') must be false" );
|
|
81
|
-
assert.equal( jis.$numeric('A3B'), false, "$numeric('A3B') must be false" );
|
|
82
|
-
assert.equal( jis.$numeric(undefined), false, "$numeric(undefined) must be false" );
|
|
83
|
-
assert.equal( jis.$numeric(null), false, "$numeric(null) must be false" );
|
|
84
|
-
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('$primitive method', function () {
|
|
88
|
-
|
|
89
|
-
assert.equal(jis.$primitive(undefined), true, '$primitive(undefined) must be true')
|
|
90
|
-
assert.equal(jis.$primitive(null), true, '$primitive(null) must be true')
|
|
91
|
-
assert.equal(jis.$primitive("something"), true, '$primitive("something") must be true')
|
|
92
|
-
assert.equal(jis.$primitive(true), true, '$primitive(true) must be true')
|
|
93
|
-
assert.equal(jis.$primitive(false), true, '$primitive(false) must be true')
|
|
94
|
-
assert.equal(jis.$primitive(12), true, '$primitive(12) must be true')
|
|
95
|
-
assert.equal(jis.$primitive(Symbol()), true, '$primitive(Symbol()) must be true')
|
|
96
|
-
|
|
97
|
-
assert.equal(jis.$primitive({}), false, '$primitive({}) must be true')
|
|
98
|
-
assert.equal(jis.$primitive([]), false, '$primitive([]) must be true')
|
|
99
|
-
assert.equal(jis.$primitive(new Date()), false, '$primitive(new Date()) must be true')
|
|
100
|
-
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it('$empty method', function () {
|
|
104
|
-
|
|
105
|
-
assert.equal(jis.$empty(null), true, '$empty(null) must be true')
|
|
106
|
-
assert.equal(jis.$empty(undefined), true, '$empty(undefined) must be true')
|
|
107
|
-
assert.equal(jis.$empty(false), true, '$empty(false) must be true')
|
|
108
|
-
assert.equal(jis.$empty(0), true, '$empty(0) must be true')
|
|
109
|
-
assert.equal(jis.$empty(0.0), true, '$empty(0.0) must be true')
|
|
110
|
-
assert.equal(jis.$empty(""), true, '$empty("") must be true')
|
|
111
|
-
assert.equal(jis.$empty("0"), true, '$empty("0") must be true')
|
|
112
|
-
assert.equal(jis.$empty([]), true, '$empty([]) must be true')
|
|
113
|
-
|
|
114
|
-
assert.equal(jis.$empty(true), false, '$empty(true) must be true')
|
|
115
|
-
assert.equal(jis.$empty(12), false, '$empty(12) must be true')
|
|
116
|
-
assert.equal(jis.$empty(12.0), false, '$empty(12.0) must be true')
|
|
117
|
-
assert.equal(jis.$empty("something"), false, '$empty("something") must be true')
|
|
118
|
-
assert.equal(jis.$empty("012"), false, '$empty("012") must be true')
|
|
119
|
-
assert.equal(jis.$empty([1, 2, 3]), false, '$empty([1, 2, 3]) must be true')
|
|
120
|
-
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it('"is" method', function () {
|
|
124
|
-
assert.equal(jis.is( [], 'Array' ) , true)
|
|
125
|
-
assert.equal(jis.is( false, 'Boolean' ) , true)
|
|
126
|
-
assert.equal(jis.is( true, 'Boolean' ) , true)
|
|
127
|
-
assert.equal(jis.is( function(){}, 'Function' ) , true)
|
|
128
|
-
assert.equal(jis.is( null, 'Null' ) , true)
|
|
129
|
-
assert.equal(jis.is( 12, 'Number' ) , true)
|
|
130
|
-
assert.equal(jis.is( {}, 'Object' ) , true)
|
|
131
|
-
assert.equal(jis.is( 'Text', 'String' ) , true)
|
|
132
|
-
assert.equal(jis.is( undefined, 'Undefined' ) , true)
|
|
133
|
-
|
|
134
|
-
let date = new Date();
|
|
135
|
-
assert.equal(jis.is(date, Date) , true)
|
|
136
|
-
|
|
137
|
-
assert.equal(jis.is(/^$/g, RegExp) , true)
|
|
138
|
-
assert.equal(jis.is(/^$/g, 'RegExp') , true)
|
|
139
|
-
|
|
140
|
-
assert.equal(jis.is(12, 12), true);
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
})
|
package/types/index.d.ts
DELETED
package/webpack.config.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
const path = require('path')
|
|
2
|
-
const TerserPlugin = require("terser-webpack-plugin");
|
|
3
|
-
|
|
4
|
-
module.exports = {
|
|
5
|
-
mode: 'production',
|
|
6
|
-
entry: {
|
|
7
|
-
'jis': './src/main.ts',
|
|
8
|
-
'jis.min': './src/main.ts'
|
|
9
|
-
},
|
|
10
|
-
output: {
|
|
11
|
-
path: path.resolve(__dirname, 'dist'),
|
|
12
|
-
filename: '[name].js',
|
|
13
|
-
libraryTarget: 'umd',
|
|
14
|
-
library: {
|
|
15
|
-
name: 'jis',
|
|
16
|
-
type: 'global'
|
|
17
|
-
},
|
|
18
|
-
umdNamedDefine: true,
|
|
19
|
-
globalObject: "this",
|
|
20
|
-
libraryExport: "default"
|
|
21
|
-
},
|
|
22
|
-
resolve: {
|
|
23
|
-
extensions: ['.ts', '.tsx', '.js']
|
|
24
|
-
},
|
|
25
|
-
// devtool: 'source-map',
|
|
26
|
-
module: {
|
|
27
|
-
rules: [{
|
|
28
|
-
test: /\.tsx?$/,
|
|
29
|
-
loader: 'ts-loader',
|
|
30
|
-
exclude: /node_modules/
|
|
31
|
-
}]
|
|
32
|
-
},
|
|
33
|
-
optimization: {
|
|
34
|
-
minimizer: [
|
|
35
|
-
new TerserPlugin({
|
|
36
|
-
include: /\.min\.js$/,
|
|
37
|
-
extractComments: false,
|
|
38
|
-
})
|
|
39
|
-
]
|
|
40
|
-
}
|
|
41
|
-
}
|