@jdeighan/coffee-utils 7.0.28 → 7.0.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jdeighan/coffee-utils",
3
3
  "type": "module",
4
- "version": "7.0.28",
4
+ "version": "7.0.31",
5
5
  "description": "A set of utility functions for CoffeeScript",
6
6
  "main": "coffee_utils.js",
7
7
  "exports": {
@@ -103,7 +103,7 @@ export hashHasKey = (x, key) ->
103
103
 
104
104
  export isEmpty = (x) ->
105
105
 
106
- if ! x?
106
+ if (x == undef) || (x == null)
107
107
  return true
108
108
  if isString(x)
109
109
  return x.match(/^\s*$/)
@@ -112,7 +112,7 @@ export isEmpty = (x) ->
112
112
  if isHash(x)
113
113
  return Object.keys(x).length == 0
114
114
  else
115
- error "isEmpty(): Invalid parameter"
115
+ return false
116
116
 
117
117
  # ---------------------------------------------------------------------------
118
118
  # nonEmpty
@@ -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]
@@ -92,7 +92,7 @@ export var hashHasKey = function(x, key) {
92
92
  // isEmpty
93
93
  // - string is whitespace, array has no elements, hash has no keys
94
94
  export var isEmpty = function(x) {
95
- if (x == null) {
95
+ if ((x === undef) || (x === null)) {
96
96
  return true;
97
97
  }
98
98
  if (isString(x)) {
@@ -104,7 +104,7 @@ export var isEmpty = function(x) {
104
104
  if (isHash(x)) {
105
105
  return Object.keys(x).length === 0;
106
106
  } else {
107
- return error("isEmpty(): Invalid parameter");
107
+ return false;
108
108
  }
109
109
  };
110
110
 
@@ -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
+ };
@@ -9,7 +9,7 @@ import {arrayToBlock, blockToArray} from '@jdeighan/coffee-utils/block'
9
9
  # ---------------------------------------------------------------------------
10
10
  # NOTE: Currently, only TAB indentation is supported
11
11
  # ---------------------------------------------------------------------------
12
- # splitLine - separate a line into {level, line}
12
+ # splitLine - separate a line into [level, line]
13
13
 
14
14
  export splitLine = (line) ->
15
15
 
@@ -21,7 +21,7 @@ import {
21
21
  // ---------------------------------------------------------------------------
22
22
  // NOTE: Currently, only TAB indentation is supported
23
23
  // ---------------------------------------------------------------------------
24
- // splitLine - separate a line into {level, line}
24
+ // splitLine - separate a line into [level, line]
25
25
  export var splitLine = function(line) {
26
26
  var lMatches;
27
27
  assert(line != null, "splitLine(): line is undef");