@jdeighan/coffee-utils 7.0.24 → 7.0.25

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.24",
4
+ "version": "7.0.25",
5
5
  "description": "A set of utility functions for CoffeeScript",
6
6
  "main": "coffee_utils.js",
7
7
  "exports": {
@@ -4,7 +4,7 @@ import fs from 'fs'
4
4
  import readline from 'readline'
5
5
 
6
6
  import {
7
- assert, isEmpty, isString, nonEmpty, error, isComment, rtrim,
7
+ assert, isEmpty, isString, nonEmpty, error, rtrim,
8
8
  } from '@jdeighan/coffee-utils'
9
9
 
10
10
  # ---------------------------------------------------------------------------
@@ -108,7 +108,7 @@ var lineNum = 0
108
108
  for await (const line of rl) {
109
109
  lineNum += 1
110
110
  // Each line will be successively available here as 'line'
111
- if (! isComment(line) && func(line, lineNum)) {
111
+ if (func(line, lineNum)) {
112
112
  rl.close(); // close if true return value
113
113
  return;
114
114
  }
@@ -10,7 +10,6 @@ import {
10
10
  isString,
11
11
  nonEmpty,
12
12
  error,
13
- isComment,
14
13
  rtrim
15
14
  } from '@jdeighan/coffee-utils';
16
15
 
@@ -130,7 +129,7 @@ var lineNum = 0
130
129
  for await (const line of rl) {
131
130
  lineNum += 1
132
131
  // Each line will be successively available here as 'line'
133
- if (! isComment(line) && func(line, lineNum)) {
132
+ if (func(line, lineNum)) {
134
133
  rl.close(); // close if true return value
135
134
  return;
136
135
  }
@@ -133,24 +133,6 @@ export nonEmpty = (x) ->
133
133
 
134
134
  # ---------------------------------------------------------------------------
135
135
 
136
- commentRegExp = /^\s*\#+(?:\s|$)/
137
-
138
- # ---------------------------------------------------------------------------
139
-
140
- export setCommentRegexp = (regexp) ->
141
-
142
- commentRegExp = regexp
143
- return
144
-
145
- # ---------------------------------------------------------------------------
146
-
147
- export isComment = (str) ->
148
-
149
- assert isString(str), "isComment(): not a string"
150
- return if str.match(commentRegExp) then true else false
151
-
152
- # ---------------------------------------------------------------------------
153
-
154
136
  export words = (str) ->
155
137
 
156
138
  return str.trim().split(/\s+/)
@@ -411,3 +393,11 @@ export replaceVars = (line, hVars={}, rx=/__(env\.)?([A-Za-z_]\w*)__/g) ->
411
393
  return result
412
394
 
413
395
  return line.replace(rx, replacerFunc)
396
+
397
+ # ---------------------------------------------------------------------------
398
+
399
+ export isIterable = (object) ->
400
+
401
+ if (object == undef) || (object == null)
402
+ return false
403
+ return typeof object[Symbol.iterator] == 'function'
@@ -1,6 +1,6 @@
1
1
  // Generated by CoffeeScript 2.6.1
2
2
  // coffee_utils.coffee
3
- var LOG, commentRegExp;
3
+ var LOG;
4
4
 
5
5
  export var sep_dash = '-'.repeat(42);
6
6
 
@@ -128,24 +128,6 @@ export var nonEmpty = function(x) {
128
128
  }
129
129
  };
130
130
 
131
- // ---------------------------------------------------------------------------
132
- commentRegExp = /^\s*\#+(?:\s|$)/;
133
-
134
- // ---------------------------------------------------------------------------
135
- export var setCommentRegexp = function(regexp) {
136
- commentRegExp = regexp;
137
- };
138
-
139
- // ---------------------------------------------------------------------------
140
- export var isComment = function(str) {
141
- assert(isString(str), "isComment(): not a string");
142
- if (str.match(commentRegExp)) {
143
- return true;
144
- } else {
145
- return false;
146
- }
147
- };
148
-
149
131
  // ---------------------------------------------------------------------------
150
132
  export var words = function(str) {
151
133
  return str.trim().split(/\s+/);
@@ -446,3 +428,11 @@ export var replaceVars = function(line, hVars = {}, rx = /__(env\.)?([A-Za-z_]\w
446
428
  };
447
429
  return line.replace(rx, replacerFunc);
448
430
  };
431
+
432
+ // ---------------------------------------------------------------------------
433
+ export var isIterable = function(object) {
434
+ if ((object === undef) || (object === null)) {
435
+ return false;
436
+ }
437
+ return typeof object[Symbol.iterator] === 'function';
438
+ };