@jdeighan/coffee-utils 7.0.27 → 7.0.30

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": "7.0.27",
4
+ "version": "7.0.30",
5
5
  "description": "A set of utility functions for CoffeeScript",
6
6
  "main": "coffee_utils.js",
7
7
  "exports": {
@@ -413,3 +413,18 @@ export isIterable = (obj) ->
413
413
  if (obj == undef) || (obj == null)
414
414
  return false
415
415
  return typeof obj[Symbol.iterator] == 'function'
416
+
417
+ # ---------------------------------------------------------------------------
418
+
419
+ export className = (aClass) ->
420
+
421
+ if lMatches = aClass.toString().match(/class\s+(\w+)/)
422
+ return lMatches[1]
423
+ else
424
+ croak "className(): Bad input class"
425
+
426
+ # ---------------------------------------------------------------------------
427
+
428
+ export range = (n) ->
429
+
430
+ return [0..n-1]
@@ -446,3 +446,23 @@ export var isIterable = function(obj) {
446
446
  }
447
447
  return typeof obj[Symbol.iterator] === 'function';
448
448
  };
449
+
450
+ // ---------------------------------------------------------------------------
451
+ export var className = function(aClass) {
452
+ var lMatches;
453
+ if (lMatches = aClass.toString().match(/class\s+(\w+)/)) {
454
+ return lMatches[1];
455
+ } else {
456
+ return croak("className(): Bad input class");
457
+ }
458
+ };
459
+
460
+ // ---------------------------------------------------------------------------
461
+ export var range = function(n) {
462
+ var ref;
463
+ return (function() {
464
+ var results = [];
465
+ for (var i = 0, ref = n - 1; 0 <= ref ? i <= ref : i >= ref; 0 <= ref ? i++ : i--){ results.push(i); }
466
+ return results;
467
+ }).apply(this);
468
+ };
@@ -181,7 +181,7 @@ export debug = (lArgs...) ->
181
181
  logItem undef, item, hOptions
182
182
  when 'return'
183
183
  log label, hOptions
184
- if item
184
+ if item?
185
185
  # --- don't repeat the label
186
186
  logItem undef, item, hOptions
187
187
  when 'string'
@@ -193,7 +193,7 @@ export var debug = function(...lArgs) {
193
193
  break;
194
194
  case 'return':
195
195
  log(label, hOptions);
196
- if (item) {
196
+ if (item != null) {
197
197
  // --- don't repeat the label
198
198
  logItem(undef, item, hOptions);
199
199
  }