@jdeighan/coffee-utils 14.0.14 → 14.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": "14.0.14",
4
+ "version": "14.0.15",
5
5
  "description": "A set of utility functions for CoffeeScript",
6
6
  "main": "coffee_utils.js",
7
7
  "exports": {
@@ -49,13 +49,13 @@
49
49
  },
50
50
  "homepage": "https://github.com/johndeighan/coffee-utils#readme",
51
51
  "dependencies": {
52
- "@jdeighan/base-utils": "^4.0.8",
52
+ "@jdeighan/base-utils": "^4.0.9",
53
53
  "cross-env": "^7.0.3",
54
54
  "n-readlines": "^1.0.1",
55
55
  "readline-sync": "^1.4.10",
56
56
  "svelte": "^3.55.1"
57
57
  },
58
58
  "devDependencies": {
59
- "@jdeighan/unit-tester": "^3.0.25"
59
+ "@jdeighan/unit-tester": "^3.0.27"
60
60
  }
61
61
  }
package/src/indent.coffee CHANGED
@@ -136,7 +136,18 @@ export undented = (input, level=undef, oneIndent="\t") =>
136
136
  if defined(level) && (level==0)
137
137
  return input
138
138
 
139
- lLines = toArray(input, 'noLeadingEmptyLines')
139
+ # --- Remove any leading blank lines, set lLines
140
+ if isString(input)
141
+ if lMatches = input.match(///^ [\r\n]+ (.*) $///s)
142
+ input = lMatches[1]
143
+ lLines = toArray(input)
144
+ else if isArray(input)
145
+ lLines = input
146
+ while (lLines.length > 0) && isEmpty(lLines[0])
147
+ lLines.shift()
148
+ else
149
+ croak "input not a string or array"
150
+
140
151
  if (lLines.length == 0)
141
152
  if isString(input)
142
153
  return ''
package/src/indent.js CHANGED
@@ -150,7 +150,20 @@ export var undented = (input, level = undef, oneIndent = "\t") => {
150
150
  if (defined(level) && (level === 0)) {
151
151
  return input;
152
152
  }
153
- lLines = toArray(input, 'noLeadingEmptyLines');
153
+ // --- Remove any leading blank lines, set lLines
154
+ if (isString(input)) {
155
+ if (lMatches = input.match(/^[\r\n]+(.*)$/s)) {
156
+ input = lMatches[1];
157
+ }
158
+ lLines = toArray(input);
159
+ } else if (isArray(input)) {
160
+ lLines = input;
161
+ while ((lLines.length > 0) && isEmpty(lLines[0])) {
162
+ lLines.shift();
163
+ }
164
+ } else {
165
+ croak("input not a string or array");
166
+ }
154
167
  if (lLines.length === 0) {
155
168
  if (isString(input)) {
156
169
  return '';