@jdeighan/coffee-utils 10.0.9 → 10.0.10

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": "10.0.9",
4
+ "version": "10.0.10",
5
5
  "description": "A set of utility functions for CoffeeScript",
6
6
  "main": "coffee_utils.js",
7
7
  "exports": {
@@ -10,6 +10,7 @@ import {
10
10
 
11
11
  # ---------------------------------------------------------------------------
12
12
  # blockToArray - split a block into lines
13
+ # DEPRECATED - use toArray()
13
14
 
14
15
  export blockToArray = (block) ->
15
16
 
@@ -68,7 +69,8 @@ export toArray = (item, option=undef) ->
68
69
  return lNewLines
69
70
 
70
71
  # ---------------------------------------------------------------------------
71
- # arrayToBlock - block will have no trailing whitespace
72
+ # arrayToBlock - block and lines in block will have no trailing whitespace
73
+ # DEPRECATED - use toBlock()
72
74
 
73
75
  export arrayToBlock = (lLines) ->
74
76
 
@@ -90,11 +92,11 @@ export toBlock = (lLines) ->
90
92
  if (lLines == undef)
91
93
  return undef
92
94
  assert isArray(lLines), "lLines is not an array"
93
- lLines = lLines.filter((line) => defined(line));
94
- if lLines.length == 0
95
- return undef
96
- else
97
- return lLines.join('\n')
95
+ lNewLines = []
96
+ for line in lLines
97
+ if defined(line)
98
+ lNewLines.push rtrim(line)
99
+ return lNewLines.join("\n")
98
100
 
99
101
  # ---------------------------------------------------------------------------
100
102
 
@@ -23,6 +23,7 @@ import {
23
23
 
24
24
  // ---------------------------------------------------------------------------
25
25
  // blockToArray - split a block into lines
26
+ // DEPRECATED - use toArray()
26
27
  export var blockToArray = function(block) {
27
28
  var lLines, len;
28
29
  if (isEmpty(block)) {
@@ -89,7 +90,8 @@ export var toArray = function(item, option = undef) {
89
90
  };
90
91
 
91
92
  // ---------------------------------------------------------------------------
92
- // arrayToBlock - block will have no trailing whitespace
93
+ // arrayToBlock - block and lines in block will have no trailing whitespace
94
+ // DEPRECATED - use toBlock()
93
95
  export var arrayToBlock = function(lLines) {
94
96
  if (lLines === undef) {
95
97
  return undef;
@@ -109,18 +111,19 @@ export var arrayToBlock = function(lLines) {
109
111
  // toBlock - block may have trailing whitespace
110
112
  // but undef items are ignored
111
113
  export var toBlock = function(lLines) {
114
+ var i, lNewLines, len1, line;
112
115
  if (lLines === undef) {
113
116
  return undef;
114
117
  }
115
118
  assert(isArray(lLines), "lLines is not an array");
116
- lLines = lLines.filter((line) => {
117
- return defined(line);
118
- });
119
- if (lLines.length === 0) {
120
- return undef;
121
- } else {
122
- return lLines.join('\n');
119
+ lNewLines = [];
120
+ for (i = 0, len1 = lLines.length; i < len1; i++) {
121
+ line = lLines[i];
122
+ if (defined(line)) {
123
+ lNewLines.push(rtrim(line));
124
+ }
123
125
  }
126
+ return lNewLines.join("\n");
124
127
  };
125
128
 
126
129
  // ---------------------------------------------------------------------------