jis 1.0.36 → 2.0.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/dist/Is.d.ts +17 -0
- package/dist/interfaces/main.d.ts +3 -0
- package/dist/jis.js +76 -160
- package/dist/jis.umd.cjs +1 -0
- package/dist/main.d.ts +2 -0
- package/package.json +26 -16
- package/dist/jis.min.js +0 -1
- package/index.html +0 -10
- package/src/Is.ts +0 -114
- package/src/main.ts +0 -3
- package/test.js +0 -143
- package/tsconfig.json +0 -15
- package/types/index.d.ts +0 -3
- package/webpack.config.js +0 -41
package/dist/Is.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Gen } from './interfaces/main.ts';
|
|
2
|
+
export default class Is {
|
|
3
|
+
private static callToString;
|
|
4
|
+
static $string(arg: any): boolean;
|
|
5
|
+
static is(arg: any, type: any): boolean;
|
|
6
|
+
static $array(arg: any): boolean;
|
|
7
|
+
static $null(arg: any): boolean;
|
|
8
|
+
static $number(arg: any): boolean;
|
|
9
|
+
static $object(arg: any): boolean;
|
|
10
|
+
static $undefined(arg: any): boolean;
|
|
11
|
+
static $boolean(arg: any): boolean;
|
|
12
|
+
static $function(arg: any): boolean;
|
|
13
|
+
static objectIsValid(data: Gen, rules: Gen): boolean;
|
|
14
|
+
static $numeric(arg: any): boolean;
|
|
15
|
+
static $primitive(arg: any): boolean;
|
|
16
|
+
static $empty(arg: any): boolean;
|
|
17
|
+
}
|
package/dist/jis.js
CHANGED
|
@@ -1,160 +1,76 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
});
|
|
1
|
+
class e {
|
|
2
|
+
static callToString(t) {
|
|
3
|
+
return Object.prototype.toString.call(t);
|
|
4
|
+
}
|
|
5
|
+
static $string(t) {
|
|
6
|
+
return e.callToString(t) === "[object String]";
|
|
7
|
+
}
|
|
8
|
+
static is(t, n) {
|
|
9
|
+
return e.$function(n) ? t instanceof n : e.$string(n) ? e.callToString(t) === `[object ${n}]` : t === n;
|
|
10
|
+
}
|
|
11
|
+
static $array(t) {
|
|
12
|
+
return e.is(t, "Array");
|
|
13
|
+
}
|
|
14
|
+
static $null(t) {
|
|
15
|
+
return e.is(t, "Null");
|
|
16
|
+
}
|
|
17
|
+
static $number(t) {
|
|
18
|
+
return e.is(t, "Number");
|
|
19
|
+
}
|
|
20
|
+
static $object(t) {
|
|
21
|
+
return e.is(t, "Object");
|
|
22
|
+
}
|
|
23
|
+
static $undefined(t) {
|
|
24
|
+
return e.is(t, "Undefined");
|
|
25
|
+
}
|
|
26
|
+
static $boolean(t) {
|
|
27
|
+
return e.is(t, "Boolean");
|
|
28
|
+
}
|
|
29
|
+
static $function(t) {
|
|
30
|
+
return e.callToString(t) === "[object Function]";
|
|
31
|
+
}
|
|
32
|
+
static objectIsValid(t, n) {
|
|
33
|
+
if (!e.$object(t)) throw new Error("The data parameter must be an Object");
|
|
34
|
+
if (!e.$object(n)) throw new Error("The rules parameter must be an Object");
|
|
35
|
+
let r = !0;
|
|
36
|
+
return Object.getOwnPropertyNames(n).forEach((a) => {
|
|
37
|
+
let i = n[a];
|
|
38
|
+
if (e.$array(i)) {
|
|
39
|
+
if (i.length < 1) return;
|
|
40
|
+
let l = !1;
|
|
41
|
+
return i.forEach((o) => {
|
|
42
|
+
l = l || e.is(t[a], o);
|
|
43
|
+
}), r = r && l;
|
|
44
|
+
}
|
|
45
|
+
r = r && e.is(t[a], i);
|
|
46
|
+
}), r;
|
|
47
|
+
}
|
|
48
|
+
static $numeric(t) {
|
|
49
|
+
if (e.$number(t))
|
|
50
|
+
return !0;
|
|
51
|
+
let n = String(t || "");
|
|
52
|
+
return /^[-+]?(([0-9]+)|([0-9]*(\.[0-9]+))|([0-9]+\.))([Ee]([-+]?[0-9]+))?$/g.test(n);
|
|
53
|
+
}
|
|
54
|
+
static $primitive(t) {
|
|
55
|
+
return [
|
|
56
|
+
e.$undefined,
|
|
57
|
+
e.$null,
|
|
58
|
+
e.$boolean,
|
|
59
|
+
e.$number,
|
|
60
|
+
e.$string,
|
|
61
|
+
(r) => e.is(r, "Symbol")
|
|
62
|
+
].some((r) => r(t));
|
|
63
|
+
}
|
|
64
|
+
static $empty(t) {
|
|
65
|
+
return [
|
|
66
|
+
e.$undefined,
|
|
67
|
+
e.$null,
|
|
68
|
+
(r) => e.$boolean(r) && !r,
|
|
69
|
+
(r) => e.$number(r) && r === 0,
|
|
70
|
+
(r) => (e.$array(r) || e.$string(r)) && (r === "0" || r.length === 0)
|
|
71
|
+
].some((r) => r(t));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export {
|
|
75
|
+
e as default
|
|
76
|
+
};
|
package/dist/jis.umd.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(t,o){typeof exports=="object"&&typeof module<"u"?module.exports=o():typeof define=="function"&&define.amd?define(o):(t=typeof globalThis<"u"?globalThis:t||self,t.jis=o())})(this,(function(){"use strict";class t{static callToString(e){return Object.prototype.toString.call(e)}static $string(e){return t.callToString(e)==="[object String]"}static is(e,r){return t.$function(r)?e instanceof r:t.$string(r)?t.callToString(e)===`[object ${r}]`:e===r}static $array(e){return t.is(e,"Array")}static $null(e){return t.is(e,"Null")}static $number(e){return t.is(e,"Number")}static $object(e){return t.is(e,"Object")}static $undefined(e){return t.is(e,"Undefined")}static $boolean(e){return t.is(e,"Boolean")}static $function(e){return t.callToString(e)==="[object Function]"}static objectIsValid(e,r){if(!t.$object(e))throw new Error("The data parameter must be an Object");if(!t.$object(r))throw new Error("The rules parameter must be an Object");let n=!0;return Object.getOwnPropertyNames(r).forEach(u=>{let i=r[u];if(t.$array(i)){if(i.length<1)return;let l=!1;return i.forEach(a=>{l=l||t.is(e[u],a)}),n=n&&l}n=n&&t.is(e[u],i)}),n}static $numeric(e){if(t.$number(e))return!0;let r=String(e||"");return/^[-+]?(([0-9]+)|([0-9]*(\.[0-9]+))|([0-9]+\.))([Ee]([-+]?[0-9]+))?$/g.test(r)}static $primitive(e){return[t.$undefined,t.$null,t.$boolean,t.$number,t.$string,n=>t.is(n,"Symbol")].some(n=>n(e))}static $empty(e){return[t.$undefined,t.$null,n=>t.$boolean(n)&&!n,n=>t.$number(n)&&n===0,n=>(t.$array(n)||t.$string(n))&&(n==="0"||n.length===0)].some(n=>n(e))}}return t}));
|
package/dist/main.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jis",
|
|
3
|
-
"
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "2.0.2",
|
|
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
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/main.d.ts",
|
|
16
|
+
"import": "./dist/jis.js",
|
|
17
|
+
"require": "./dist/jis.umd.cjs"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
7
20
|
"scripts": {
|
|
8
|
-
"
|
|
9
|
-
"build": "
|
|
21
|
+
"dev": "vite",
|
|
22
|
+
"build": "tsc && vite build",
|
|
23
|
+
"preview": "vite preview",
|
|
24
|
+
"test": "vitest run"
|
|
10
25
|
},
|
|
11
26
|
"keywords": [
|
|
12
27
|
"Is",
|
|
@@ -20,20 +35,15 @@
|
|
|
20
35
|
],
|
|
21
36
|
"repository": {
|
|
22
37
|
"type": "git",
|
|
23
|
-
"url": "https://gitlab.com/
|
|
38
|
+
"url": "git+https://gitlab.com/josebasmtzdev/jis.git"
|
|
24
39
|
},
|
|
25
40
|
"author": "Jose Can <joseluisgpecanmtz@gmail.com>",
|
|
26
41
|
"license": "ISC",
|
|
27
42
|
"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"
|
|
43
|
+
"@types/node": "^25.0.3",
|
|
44
|
+
"typescript": "~5.9.3",
|
|
45
|
+
"vite": "^7.2.4",
|
|
46
|
+
"vite-plugin-dts": "^4.5.4",
|
|
47
|
+
"vitest": "^4.0.16"
|
|
38
48
|
}
|
|
39
49
|
}
|
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/src/Is.ts
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
export default class Is{
|
|
2
|
-
private static callToString(arg:any) {
|
|
3
|
-
return Object.prototype.toString.call(arg)
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
static $string(arg:any) {
|
|
7
|
-
return Is.callToString(arg) === '[object String]';
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
static is(arg:any, type){
|
|
11
|
-
if(Is.$function(type))
|
|
12
|
-
{
|
|
13
|
-
return arg instanceof type;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (Is.$string(type))
|
|
17
|
-
{
|
|
18
|
-
return Is.callToString(arg) === `[object ${type}]`;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return arg === type;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
static $array(arg:any){
|
|
25
|
-
return Is.is(arg, 'Array');
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
static $null(arg:any){
|
|
29
|
-
return Is.is(arg, 'Null');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
static $number(arg:any){
|
|
33
|
-
return Is.is(arg, 'Number');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
static $object(arg:any){
|
|
37
|
-
return Is.is(arg, 'Object');
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
static $undefined(arg:any){
|
|
41
|
-
return Is.is(arg, 'Undefined');
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
static $boolean(arg:any){
|
|
45
|
-
return Is.is(arg, 'Boolean');
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
static $function(arg:any){
|
|
49
|
-
return Is.callToString(arg) === '[object Function]';
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
static objectIsValid(data:object, rules:object) {
|
|
53
|
-
if (!Is.$object(data)) throw new Error('The data parameter must be an Object');
|
|
54
|
-
if (!Is.$object(rules)) throw new Error('The rules parameter must be an Object');
|
|
55
|
-
|
|
56
|
-
let $response = true;
|
|
57
|
-
let $keys = Object.getOwnPropertyNames(rules);
|
|
58
|
-
|
|
59
|
-
$keys.forEach((key) => {
|
|
60
|
-
let rule = rules[key];
|
|
61
|
-
if (Is.$array(rule)) {
|
|
62
|
-
if (rule.length < 1) return;
|
|
63
|
-
let parcial = false;
|
|
64
|
-
rule.forEach((_rule) => {
|
|
65
|
-
parcial = parcial || Is.is(data[key], _rule);
|
|
66
|
-
});
|
|
67
|
-
return $response = $response && parcial;
|
|
68
|
-
}
|
|
69
|
-
$response = $response && Is.is(data[key], rule);
|
|
70
|
-
});
|
|
71
|
-
return $response;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
static $numeric(arg: any)
|
|
75
|
-
{
|
|
76
|
-
if (Is.$number(arg))
|
|
77
|
-
{
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
let $arg = String(arg || '');
|
|
82
|
-
let regex = /^[-+]?(([0-9]+)|([0-9]*(\.[0-9]+))|([0-9]+\.))([Ee]([-+]?[0-9]+))?$/g;
|
|
83
|
-
|
|
84
|
-
return regex.test( $arg );
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
static $primitive(arg: any)
|
|
88
|
-
{
|
|
89
|
-
let validations = [
|
|
90
|
-
Is.$undefined,
|
|
91
|
-
Is.$null,
|
|
92
|
-
Is.$boolean,
|
|
93
|
-
Is.$number,
|
|
94
|
-
Is.$string,
|
|
95
|
-
(arg) => Is.is(arg, 'Symbol')
|
|
96
|
-
]
|
|
97
|
-
|
|
98
|
-
return validations.some(item => item(arg))
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
static $empty(arg: any)
|
|
102
|
-
{
|
|
103
|
-
let validations = [
|
|
104
|
-
Is.$undefined,
|
|
105
|
-
Is.$null,
|
|
106
|
-
|
|
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)
|
|
110
|
-
]
|
|
111
|
-
|
|
112
|
-
return validations.some(item => item(arg))
|
|
113
|
-
}
|
|
114
|
-
}
|
package/src/main.ts
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/tsconfig.json
DELETED
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
|
-
}
|