jis 2.0.1 → 2.0.3-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/README.md +17 -5
- package/dist/Is.d.ts +17 -0
- package/dist/interfaces/main.d.ts +3 -0
- package/dist/jis.js +76 -0
- package/dist/jis.umd.cjs +1 -0
- package/dist/main.d.ts +2 -0
- package/package.json +4 -1
- package/.gitlab-ci.yml +0 -55
- package/src/Is.ts +0 -116
- package/src/interfaces/main.ts +0 -3
- package/src/main.ts +0 -4
- package/test/array.test.ts +0 -19
- package/test/boolean.test.ts +0 -19
- package/test/empty.test.ts +0 -63
- package/test/function.test.ts +0 -15
- package/test/is.test.ts +0 -59
- package/test/null.test.ts +0 -19
- package/test/number.test.ts +0 -15
- package/test/numeric.test.ts +0 -63
- package/test/object.test.ts +0 -15
- package/test/primitive.test.ts +0 -47
- package/test/string.test.ts +0 -18
- package/test/undefined.test.ts +0 -14
- package/tsconfig.json +0 -26
- package/vite.config.ts +0 -28
package/README.md
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
# J`is`
|
|
2
2
|
|
|
3
|
-
`jis` is a data type verifier for
|
|
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
|
-
|
|
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
18
|
|
|
@@ -10,7 +20,7 @@ The library has some methods to check the data type.
|
|
|
10
20
|
npm install jis
|
|
11
21
|
```
|
|
12
22
|
|
|
13
|
-
You can install this library with `npm` or `yarn`. And you can add in `
|
|
23
|
+
You can install this library with `npm` or `yarn`. And you can add in `devDependencies` with
|
|
14
24
|
|
|
15
25
|
```shell script
|
|
16
26
|
npm install jis --dev
|
|
@@ -172,7 +182,7 @@ jis.$numeric( null ) // false
|
|
|
172
182
|
|
|
173
183
|
##### $primitive
|
|
174
184
|
|
|
175
|
-
Check if the argument is primitive
|
|
185
|
+
Check if the argument is a primitive value
|
|
176
186
|
|
|
177
187
|
```js
|
|
178
188
|
|
|
@@ -192,6 +202,8 @@ jis.$primitive(new Date()) // false
|
|
|
192
202
|
|
|
193
203
|
##### $empty
|
|
194
204
|
|
|
205
|
+
$empty follows a semantic definition of emptiness, where certain falsy or zero-like values are intentionally considered empty.
|
|
206
|
+
|
|
195
207
|
```js
|
|
196
208
|
|
|
197
209
|
jis.$empty(null) // true
|
|
@@ -214,7 +226,7 @@ jis.$empty([1, 2, 3]) // false
|
|
|
214
226
|
|
|
215
227
|
##### is
|
|
216
228
|
|
|
217
|
-
This method is the library
|
|
229
|
+
This method is the core of the library and provides more flexible and advanced type checks.
|
|
218
230
|
|
|
219
231
|
```js
|
|
220
232
|
|
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
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
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,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jis",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "2.0.1",
|
|
4
|
+
"version": "2.0.3-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
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
10
13
|
"exports": {
|
|
11
14
|
".": {
|
|
12
15
|
"types": "./dist/main.d.ts",
|
package/.gitlab-ci.yml
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
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/src/Is.ts
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import type {Gen} from "./interfaces/main.ts";
|
|
2
|
-
|
|
3
|
-
export default class Is{
|
|
4
|
-
private static callToString(arg:any) {
|
|
5
|
-
return Object.prototype.toString.call(arg)
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
static $string(arg:any) {
|
|
9
|
-
return Is.callToString(arg) === '[object String]';
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
static is(arg: any, type : any){
|
|
13
|
-
if(Is.$function(type))
|
|
14
|
-
{
|
|
15
|
-
return arg instanceof type;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (Is.$string(type))
|
|
19
|
-
{
|
|
20
|
-
return Is.callToString(arg) === `[object ${type}]`;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return arg === type;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
static $array(arg: any){
|
|
27
|
-
return Is.is(arg, 'Array');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
static $null(arg: any){
|
|
31
|
-
return Is.is(arg, 'Null');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
static $number(arg: any){
|
|
35
|
-
return Is.is(arg, 'Number');
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
static $object(arg: any){
|
|
39
|
-
return Is.is(arg, 'Object');
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
static $undefined(arg: any){
|
|
43
|
-
return Is.is(arg, 'Undefined');
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
static $boolean(arg: any){
|
|
47
|
-
return Is.is(arg, 'Boolean');
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
static $function(arg: any){
|
|
51
|
-
return Is.callToString(arg) === '[object Function]';
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
static objectIsValid(data: Gen, rules: Gen) {
|
|
55
|
-
if (!Is.$object(data)) throw new Error('The data parameter must be an Object');
|
|
56
|
-
if (!Is.$object(rules)) throw new Error('The rules parameter must be an Object');
|
|
57
|
-
|
|
58
|
-
let $response = true;
|
|
59
|
-
let $keys = Object.getOwnPropertyNames(rules);
|
|
60
|
-
|
|
61
|
-
$keys.forEach((key: string) => {
|
|
62
|
-
let rule = rules[key];
|
|
63
|
-
if (Is.$array(rule)) {
|
|
64
|
-
if (rule.length < 1) return;
|
|
65
|
-
let parcial = false;
|
|
66
|
-
rule.forEach((_rule: any) => {
|
|
67
|
-
parcial = parcial || Is.is(data[key], _rule);
|
|
68
|
-
});
|
|
69
|
-
return $response = $response && parcial;
|
|
70
|
-
}
|
|
71
|
-
$response = $response && Is.is(data[key], rule);
|
|
72
|
-
});
|
|
73
|
-
return $response;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
static $numeric(arg: any)
|
|
77
|
-
{
|
|
78
|
-
if (Is.$number(arg))
|
|
79
|
-
{
|
|
80
|
-
return true;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
let $arg = String(arg || '');
|
|
84
|
-
let regex = /^[-+]?(([0-9]+)|([0-9]*(\.[0-9]+))|([0-9]+\.))([Ee]([-+]?[0-9]+))?$/g;
|
|
85
|
-
|
|
86
|
-
return regex.test( $arg );
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
static $primitive(arg: any)
|
|
90
|
-
{
|
|
91
|
-
let validations = [
|
|
92
|
-
Is.$undefined,
|
|
93
|
-
Is.$null,
|
|
94
|
-
Is.$boolean,
|
|
95
|
-
Is.$number,
|
|
96
|
-
Is.$string,
|
|
97
|
-
(arg: any) => Is.is(arg, 'Symbol')
|
|
98
|
-
]
|
|
99
|
-
|
|
100
|
-
return validations.some(item => item(arg))
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
static $empty(arg: any)
|
|
104
|
-
{
|
|
105
|
-
let validations = [
|
|
106
|
-
Is.$undefined,
|
|
107
|
-
Is.$null,
|
|
108
|
-
|
|
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)
|
|
112
|
-
]
|
|
113
|
-
|
|
114
|
-
return validations.some(item => item(arg))
|
|
115
|
-
}
|
|
116
|
-
}
|
package/src/interfaces/main.ts
DELETED
package/src/main.ts
DELETED
package/test/array.test.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
})
|
package/test/boolean.test.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
})
|
package/test/empty.test.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
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
|
-
})
|
package/test/function.test.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
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
|
-
})
|
package/test/null.test.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
})
|
package/test/number.test.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
});
|
package/test/numeric.test.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
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
|
-
})
|
package/test/object.test.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
})
|
package/test/primitive.test.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
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
|
-
})
|
package/test/string.test.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
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
|
-
})
|
package/test/undefined.test.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
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
|
|
24
|
-
},
|
|
25
|
-
"include": ["src"]
|
|
26
|
-
}
|
package/vite.config.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
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
|
-
});
|