@jdeighan/coffee-utils 8.0.14 → 8.0.15

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jdeighan/coffee-utils",
3
3
  "type": "module",
4
- "version": "8.0.14",
4
+ "version": "8.0.15",
5
5
  "description": "A set of utility functions for CoffeeScript",
6
6
  "main": "coffee_utils.js",
7
7
  "exports": {
@@ -151,12 +151,6 @@ export isBoolean = (x) ->
151
151
 
152
152
  # ---------------------------------------------------------------------------
153
153
 
154
- export isNumber = (x) ->
155
-
156
- return typeof x == 'number' || x instanceof Number
157
-
158
- # ---------------------------------------------------------------------------
159
-
160
154
  export isObject = (x) ->
161
155
 
162
156
  return (typeof x == 'object') \
@@ -280,14 +274,33 @@ export isRegExp = (x) ->
280
274
 
281
275
  # ---------------------------------------------------------------------------
282
276
 
283
- export isInteger = (x) ->
277
+ export isNumber = (x, hOptions={}) ->
278
+
279
+ result = (typeof x == 'number') || (x instanceof Number)
280
+ if result
281
+ if defined(hOptions.min) && (x < hOptions.min)
282
+ result = false
283
+ if defined(hOptions.max) && (x > hOptions.max)
284
+ result = false
285
+ return result
286
+
287
+ # ---------------------------------------------------------------------------
288
+
289
+ export isInteger = (x, hOptions={}) ->
284
290
 
285
291
  if (typeof x == 'number')
286
- return Number.isInteger(x)
287
- else if (getClassName(x) == 'Number')
288
- return Number.isInteger(x.valueOf())
292
+ result = Number.isInteger(x)
293
+ else if (x instanceof Number)
294
+ result = Number.isInteger(x.valueOf())
289
295
  else
290
- return false
296
+ result = false
297
+
298
+ if result
299
+ if defined(hOptions.min) && (x < hOptions.min)
300
+ result = false
301
+ if defined(hOptions.max) && (x > hOptions.max)
302
+ result = false
303
+ return result
291
304
 
292
305
  # ---------------------------------------------------------------------------
293
306
 
@@ -144,11 +144,6 @@ export var isBoolean = function(x) {
144
144
  return typeof x === 'boolean';
145
145
  };
146
146
 
147
- // ---------------------------------------------------------------------------
148
- export var isNumber = function(x) {
149
- return typeof x === 'number' || x instanceof Number;
150
- };
151
-
152
147
  // ---------------------------------------------------------------------------
153
148
  export var isObject = function(x) {
154
149
  return (typeof x === 'object') && !isString(x) && !isArray(x) && !isHash(x) && !isNumber(x);
@@ -280,14 +275,39 @@ export var isRegExp = function(x) {
280
275
  };
281
276
 
282
277
  // ---------------------------------------------------------------------------
283
- export var isInteger = function(x) {
278
+ export var isNumber = function(x, hOptions = {}) {
279
+ var result;
280
+ result = (typeof x === 'number') || (x instanceof Number);
281
+ if (result) {
282
+ if (defined(hOptions.min) && (x < hOptions.min)) {
283
+ result = false;
284
+ }
285
+ if (defined(hOptions.max) && (x > hOptions.max)) {
286
+ result = false;
287
+ }
288
+ }
289
+ return result;
290
+ };
291
+
292
+ // ---------------------------------------------------------------------------
293
+ export var isInteger = function(x, hOptions = {}) {
294
+ var result;
284
295
  if (typeof x === 'number') {
285
- return Number.isInteger(x);
286
- } else if (getClassName(x) === 'Number') {
287
- return Number.isInteger(x.valueOf());
296
+ result = Number.isInteger(x);
297
+ } else if (x instanceof Number) {
298
+ result = Number.isInteger(x.valueOf());
288
299
  } else {
289
- return false;
300
+ result = false;
301
+ }
302
+ if (result) {
303
+ if (defined(hOptions.min) && (x < hOptions.min)) {
304
+ result = false;
305
+ }
306
+ if (defined(hOptions.max) && (x > hOptions.max)) {
307
+ result = false;
308
+ }
290
309
  }
310
+ return result;
291
311
  };
292
312
 
293
313
  // ---------------------------------------------------------------------------