@jdeighan/coffee-utils 11.0.4 → 11.0.5

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": "11.0.4",
4
+ "version": "11.0.5",
5
5
  "description": "A set of utility functions for CoffeeScript",
6
6
  "main": "coffee_utils.js",
7
7
  "exports": {
@@ -50,14 +50,14 @@
50
50
  },
51
51
  "homepage": "https://github.com/johndeighan/coffee-utils#readme",
52
52
  "dependencies": {
53
- "@jdeighan/exceptions": "^1.0.3",
53
+ "@jdeighan/exceptions": "^1.0.4",
54
54
  "cross-env": "^7.0.3",
55
55
  "js-yaml": "^4.1.0",
56
56
  "n-readlines": "^1.0.1",
57
57
  "readline-sync": "^1.4.10",
58
- "svelte": "^3.50.1"
58
+ "svelte": "^3.51.0"
59
59
  },
60
60
  "devDependencies": {
61
- "@jdeighan/unit-tester": "^2.0.27"
61
+ "@jdeighan/unit-tester": "^2.0.28"
62
62
  }
63
63
  }
@@ -1,12 +1,12 @@
1
1
  # Section.coffee
2
2
 
3
3
  import {assert, croak} from '@jdeighan/exceptions'
4
+ import {debug} from '@jdeighan/exceptions/debug'
4
5
  import {
5
6
  pass, undef, defined, isArray, isEmpty,
6
7
  } from '@jdeighan/coffee-utils'
7
8
  import {arrayToBlock} from '@jdeighan/coffee-utils/block'
8
9
  import {indented} from '@jdeighan/coffee-utils/indent'
9
- import {debug} from '@jdeighan/coffee-utils/debug'
10
10
 
11
11
  # ---------------------------------------------------------------------------
12
12
 
package/src/Section.js CHANGED
@@ -5,6 +5,10 @@ import {
5
5
  croak
6
6
  } from '@jdeighan/exceptions';
7
7
 
8
+ import {
9
+ debug
10
+ } from '@jdeighan/exceptions/debug';
11
+
8
12
  import {
9
13
  pass,
10
14
  undef,
@@ -21,10 +25,6 @@ import {
21
25
  indented
22
26
  } from '@jdeighan/coffee-utils/indent';
23
27
 
24
- import {
25
- debug
26
- } from '@jdeighan/coffee-utils/debug';
27
-
28
28
  // ---------------------------------------------------------------------------
29
29
  export var Section = class Section {
30
30
  constructor(name, content = undef) {
@@ -1,13 +1,14 @@
1
1
  # SectionMap.coffee
2
2
 
3
- import {LOG, assert, croak} from '@jdeighan/exceptions'
3
+ import {assert, croak} from '@jdeighan/exceptions'
4
+ import {LOG} from '@jdeighan/exceptions/log'
5
+ import {debug} from '@jdeighan/exceptions/debug'
4
6
  import {
5
7
  pass, undef, defined, notdefined, OL, isEmpty, nonEmpty,
6
8
  isString, isHash, isArray, isUniqueTree, isNonEmptyString,
7
9
  isNonEmptyArray,
8
10
  } from '@jdeighan/coffee-utils'
9
11
  import {toBlock} from '@jdeighan/coffee-utils/block'
10
- import {debug} from '@jdeighan/coffee-utils/debug'
11
12
  import {isTAML, fromTAML} from '@jdeighan/coffee-utils/taml'
12
13
  import {Section} from '@jdeighan/coffee-utils/section'
13
14
 
package/src/SectionMap.js CHANGED
@@ -3,11 +3,18 @@
3
3
  var isSectionName, isSetName;
4
4
 
5
5
  import {
6
- LOG,
7
6
  assert,
8
7
  croak
9
8
  } from '@jdeighan/exceptions';
10
9
 
10
+ import {
11
+ LOG
12
+ } from '@jdeighan/exceptions/log';
13
+
14
+ import {
15
+ debug
16
+ } from '@jdeighan/exceptions/debug';
17
+
11
18
  import {
12
19
  pass,
13
20
  undef,
@@ -28,10 +35,6 @@ import {
28
35
  toBlock
29
36
  } from '@jdeighan/coffee-utils/block';
30
37
 
31
- import {
32
- debug
33
- } from '@jdeighan/coffee-utils/debug';
34
-
35
38
  import {
36
39
  isTAML,
37
40
  fromTAML
package/src/block.coffee CHANGED
@@ -4,29 +4,14 @@ import fs from 'fs'
4
4
  import readline from 'readline'
5
5
 
6
6
  import {assert, croak} from '@jdeighan/exceptions'
7
+ import {blockToArray, arrayToBlock} from '@jdeighan/exceptions/utils'
7
8
  import {
8
9
  undef, pass, defined, notdefined,
9
10
  isEmpty, isString, isArray, nonEmpty, isArrayOfStrings,
10
11
  rtrim, OL,
11
12
  } from '@jdeighan/coffee-utils'
12
13
 
13
- # ---------------------------------------------------------------------------
14
- # blockToArray - split a block into lines
15
- # DEPRECATED - use toArray()
16
-
17
- export blockToArray = (block) ->
18
-
19
- if isEmpty(block)
20
- return []
21
- else
22
- lLines = block.split(/\r?\n/)
23
-
24
- # --- remove trailing empty lines
25
- len = lLines.length
26
- while (len > 0) && isEmpty(lLines[len-1])
27
- lLines.pop()
28
- len -= 1
29
- return lLines
14
+ export {blockToArray, arrayToBlock}
30
15
 
31
16
  # ---------------------------------------------------------------------------
32
17
  # toArray - split a block or array into lines w/o newlines
@@ -70,21 +55,6 @@ export toArray = (item, option=undef) ->
70
55
  lNewLines.push line
71
56
  return lNewLines
72
57
 
73
- # ---------------------------------------------------------------------------
74
- # arrayToBlock - block and lines in block will have no trailing whitespace
75
- # DEPRECATED - use toBlock()
76
-
77
- export arrayToBlock = (lLines) ->
78
-
79
- if (lLines == undef)
80
- return undef
81
- assert isArray(lLines), "lLines is not an array"
82
- lLines = lLines.filter((line) => defined(line));
83
- if lLines.length == 0
84
- return undef
85
- else
86
- return rtrim(lLines.join('\n'))
87
-
88
58
  # ---------------------------------------------------------------------------
89
59
  # toBlock - block may have trailing whitespace
90
60
  # but undef items are ignored
package/src/block.js CHANGED
@@ -9,6 +9,11 @@ import {
9
9
  croak
10
10
  } from '@jdeighan/exceptions';
11
11
 
12
+ import {
13
+ blockToArray,
14
+ arrayToBlock
15
+ } from '@jdeighan/exceptions/utils';
16
+
12
17
  import {
13
18
  undef,
14
19
  pass,
@@ -23,29 +28,15 @@ import {
23
28
  OL
24
29
  } from '@jdeighan/coffee-utils';
25
30
 
26
- // ---------------------------------------------------------------------------
27
- // blockToArray - split a block into lines
28
- // DEPRECATED - use toArray()
29
- export var blockToArray = function(block) {
30
- var lLines, len;
31
- if (isEmpty(block)) {
32
- return [];
33
- } else {
34
- lLines = block.split(/\r?\n/);
35
- // --- remove trailing empty lines
36
- len = lLines.length;
37
- while ((len > 0) && isEmpty(lLines[len - 1])) {
38
- lLines.pop();
39
- len -= 1;
40
- }
41
- return lLines;
42
- }
31
+ export {
32
+ blockToArray,
33
+ arrayToBlock
43
34
  };
44
35
 
45
36
  // ---------------------------------------------------------------------------
46
37
  // toArray - split a block or array into lines w/o newlines
47
38
  export var toArray = function(item, option = undef) {
48
- var i, j, lLines, lNewLines, len1, len2, line, nonEmptyFound, ref, substr;
39
+ var i, j, lLines, lNewLines, len, len1, line, nonEmptyFound, ref, substr;
49
40
  // --- Valid options:
50
41
  // 'noEmptyLines'
51
42
  // 'noLeadingEmptyLines'
@@ -60,7 +51,7 @@ export var toArray = function(item, option = undef) {
60
51
  // and possibly remove empty lines
61
52
  lNewLines = [];
62
53
  nonEmptyFound = false;
63
- for (i = 0, len1 = lLines.length; i < len1; i++) {
54
+ for (i = 0, len = lLines.length; i < len; i++) {
64
55
  line = lLines[i];
65
56
  if (isEmpty(line)) {
66
57
  if ((option === 'noEmptyLines') || ((option === 'noLeadingEmptyLines') && !nonEmptyFound)) {
@@ -70,7 +61,7 @@ export var toArray = function(item, option = undef) {
70
61
  }
71
62
  } else if (line.indexOf("\n") > -1) {
72
63
  ref = toArray(line);
73
- for (j = 0, len2 = ref.length; j < len2; j++) {
64
+ for (j = 0, len1 = ref.length; j < len1; j++) {
74
65
  substr = ref[j];
75
66
  if (isEmpty(substr)) {
76
67
  if ((option === 'noEmptyLines') || ((option === 'noLeadingEmptyLines') && !nonEmptyFound)) {
@@ -91,35 +82,17 @@ export var toArray = function(item, option = undef) {
91
82
  return lNewLines;
92
83
  };
93
84
 
94
- // ---------------------------------------------------------------------------
95
- // arrayToBlock - block and lines in block will have no trailing whitespace
96
- // DEPRECATED - use toBlock()
97
- export var arrayToBlock = function(lLines) {
98
- if (lLines === undef) {
99
- return undef;
100
- }
101
- assert(isArray(lLines), "lLines is not an array");
102
- lLines = lLines.filter((line) => {
103
- return defined(line);
104
- });
105
- if (lLines.length === 0) {
106
- return undef;
107
- } else {
108
- return rtrim(lLines.join('\n'));
109
- }
110
- };
111
-
112
85
  // ---------------------------------------------------------------------------
113
86
  // toBlock - block may have trailing whitespace
114
87
  // but undef items are ignored
115
88
  export var toBlock = function(lLines) {
116
- var i, lNewLines, len1, line;
89
+ var i, lNewLines, len, line;
117
90
  if (notdefined(lLines)) {
118
91
  return undef;
119
92
  }
120
93
  assert(isArrayOfStrings(lLines), `lLines is not an array: ${OL(lLines)}`);
121
94
  lNewLines = [];
122
- for (i = 0, len1 = lLines.length; i < len1; i++) {
95
+ for (i = 0, len = lLines.length; i < len; i++) {
123
96
  line = lLines[i];
124
97
  if (defined(line)) {
125
98
  lNewLines.push(rtrim(line));
@@ -173,10 +146,10 @@ export var normalizeBlock = function(content) {
173
146
  throw new Error("normalizeBlock(): not a string");
174
147
  }
175
148
  lLines = (function() {
176
- var i, len1, ref, results;
149
+ var i, len, ref, results;
177
150
  ref = blockToArray(content);
178
151
  results = [];
179
- for (i = 0, len1 = ref.length; i < len1; i++) {
152
+ for (i = 0, len = ref.length; i < len; i++) {
180
153
  line = ref[i];
181
154
  line = line.trim();
182
155
  results.push(line.replace(/\s+/g, ' '));
@@ -200,10 +173,10 @@ export var truncateBlock = function(str, numLines) {
200
173
 
201
174
  // ---------------------------------------------------------------------------
202
175
  export var joinBlocks = function(...lBlocks) {
203
- var block, i, lNonEmptyBlocks, len1, ref;
176
+ var block, i, lNonEmptyBlocks, len, ref;
204
177
  lNonEmptyBlocks = [];
205
178
  ref = lBlocks.flat(999);
206
- for (i = 0, len1 = ref.length; i < len1; i++) {
179
+ for (i = 0, len = ref.length; i < len; i++) {
207
180
  block = ref[i];
208
181
  assert(isString(block), `joinBlocks(): ${block} is not a string`);
209
182
  if (nonEmpty(block)) {
package/src/fs.coffee CHANGED
@@ -5,7 +5,8 @@ import urllib from 'url'
5
5
  import fs from 'fs'
6
6
  import NReadLines from 'n-readlines'
7
7
 
8
- import {LOG, assert, croak} from '@jdeighan/exceptions'
8
+ import {assert, croak} from '@jdeighan/exceptions'
9
+ import {LOG} from '@jdeighan/exceptions/log'
9
10
  import {
10
11
  undef, pass, defined, rtrim, isEmpty, nonEmpty,
11
12
  isString, isArray, isHash, isRegExp, isFunction, OL,
package/src/fs.js CHANGED
@@ -11,11 +11,14 @@ import fs from 'fs';
11
11
  import NReadLines from 'n-readlines';
12
12
 
13
13
  import {
14
- LOG,
15
14
  assert,
16
15
  croak
17
16
  } from '@jdeighan/exceptions';
18
17
 
18
+ import {
19
+ LOG
20
+ } from '@jdeighan/exceptions/log';
21
+
19
22
  import {
20
23
  undef,
21
24
  pass,
package/src/fsa.coffee CHANGED
@@ -1,12 +1,13 @@
1
1
  # fsa.coffee
2
2
 
3
- import {LOG, assert, croak} from '@jdeighan/exceptions'
3
+ import {assert, croak} from '@jdeighan/exceptions'
4
+ import {LOG} from '@jdeighan/exceptions/log'
5
+ import {debug} from '@jdeighan/exceptions/debug'
4
6
  import {
5
7
  undef, defined, notdefined, words, isEmpty, nonEmpty,
6
8
  isString, OL,
7
9
  } from '@jdeighan/coffee-utils'
8
10
  import {toArray} from '@jdeighan/coffee-utils/block'
9
- import {debug} from '@jdeighan/coffee-utils/debug'
10
11
 
11
12
  # ---------------------------------------------------------------------------
12
13
 
package/src/fsa.js CHANGED
@@ -1,11 +1,18 @@
1
1
  // Generated by CoffeeScript 2.7.0
2
2
  // fsa.coffee
3
3
  import {
4
- LOG,
5
4
  assert,
6
5
  croak
7
6
  } from '@jdeighan/exceptions';
8
7
 
8
+ import {
9
+ LOG
10
+ } from '@jdeighan/exceptions/log';
11
+
12
+ import {
13
+ debug
14
+ } from '@jdeighan/exceptions/debug';
15
+
9
16
  import {
10
17
  undef,
11
18
  defined,
@@ -21,10 +28,6 @@ import {
21
28
  toArray
22
29
  } from '@jdeighan/coffee-utils/block';
23
30
 
24
- import {
25
- debug
26
- } from '@jdeighan/coffee-utils/debug';
27
-
28
31
  // ---------------------------------------------------------------------------
29
32
  export var FSA = class FSA {
30
33
  constructor(block) {
package/src/svelte.coffee CHANGED
@@ -1,6 +1,7 @@
1
1
  # svelte.coffee
2
2
 
3
- import {assert, croak, LOG} from '@jdeighan/exceptions'
3
+ import {assert, croak} from '@jdeighan/exceptions'
4
+ import {LOG} from '@jdeighan/exceptions/log'
4
5
  import {isFunction} from '@jdeighan/coffee-utils'
5
6
 
6
7
  # ---------------------------------------------------------------------------
package/src/svelte.js CHANGED
@@ -2,10 +2,13 @@
2
2
  // svelte.coffee
3
3
  import {
4
4
  assert,
5
- croak,
6
- LOG
5
+ croak
7
6
  } from '@jdeighan/exceptions';
8
7
 
8
+ import {
9
+ LOG
10
+ } from '@jdeighan/exceptions/log';
11
+
9
12
  import {
10
13
  isFunction
11
14
  } from '@jdeighan/coffee-utils';