@jdeighan/coffee-utils 16.0.11 → 16.0.13

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": "16.0.11",
4
+ "version": "16.0.13",
5
5
  "description": "A set of utility functions for CoffeeScript",
6
6
  "main": "coffee_utils.js",
7
7
  "exports": {
@@ -45,14 +45,14 @@
45
45
  },
46
46
  "homepage": "https://github.com/johndeighan/coffee-utils#readme",
47
47
  "dependencies": {
48
- "@jdeighan/base-utils": "^7.0.1",
48
+ "@jdeighan/base-utils": "^8.0.0",
49
49
  "cross-env": "^7.0.3",
50
50
  "n-readlines": "^1.0.1",
51
51
  "readline-sync": "^1.4.10",
52
52
  "svelte": "^4.0.5"
53
53
  },
54
54
  "devDependencies": {
55
- "@jdeighan/unit-tester": "^3.0.56",
55
+ "@jdeighan/unit-tester": "^3.0.58",
56
56
  "ava": "^5.3.1"
57
57
  }
58
58
  }
package/src/lib/fs.coffee CHANGED
@@ -213,6 +213,7 @@ export getFullPath = (filepath) =>
213
213
  # ---------------------------------------------------------------------------
214
214
 
215
215
  export forEachLineInFile = (filepath, func) =>
216
+ # --- func gets (line, lineNum, filepath) - lineNum starts at 1
216
217
 
217
218
  reader = new NReadLines(filepath)
218
219
  nLines = 0
@@ -222,7 +223,7 @@ export forEachLineInFile = (filepath, func) =>
222
223
  # --- text is split on \n chars,
223
224
  # we also need to remove \r chars
224
225
  line = buffer.toString().replace(/\r/g, '')
225
- result = func(line, nLines)
226
+ result = func(line, nLines, filepath)
226
227
  assert isBoolean(result)
227
228
  if result
228
229
  reader.close() # allow premature termination
package/src/lib/fs.js CHANGED
@@ -276,6 +276,7 @@ export var getFullPath = (filepath) => {
276
276
  // ---------------------------------------------------------------------------
277
277
  export var forEachLineInFile = (filepath, func) => {
278
278
  var buffer, line, nLines, reader, result;
279
+ // --- func gets (line, lineNum, filepath) - lineNum starts at 1
279
280
  reader = new NReadLines(filepath);
280
281
  nLines = 0;
281
282
  while ((buffer = reader.next())) {
@@ -283,7 +284,7 @@ export var forEachLineInFile = (filepath, func) => {
283
284
  // --- text is split on \n chars,
284
285
  // we also need to remove \r chars
285
286
  line = buffer.toString().replace(/\r/g, '');
286
- result = func(line, nLines);
287
+ result = func(line, nLines, filepath);
287
288
  assert(isBoolean(result));
288
289
  if (result) {
289
290
  reader.close(); // allow premature termination