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
Merge pull request #4 from wizard04wsu/fewer-keystrokes
Version 4 is not backwards compatible. It has been rewritten to be quicker/easier to type code, avoiding the need for string literals and comparison operators when possible.
| is.**numberish**() | _number_ primitive, instance of `Number`
91
-
92
-
_Numberish_ values can be more explicitly tested using the following methods:
93
-
94
-
| Method | Tests for
95
-
| - | -
96
-
| is.**real**() | real numbers
97
-
| is.**infinite**() | `Infinity`, `-Infinity`
98
-
| is.**number**() | real numbers, `Infinity`, `-Infinity`
99
-
| is.**nan**() | `NaN`
28
+
| .type | The type of _value_ (using this module's type names).
29
+
| .of(_class_) | Tests if _value_ was an instance of _class_.
30
+
| .all(_...descriptors)_ | Takes a list of descriptor names as arguments. Returns `true` if **all** of them applied to _value_.
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_.
33
+
34
+
Enumerable properties of the **is** function are string values of the name of each descriptor. These can be used
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>.
37
+
38
+
39
+
## Type Names and Related Descriptors
40
+
41
+
| Descriptor | Type Name | Primitive Values | Instances Of Classes
| **nan** | yes | `NaN` | `Number` with value `NaN`
59
+
| **number** | yes | `0`, `5`, `Infinity` | `Number` excluding those with value `NaN`
60
+
| real | | `0`, `5` | `Number` with a real number value
61
+
| infinite | | `Infinity` | `Number` with an infinite value
62
+
| **string** | yes | `""`, `"foo"` | `String`
63
+
| **array** | yes | `[]`, `[1,2]` | `Array`
64
+
| **map** | yes | | `Map`
65
+
| **set** | yes | | `Set`
66
+
| **weakmap** | yes | | `WeakMap`
67
+
| **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_
70
+
| **date** | yes | | `Date`
71
+
| **error** | yes | | `Error`
72
+
| **function** | yes | | `Function`
73
+
| **promise** | yes | | `Promise`
74
+
| **regex** | yes | | `Regex`
75
+
76
+
## Note
100
77
101
78
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`.
102
-
103
-
### Text
104
-
105
-
| Method | Tests for
106
-
| - | -
107
-
| is.**regex**() | instance of `RegExp`
108
-
| is.**string**() | _string_ primitive, instance of `String`
109
-
110
-
### Collections
111
-
112
-
| Method | Tests for
113
-
| - | -
114
-
| is.**array**() | instance of `Array`
115
-
| is.**map**() | instance of `Map`
116
-
| is.**set**() | instance of `Set`
117
-
| is.**weakmap**() | instance of `WeakMap`
118
-
| is.**weakset**() | instance of `WeakSet`
119
-
120
-
### Other Common Types
121
-
122
-
| Method | Tests for
123
-
| - | -
124
-
| is.**error**() | instance of `Error`
125
-
| is.**promise**() | instance of `Promise`
126
-
| is.**symbol**() | _symbol_ primitive
127
-
128
-
129
-
## Additional Methods
130
-
131
-
| Method | Description
132
-
| - | -
133
-
| is.**empty**(_value_) | Tests if an object's `.length` or `.size` property equals zero.
134
-
| is.**of**(_value_, _class_) | Tests if _value_ is an instance of _class_. (Same as using the `instanceof` operator.)
0 commit comments