jis 2.0.2 → 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/package.json +1 -1
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
|
|