@jdeighan/coffee-utils 10.0.16 → 10.0.17

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": "10.0.16",
4
+ "version": "10.0.17",
5
5
  "description": "A set of utility functions for CoffeeScript",
6
6
  "main": "coffee_utils.js",
7
7
  "exports": {
@@ -5,8 +5,9 @@ import readline from 'readline'
5
5
 
6
6
  import {assert, error, croak} from '@jdeighan/unit-tester/utils'
7
7
  import {
8
- undef, pass, defined, isEmpty, isString, isArray, nonEmpty, rtrim,
9
- escapeStr,
8
+ undef, pass, defined, notdefined,
9
+ isEmpty, isString, isArray, nonEmpty, isArrayOfStrings,
10
+ escapeStr, rtrim, OL,
10
11
  } from '@jdeighan/coffee-utils'
11
12
 
12
13
  # ---------------------------------------------------------------------------
@@ -90,9 +91,9 @@ export arrayToBlock = (lLines) ->
90
91
 
91
92
  export toBlock = (lLines) ->
92
93
 
93
- if (lLines == undef)
94
+ if notdefined(lLines)
94
95
  return undef
95
- assert isArray(lLines), "lLines is not an array"
96
+ assert isArrayOfStrings(lLines), "lLines is not an array: #{OL(lLines)}"
96
97
  lNewLines = []
97
98
  for line in lLines
98
99
  if defined(line)
@@ -14,12 +14,15 @@ import {
14
14
  undef,
15
15
  pass,
16
16
  defined,
17
+ notdefined,
17
18
  isEmpty,
18
19
  isString,
19
20
  isArray,
20
21
  nonEmpty,
22
+ isArrayOfStrings,
23
+ escapeStr,
21
24
  rtrim,
22
- escapeStr
25
+ OL
23
26
  } from '@jdeighan/coffee-utils';
24
27
 
25
28
  // ---------------------------------------------------------------------------
@@ -113,10 +116,10 @@ export var arrayToBlock = function(lLines) {
113
116
  // but undef items are ignored
114
117
  export var toBlock = function(lLines) {
115
118
  var i, lNewLines, len1, line;
116
- if (lLines === undef) {
119
+ if (notdefined(lLines)) {
117
120
  return undef;
118
121
  }
119
- assert(isArray(lLines), "lLines is not an array");
122
+ assert(isArrayOfStrings(lLines), `lLines is not an array: ${OL(lLines)}`);
120
123
  lNewLines = [];
121
124
  for (i = 0, len1 = lLines.length; i < len1; i++) {
122
125
  line = lLines[i];
@@ -647,3 +647,9 @@ export getOptions = (hOptions, hDefault={}) ->
647
647
  return hOptions
648
648
  else
649
649
  return hDefault
650
+
651
+ # ---------------------------------------------------------------------------
652
+
653
+ export timestamp = () ->
654
+
655
+ return new Date().toLocaleTimeString("en-US")
@@ -731,3 +731,8 @@ export var getOptions = function(hOptions, hDefault = {}) {
731
731
  return hDefault;
732
732
  }
733
733
  };
734
+
735
+ // ---------------------------------------------------------------------------
736
+ export var timestamp = function() {
737
+ return new Date().toLocaleTimeString("en-US");
738
+ };
@@ -68,7 +68,8 @@ export isUndented = (line) ->
68
68
  return (lMatches[0].length == 0)
69
69
 
70
70
  # ---------------------------------------------------------------------------
71
- # indented - add indentation to each string in a block
71
+ # indented - add indentation to each string in a block or array
72
+ # - always returns a string
72
73
 
73
74
  export indented = (input, level=1, oneIndent="\t") ->
74
75
 
@@ -81,7 +81,8 @@ export var isUndented = function(line) {
81
81
  };
82
82
 
83
83
  // ---------------------------------------------------------------------------
84
- // indented - add indentation to each string in a block
84
+ // indented - add indentation to each string in a block or array
85
+ // - always returns a string
85
86
  export var indented = function(input, level = 1, oneIndent = "\t") {
86
87
  var lInputLines, lLines, line, toAdd;
87
88
  assert(level >= 0, "indented(): negative level");