You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-12Lines changed: 16 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,30 +13,34 @@ See the [test page](https://wizard04wsu.github.io/javascript-type-testing/test/t
13
13
This module uses an expanded set of type names and related descriptors to simplify common tests of values.
14
14
Basic types do not distinguish between primitives and objects, but descriptors _primitive_ or _object_
15
15
can be used to determine that aspect.
16
-
For example, `5` and `new Number(5)` are both _number_, but `5`is _primitive_ and `new Number(5)`is_object_.
16
+
For example, `5` and `new Number(5)` are both type _number_, but `5`has descriptor _primitive_ and `new Number(5)`has descriptor_object_.
17
17
18
-
The **is()** function returns an **IsType**object describing its argument.
18
+
The **is()** function returns an object that describes its argument.
19
19
20
20
Syntax:
21
21
> **is**(_value_)
22
22
23
23
24
-
## IsType Object
24
+
## Return Value
25
25
26
26
| Member | Description
27
27
| - | -
28
28
| .type | The type of _value_ (using this module's type names).
29
-
| .of(_class_) | Tests if _value_was an instance of _class_.
29
+
| .of(_class_) | Tests if _value_is an instance of _class_.
30
30
| .all(_...descriptors)_ | Takes a list of descriptor names as arguments. Returns `true` if **all** of them applied to _value_.
31
31
| .any(_...descriptors_) | Takes a list of descriptor names as arguments. Returns `true` if **any** of them applied to _value_.
32
-
| \[[_descriptor_](#type-names-and-related-descriptors)\] | Descriptors are listed in the table below. Each descriptor property is a boolean that is `true` if it applied to _value_.
32
+
| \[_descriptor_\]| Each [descriptor](#descriptors-and-type-names) property is a boolean that is `true` if it applied to _value_.
33
33
34
-
Enumerable properties of the **is** function are string values of the name of each descriptor. These can be used
34
+
Enumerable properties of `is`are string constants of all the descriptor names. These can be used
35
35
in the `.all()` and `.any()` methods instead of string literals.
36
-
For example, <code>is(<i>value</i>).all("number", "object")</code> is equivalent to <code>is(<i>value</i>).all(is.number, is.object)</code>.
@@ -65,14 +69,14 @@ For example, <code>is(<i>value</i>).all("number", "object")</code> is equivalent
65
69
| **set** | yes | | `Set`
66
70
| **weakmap** | yes | | `WeakMap`
67
71
| **weakset** | yes | | `WeakSet`
68
-
| empty | | `""`, `[]` | `String` or `Array`of length == 0, `Map` or `Set`of size == 0
69
-
| nonempty | | not _empty_| `String`, `Array`, `Map`, or `Set`that is not _empty_
72
+
| empty | | `""`, `[]` | `String` or `Array`with `.length === 0`,<br>`Map` or `Set`with `.size === 0`
73
+
| nonempty | | `"foo"`, `[1,2]` | `String` or `Array` with `.length > 0`,<br>`Map` or `Set`with `.size > 0`
70
74
| **date** | yes | | `Date`
71
75
| **error** | yes | | `Error`
72
76
| **function** | yes | | `Function`
73
77
| **promise** | yes | | `Promise`
74
78
| **regex** | yes | | `Regex`
75
79
76
-
## Note
80
+
## Math Note
77
81
78
82
Note that JavaScript doesn't always treat mathematical expressions of undefined or indeterminate form as you might expect. For example, `1/0` is an undefined form, but JavaScript evaluates it as `Infinity`.
0 commit comments