Skip to content

Commit 2e15c28

Browse files
committed
Exposes type names as is function properties
Adds getters (instead of basic properties) to the `is` function for each type descriptor name. This allows using `is.number` or `is.object` directly instead of passing strings to methods like `is(val).all()`.
1 parent a5145b1 commit 2e15c28

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

isType.mjs.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,12 @@ function is(value){
147147
for(const propName in new TypeTest()){
148148
// For each descriptor name:
149149

150-
// Add an enumerable property to the `is` function.
150+
// Add a getter to the `is` function that returns the name of the descriptor.
151+
// This allows you to do `is(val).all(is.number, is.object)` instead of `is(val).all('number', 'object')`.
151152
Object.defineProperty(is, propName, {
152-
value: propName,
153+
get: function(){ return propName; },
153154
enumerable: true,
155+
configurable: true,
154156
});
155157
}
156158

0 commit comments

Comments
 (0)