jis 2.0.2 → 2.1.0-preview.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/CHANGELOG.md ADDED
@@ -0,0 +1,25 @@
1
+ # Changelog
2
+
3
+ ## [Unreleased]
4
+
5
+ ### Deprecated
6
+ - Accessing type checks directly via `jis.is` and `jis.$*` is deprecated.
7
+ These APIs will be removed in v3.0.0.
8
+ Use `jis.types.*` and `jis.semantic.*` instead.
9
+
10
+ ### Added
11
+ - Introduced new namespaces: `jis.types` and `jis.semantic`
12
+
13
+ ## [2.0.2]
14
+ ### Fixed
15
+ - Fixed CI configuration to run `build` and `test` jobs only on merge requests to `dev` and `master`
16
+ - Fixed package publishing issue where the `dist/` folder was not included
17
+
18
+ ## [2.0.1]
19
+ ### Changed
20
+ - Migrated build system from webpack to Vite
21
+ - Integrated Vitest
22
+ - Integrated CI/CD (build, test, and deploy)
23
+
24
+ ### Notes
25
+ - Previous versions (< 2.0.1) were early iterations and did not follow a formal changelog.
package/README.md CHANGED
@@ -1,242 +1,297 @@
1
1
  # J`is`
2
2
 
3
- `jis` is a data type verifier for older browsers. Based in `Object.prototype.toString.call`
3
+ `jis` is a lightweight runtime data type verifier designed for browsers and environments where static typing or modern language features may not be reliable or available.
4
4
 
5
- The library has some methods to check the data type.
5
+ Based on `Object.prototype.toString.call`, the library provides a set of methods to perform reliable runtime data type checks.
6
+
7
+ ### Why jis?
8
+
9
+ `jis` comes from `is`, the core of the library, prefixed with `j` (my initial).
10
+ Phonetically, it sounds like “ji-is”, a subtle nod to JS itself.
11
+
12
+ In the browser, everything runs as JavaScript at runtime.
13
+ Static types disappear after transpilation, and runtime type checks are often limited, inconsistent, or dependent on modern language features that are not always available.
14
+
15
+ `jis` focuses on providing simple, reliable runtime `is` checks using the most stable and widely supported mechanisms in JavaScript.
6
16
 
7
17
  ### Installation
8
-
9
- ```shell script
10
- npm install jis
11
- ```
12
18
 
13
- You can install this library with `npm` or `yarn`. And you can add in `devDependecies` with
19
+ You can install this library with npm or yarn.
14
20
 
15
- ```shell script
16
- npm install jis --dev
21
+ ```shell script
22
+ npm install jis
17
23
  ```
18
24
 
19
25
  ### Usage
20
26
 
21
- ##### Import in ES5 or higher
27
+ #### Import in ES5 or higher
22
28
 
23
29
  ```js
24
- let jis = require('jis')
30
+ const jis = require('jis')
25
31
  ```
26
32
 
27
- ##### Import in TS
33
+ #### Import in TS
28
34
 
29
35
  ```ts
30
36
  import jis from 'jis'
31
37
  ```
32
38
 
33
- #### Methods
39
+ ### ⚠️ Backward compatibility
34
40
 
35
- ##### $array
41
+ In `v2.x`, legacy access via `jis.is` and `jis.$*` **still works for compatibility reasons**, but it is **deprecated** and will be removed in `v3.0.0`.
36
42
 
37
- ```js
38
-
39
- jis.$array( [] ) // true
40
-
41
- jis.$array( true ) //false
42
- jis.$array( function() {} ) // false
43
- jis.$array( null ) // false
44
- jis.$array( 12 ) // false
45
- jis.$array( {} ) // false
46
- jis.$array( '' ) // false
47
- jis.$array( undefined ) // false
43
+ If you are starting a new project or updating existing code, **use the new namespaces shown below**.
48
44
 
45
+ ```js
46
+ // Deprecated
47
+ jis.is(arg, type);
48
+ jis.$object(arg);
49
+ jis.$array(arg);
50
+ jis.$number(arg);
51
+ jis.$string(arg);
52
+ jis.$boolean(arg);
53
+ jis.$undefined(arg);
54
+ jis.$function(arg);
55
+ jis.$null(arg);
56
+
57
+ jis.$empty(arg);
58
+ jis.$numeric(arg);
59
+ jis.$primitive(arg);
49
60
  ```
50
61
 
51
- ##### $boolean
62
+ Use the new namespaces instead:
52
63
 
53
64
  ```js
65
+ jis.types.is(arg, type);
66
+ jis.types.$object(arg);
67
+ jis.types.$array(arg);
68
+ jis.types.$number(arg);
69
+ jis.types.$string(arg);
70
+ jis.types.$boolean(arg);
71
+ jis.types.$undefined(arg);
72
+ jis.types.$function(arg);
73
+ jis.types.$null(arg);
74
+
75
+ jis.semantic.$empty(arg);
76
+ jis.semantic.$numeric(arg);
77
+ jis.semantic.$primitive(arg);
78
+ ```
54
79
 
55
- jis.$boolean( true ) // true
56
- jis.$boolean( false ) // true
80
+ ## API
57
81
 
58
- jis.$boolean( [] ) //false
59
- jis.$boolean( function() {} ) // false
82
+ ### Type checks (`jis.types`)
83
+ #### $array
60
84
 
61
- // ...
85
+ ```js
86
+ const { $array } = jis.types // jis.types.$array
87
+
88
+ $array( [] ) // true
62
89
 
90
+ $array( true ) // false
91
+ $array( function() {} ) // false
92
+ $array( null ) // false
93
+ $array( 12 ) // false
94
+ $array( {} ) // false
95
+ $array( '' ) // false
96
+ $array( undefined ) // false
63
97
  ```
64
98
 
65
- ##### $function
99
+ #### $boolean
66
100
 
67
101
  ```js
102
+ const { $boolean } = jis.types
68
103
 
69
- jis.$function( function() {} ) // true
104
+ $boolean( true ) // true
105
+ $boolean( false ) // true
70
106
 
71
- jis.$function( 12 ) // false
72
- jis.$function( {} ) // false
73
- jis.$function( '' ) // false
107
+ $boolean( [] ) // false
108
+ $boolean( function() {} ) // false
74
109
 
75
110
  // ...
76
-
77
111
  ```
78
112
 
79
- ##### $null
113
+ #### $function
80
114
 
81
115
  ```js
116
+ const { $function } = jis.types
82
117
 
83
- jis.$null( null ) // true
118
+ $function( function() {} ) // true
84
119
 
85
- jis.$null( {} ) // false
86
- jis.$null( '' ) // false
87
- jis.$null( undefined ) // false
120
+ $function( 12 ) // false
121
+ $function( {} ) // false
122
+ $function( '' ) // false
88
123
 
89
124
  // ...
90
-
91
125
  ```
92
126
 
93
- ##### $number
127
+ #### $null
94
128
 
95
129
  ```js
130
+ const { $null } = jis.types
96
131
 
97
- jis.$number( 12 ) // true
132
+ $null( null ) // true
98
133
 
99
- jis.$number( function() {} ) // false
100
- jis.$number( null ) // false
101
- jis.$number( undefined ) // false
134
+ $null( {} ) // false
135
+ $null( '' ) // false
136
+ $null( undefined ) // false
102
137
 
103
138
  // ...
104
-
105
139
  ```
106
140
 
107
- ##### $object
141
+ #### $number
108
142
 
109
143
  ```js
144
+ const { $number } = jis.types
110
145
 
111
- jis.$object( {} ) // true
146
+ $number( 12 ) // true
112
147
 
113
- jis.$object( [] ) // false
114
- jis.$object( true ) //false
115
- jis.$object( 12 ) // false
148
+ $number( function() {} ) // false
149
+ $number( null ) // false
150
+ $number( undefined ) // false
116
151
 
117
152
  // ...
118
-
119
153
  ```
120
154
 
121
- ##### $string
155
+ #### $object
122
156
 
123
157
  ```js
158
+ const { $object } = jis.types
124
159
 
125
- jis.$string( 'Some text' ) // true
160
+ $object( {} ) // true
126
161
 
127
- jis.$string( [] ) // false
128
- jis.$string( true ) //false
129
- jis.$string( undefined ) // false
162
+ $object( [] ) // false
163
+ $object( true ) // false
164
+ $object( 12 ) // false
130
165
 
131
166
  // ...
132
-
133
167
  ```
134
168
 
135
- ##### $undefined
169
+ #### $string
136
170
 
137
171
  ```js
172
+ const { $string } = jis.types
138
173
 
139
- jis.$undefined( undefined ) // true
174
+ $string( 'Some text' ) // true
140
175
 
141
- jis.$undefined( [] ) // false
142
- jis.$undefined( {} ) // false
143
- jis.$undefined( '' ) // false
176
+ $string( [] ) // false
177
+ $string( true ) // false
178
+ $string( undefined ) // false
144
179
 
145
180
  // ...
146
-
147
181
  ```
148
182
 
149
- ##### $numeric
150
-
151
- Check if the argument is a number or number string (including exponential)
183
+ #### $undefined
152
184
 
153
185
  ```js
186
+ const { $undefined } = jis.types
154
187
 
155
- jis.$numeric( 12 ) // true
156
- jis.$numeric( '12' ) // true
157
- jis.$numeric( '-12' ) // true
158
- jis.$numeric( '+12' ) // true
159
- jis.$numeric( '12.' ) // true
160
- jis.$numeric( '12.e5' ) // true
161
- jis.$numeric( '12.E5' ) // true
162
- jis.$numeric( '12.E-5' ) // true
163
- jis.$numeric( '-12.E-5' ) // true
164
- jis.$numeric( '+12.E-5' ) // true
188
+ $undefined( undefined ) // true
165
189
 
166
- jis.$numeric( '12.E-' ) // false
167
- jis.$numeric( 'A3B' ) // false
168
- jis.$numeric( undefined ) // false
169
- jis.$numeric( null ) // false
190
+ $undefined( [] ) // false
191
+ $undefined( {} ) // false
192
+ $undefined( '' ) // false
170
193
 
194
+ // ...
171
195
  ```
172
196
 
173
- ##### $primitive
197
+ #### is
174
198
 
175
- Check if the argument is primitive type
199
+ This method is the core of the library and provides more flexible and advanced type checks.
176
200
 
177
201
  ```js
202
+ const { is } = jis.types
203
+
204
+ is( [], 'Array' ) // true
205
+ is( false, 'Boolean' ) // true
206
+ is( true, 'Boolean' ) // true
207
+ is( function(){}, 'Function' ) // true
208
+ is( null, 'Null' ) // true
209
+ is( 12, 'Number' ) // true
210
+ is( {}, 'Object' ) // true
211
+ is( 'Text', 'String' ) // true
212
+ is( undefined, 'Undefined' ) // true
178
213
 
179
- jis.$primitive(undefined) // true
180
- jis.$primitive(null) // true
181
- jis.$primitive("something") // true
182
- jis.$primitive(true) // true
183
- jis.$primitive(false) // true
184
- jis.$primitive(12) // true
185
- jis.$primitive(Symbol()) // true
214
+ let date = new Date();
215
+ is(date, Date) // true
186
216
 
187
- jis.$primitive({}) // false
188
- jis.$primitive([]) // false
189
- jis.$primitive(new Date()) // false
217
+ is(/^$/g, RegExp) // true
218
+ is(/^$/g, 'RegExp') // true
190
219
 
191
- ```
220
+ is(12, 12) // true
221
+ is(12, 13) // false
192
222
 
193
- ##### $empty
194
-
195
- ```js
223
+ // ... experiment with this method :D
224
+ ```
196
225
 
197
- jis.$empty(null) // true
198
- jis.$empty(undefined) // true
199
- jis.$empty(false) // true
200
- jis.$empty(0) // true
201
- jis.$empty(0.0) // true
202
- jis.$empty("") // true
203
- jis.$empty("0") // true
204
- jis.$empty([]) // true
226
+ ### Semantic checks (`jis.semantic`)
227
+ #### $numeric
205
228
 
206
- jis.$empty(true) // false
207
- jis.$empty(12) // false
208
- jis.$empty(12.0) // false
209
- jis.$empty("something") // false
210
- jis.$empty("012") // false
211
- jis.$empty([1, 2, 3]) // false
229
+ Check if the argument is a number or number string (including exponential)
212
230
 
231
+ ```js
232
+ const { $numeric } = jis.semantic // jis.semantic.$numeric
233
+
234
+ $numeric( 12 ) // true
235
+ $numeric( '12' ) // true
236
+ $numeric( '-12' ) // true
237
+ $numeric( '+12' ) // true
238
+ $numeric( '12.' ) // true
239
+ $numeric( '12.e5' ) // true
240
+ $numeric( '12.E5' ) // true
241
+ $numeric( '12.E-5' ) // true
242
+ $numeric( '-12.E-5' ) // true
243
+ $numeric( '+12.E-5' ) // true
244
+
245
+ $numeric( '12.E-' ) // false
246
+ $numeric( 'A3B' ) // false
247
+ $numeric( undefined ) // false
248
+ $numeric( null ) // false
213
249
  ```
214
250
 
215
- ##### is
251
+ #### $primitive
216
252
 
217
- This method is the library core. Have more options.
253
+ Check if the argument is a primitive value
218
254
 
219
255
  ```js
256
+ const { $primitive } = jis.semantic
257
+
258
+ $primitive(undefined) // true
259
+ $primitive(null) // true
260
+ $primitive("something") // true
261
+ $primitive(true) // true
262
+ $primitive(false) // true
263
+ $primitive(12) // true
264
+ $primitive(Symbol()) // true
265
+
266
+ $primitive({}) // false
267
+ $primitive([]) // false
268
+ $primitive(new Date()) // false
269
+ ```
220
270
 
221
- jis.is( [], 'Array' ) // true
222
- jis.is( false, 'Boolean' ) // true
223
- jis.is( true, 'Boolean' ) // true
224
- jis.is( function(){}, 'Function' ) // true
225
- jis.is( null, 'Null' ) // true
226
- jis.is( 12, 'Number' ) // true
227
- jis.is( {}, 'Object' ) // true
228
- jis.is( 'Text', 'String' ) // true
229
- jis.is( undefined, 'Undefined' ) // true
230
-
231
- let date = new Date();
232
- jis.is(date, Date) // true
271
+ #### $empty
233
272
 
234
- jis.is(/^$/g, RegExp) // true
235
- jis.is(/^$/g, 'RegExp') // true
273
+ $empty follows a semantic definition of emptiness, where certain falsy or zero-like values are intentionally considered empty.
236
274
 
237
- jis.is(12, 12) // true
238
- jis.is(12, 13) // false
275
+ ```js
276
+ const { $empty } = jis.semantic
277
+
278
+ $empty(null) // true
279
+ $empty(undefined) // true
280
+ $empty(false) // true
281
+ $empty(0) // true
282
+ $empty(0.0) // true
283
+ $empty("") // true
284
+ $empty("0") // true
285
+ $empty([]) // true
286
+
287
+ $empty(true) // false
288
+ $empty(12) // false
289
+ $empty(12.0) // false
290
+ $empty("something") // false
291
+ $empty("012") // false
292
+ $empty([1, 2, 3]) // false
293
+ ```
239
294
 
240
- // ... experiment with this method :D
295
+ ## Changelog
241
296
 
242
- ```
297
+ See [CHANGELOG.md](./CHANGELOG.md) for version history and breaking changes.
package/dist/Is.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Gen } from './interfaces/main.ts';
1
+ import { IGen } from './interfaces/main.ts';
2
2
  export default class Is {
3
3
  private static callToString;
4
4
  static $string(arg: any): boolean;
@@ -10,8 +10,5 @@ export default class Is {
10
10
  static $undefined(arg: any): boolean;
11
11
  static $boolean(arg: any): boolean;
12
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;
13
+ static objectIsValid(data: IGen, rules: IGen): boolean;
17
14
  }
@@ -0,0 +1,5 @@
1
+ export default class Semantic {
2
+ static $numeric(arg: any): boolean;
3
+ static $primitive(arg: any): boolean;
4
+ static $empty(arg: any): boolean;
5
+ }
@@ -0,0 +1,28 @@
1
+ import { default as Is } from '../Is';
2
+ import { default as Semantic } from '../Semantic.ts';
3
+ export default interface ILegacyApi {
4
+ /** @deprecated Use `jis.types.is`. It'll be remove in v3.0.0 **/
5
+ is: typeof Is.is;
6
+ /** @deprecated Use `jis.types.$object`. It'll be remove in v3.0.0 **/
7
+ $object: typeof Is.$object;
8
+ /** @deprecated Use `jis.types.$array`. It'll be remove in v3.0.0 **/
9
+ $array: typeof Is.$array;
10
+ /** @deprecated Use `jis.types.$number`. It'll be remove in v3.0.0 **/
11
+ $number: typeof Is.$number;
12
+ /** @deprecated Use `jis.types.$string`. It'll be remove in v3.0.0 **/
13
+ $string: typeof Is.$string;
14
+ /** @deprecated Use `jis.types.$boolean`. It'll be remove in v3.0.0 **/
15
+ $boolean: typeof Is.$boolean;
16
+ /** @deprecated Use `jis.types.$undefined`. It'll be remove in v3.0.0 **/
17
+ $undefined: typeof Is.$undefined;
18
+ /** @deprecated Use `jis.types.$function`. It'll be remove in v3.0.0 **/
19
+ $function: typeof Is.$function;
20
+ /** @deprecated Use `jis.types.$null`. It'll be remove in v3.0.0 **/
21
+ $null: typeof Is.$null;
22
+ /** @deprecated Use `jis.semantic.$empty`. It'll be remove in v3.0.0 **/
23
+ $empty: typeof Semantic.$empty;
24
+ /** @deprecated Use `jis.semantic.$numeric`. It'll be remove in v3.0.0 **/
25
+ $numeric: typeof Semantic.$numeric;
26
+ /** @deprecated Use `jis.semantic.$primitive`. It'll be remove in v3.0.0 **/
27
+ $primitive: typeof Semantic.$primitive;
28
+ }
@@ -1,3 +1,3 @@
1
- export interface Gen extends Object {
1
+ export interface IGen extends Object {
2
2
  [key: string]: any;
3
3
  }
package/dist/jis.js CHANGED
@@ -1,76 +1,111 @@
1
- class e {
2
- static callToString(t) {
3
- return Object.prototype.toString.call(t);
1
+ class t {
2
+ static callToString(e) {
3
+ return Object.prototype.toString.call(e);
4
4
  }
5
- static $string(t) {
6
- return e.callToString(t) === "[object String]";
5
+ static $string(e) {
6
+ return t.callToString(e) === "[object String]";
7
7
  }
8
- static is(t, n) {
9
- return e.$function(n) ? t instanceof n : e.$string(n) ? e.callToString(t) === `[object ${n}]` : t === n;
8
+ static is(e, r) {
9
+ return t.$function(r) ? e instanceof r : t.$string(r) ? t.callToString(e) === `[object ${r}]` : e === r;
10
10
  }
11
- static $array(t) {
12
- return e.is(t, "Array");
11
+ static $array(e) {
12
+ return t.is(e, "Array");
13
13
  }
14
- static $null(t) {
15
- return e.is(t, "Null");
14
+ static $null(e) {
15
+ return t.is(e, "Null");
16
16
  }
17
- static $number(t) {
18
- return e.is(t, "Number");
17
+ static $number(e) {
18
+ return t.is(e, "Number");
19
19
  }
20
- static $object(t) {
21
- return e.is(t, "Object");
20
+ static $object(e) {
21
+ return t.is(e, "Object");
22
22
  }
23
- static $undefined(t) {
24
- return e.is(t, "Undefined");
23
+ static $undefined(e) {
24
+ return t.is(e, "Undefined");
25
25
  }
26
- static $boolean(t) {
27
- return e.is(t, "Boolean");
26
+ static $boolean(e) {
27
+ return t.is(e, "Boolean");
28
28
  }
29
- static $function(t) {
30
- return e.callToString(t) === "[object Function]";
29
+ static $function(e) {
30
+ return t.callToString(e) === "[object Function]";
31
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;
32
+ static objectIsValid(e, r) {
33
+ if (!t.$object(e)) throw new Error("The data parameter must be an Object");
34
+ if (!t.$object(r)) throw new Error("The rules parameter must be an Object");
35
+ let n = !0;
36
+ return Object.getOwnPropertyNames(r).forEach((i) => {
37
+ let a = r[i];
38
+ if (t.$array(a)) {
39
+ if (a.length < 1) return;
40
+ let o = !1;
41
+ return a.forEach((s) => {
42
+ o = o || t.is(e[i], s);
43
+ }), n = n && o;
44
44
  }
45
- r = r && e.is(t[a], i);
46
- }), r;
45
+ n = n && t.is(e[i], a);
46
+ }), n;
47
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);
48
+ }
49
+ class l {
50
+ static $numeric(e) {
51
+ return [
52
+ t.$number,
53
+ (n) => {
54
+ let c = String(n || "");
55
+ return /^[-+]?(([0-9]+)|([0-9]*(\.[0-9]+))|([0-9]+\.))([Ee]([-+]?[0-9]+))?$/g.test(c);
56
+ }
57
+ ].some((n) => n(e));
53
58
  }
54
- static $primitive(t) {
59
+ static $primitive(e) {
55
60
  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));
61
+ t.$undefined,
62
+ t.$null,
63
+ t.$boolean,
64
+ t.$number,
65
+ t.$string,
66
+ (n) => t.is(n, "Symbol")
67
+ ].some((n) => n(e));
63
68
  }
64
- static $empty(t) {
69
+ static $empty(e) {
65
70
  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));
71
+ t.$undefined,
72
+ t.$null,
73
+ (n) => t.$boolean(n) && !n,
74
+ (n) => t.$number(n) && n === 0,
75
+ (n) => (t.$array(n) || t.$string(n)) && (n === "0" || n.length === 0)
76
+ ].some((n) => n(e));
72
77
  }
73
78
  }
79
+ const {
80
+ is: $,
81
+ $array: u,
82
+ $object: b,
83
+ $number: m,
84
+ $string: f,
85
+ $boolean: d,
86
+ $undefined: j,
87
+ $function: g,
88
+ $null: p
89
+ } = t, {
90
+ $primitive: S,
91
+ $empty: h,
92
+ $numeric: v
93
+ } = l, O = {
94
+ types: t,
95
+ semantic: l,
96
+ is: $,
97
+ $object: b,
98
+ $array: u,
99
+ $number: m,
100
+ $string: f,
101
+ $boolean: d,
102
+ $undefined: j,
103
+ $function: g,
104
+ $null: p,
105
+ $empty: h,
106
+ $numeric: v,
107
+ $primitive: S
108
+ };
74
109
  export {
75
- e as default
110
+ O as default
76
111
  };
package/dist/jis.umd.cjs CHANGED
@@ -1 +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}));
1
+ (function(t,r){typeof exports=="object"&&typeof module<"u"?module.exports=r():typeof define=="function"&&define.amd?define(r):(t=typeof globalThis<"u"?globalThis:t||self,t.jis=r())})(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,i){return t.$function(i)?e instanceof i:t.$string(i)?t.callToString(e)===`[object ${i}]`:e===i}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,i){if(!t.$object(e))throw new Error("The data parameter must be an Object");if(!t.$object(i))throw new Error("The rules parameter must be an Object");let n=!0;return Object.getOwnPropertyNames(i).forEach(o=>{let a=i[o];if(t.$array(a)){if(a.length<1)return;let c=!1;return a.forEach(S=>{c=c||t.is(e[o],S)}),n=n&&c}n=n&&t.is(e[o],a)}),n}}class r{static $numeric(e){return[t.$number,n=>{let s=String(n||"");return/^[-+]?(([0-9]+)|([0-9]*(\.[0-9]+))|([0-9]+\.))([Ee]([-+]?[0-9]+))?$/g.test(s)}].some(n=>n(e))}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))}}const{is:u,$array:l,$object:$,$number:f,$string:b,$boolean:d,$undefined:m,$function:p,$null:j}=t,{$primitive:g,$empty:h,$numeric:y}=r;return{types:t,semantic:r,is:u,$object:$,$array:l,$number:f,$string:b,$boolean:d,$undefined:m,$function:p,$null:j,$empty:h,$numeric:y,$primitive:g}}));
package/dist/main.d.ts CHANGED
@@ -1,2 +1,8 @@
1
1
  import { default as Is } from './Is.ts';
2
- export default Is;
2
+ import { default as ILegacyApi } from './interfaces/ILegacyApi.ts';
3
+ import { default as Semantic } from './Semantic.ts';
4
+ declare const api: ILegacyApi & {
5
+ types: typeof Is;
6
+ semantic: typeof Semantic;
7
+ };
8
+ export default api;
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "jis",
3
3
  "private": false,
4
- "version": "2.0.2",
4
+ "version": "2.1.0-preview.1",
5
5
  "description": "When you need validate the variable data type",
6
6
  "type": "module",
7
7
  "main": "./dist/jis.umd.cjs",
8
8
  "module": "./dist/jis.js",
9
9
  "types": "./dist/main.d.ts",
10
10
  "files": [
11
- "dist"
11
+ "dist",
12
+ "CHANGELOG.md"
12
13
  ],
13
14
  "exports": {
14
15
  ".": {