@small-tech/auto-encrypt 2.1.0 → 2.3.0

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.
@@ -11,7 +11,7 @@
11
11
  //
12
12
  ////////////////////////////////////////////////////////////////////////////////
13
13
 
14
- import fs from 'fs'
14
+ const fs = require('fs-extra')
15
15
 
16
16
  class SymbolicError extends Error {
17
17
  symbol = null
@@ -21,7 +21,7 @@ class SymbolicError extends Error {
21
21
  // at the end of the error message, in parentheses.
22
22
  const hinted = (str, hint) => hint ? `${str} (${hint}).` : `${str}.`
23
23
 
24
- export default class Throws {
24
+ class Throws {
25
25
  // Define common global errors. These are mixed into a local ERRORS object
26
26
  // if it exists on the object the mixin() method is called with a reference to.
27
27
  static ERRORS = {
@@ -75,6 +75,7 @@ export default class Throws {
75
75
  }
76
76
 
77
77
  ifMissing (parameterName) {
78
+
78
79
  // Attempt to automatically get the argument name even if parameterName was not
79
80
  // manually specified in the code.
80
81
  //
@@ -86,7 +87,7 @@ export default class Throws {
86
87
  const stack = new Error().stack;
87
88
  Error.prepareStackTrace = copy;
88
89
 
89
- const fileName = stack[1].getFileName().replace('file://', '');
90
+ const fileName = stack[1].getFileName();
90
91
  const lineNumber = stack[1].getLineNumber() - 1;
91
92
  const columnNumber = stack[1].getColumnNumber() - 1;
92
93
  const line = fs.readFileSync(fileName, "utf8").split("\n")[lineNumber];
@@ -96,6 +97,7 @@ export default class Throws {
96
97
  if (groups !== null) {
97
98
  argumentName = groups[2]
98
99
  }
100
+
99
101
  this.error(Symbol.for('UndefinedOrNullError'), parameterName || argumentName || '<unknown>')
100
102
  }
101
103
 
@@ -115,3 +117,5 @@ export default class Throws {
115
117
  throw this.createError(symbol, ...args)
116
118
  }
117
119
  }
120
+
121
+ module.exports = Throws
@@ -20,8 +20,10 @@
20
20
  //
21
21
  ////////////////////////////////////////////////////////////////////////////////
22
22
 
23
- export default async function asyncForEach(array, callback) {
23
+ async function asyncForEach(array, callback) {
24
24
  for (let index = 0; index < array.length; index++) {
25
25
  await callback(array[index], index, array);
26
26
  }
27
27
  }
28
+
29
+ module.exports = asyncForEach
package/lib/util/log.js CHANGED
@@ -1,7 +1,9 @@
1
1
  // Conditionally log to console.
2
- export default function log (...args) {
2
+ function log (...args) {
3
3
  if (process.env.QUIET) {
4
4
  return
5
5
  }
6
6
  console.log(...args)
7
7
  }
8
+
9
+ module.exports = log
@@ -1,3 +1,5 @@
1
- export default function waitFor(ms) {
1
+ function waitFor(ms) {
2
2
  return new Promise(resolve => setTimeout(resolve, ms))
3
3
  }
4
+
5
+ module.exports = waitFor