vrpc 3.3.1 → 3.3.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vrpc",
3
- "version": "3.3.1",
3
+ "version": "3.3.2",
4
4
  "description": "Variadic Remote Procedure Calls",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -38,7 +38,6 @@ SOFTWARE.
38
38
  */
39
39
 
40
40
  const VrpcAdapter = require('./VrpcAdapter')
41
- const Storage = require('@heisenware/storage')
42
41
 
43
42
  /**
44
43
  * Provides a persistence layer for VRPC instances.
@@ -55,19 +54,21 @@ class VrpcPersistor {
55
54
  *
56
55
  * @param {object} options Configuration options for the persistor.
57
56
  * @param {VrpcAgent} options.agentInstance The VRPC agent whose instances should be persisted.
58
- * @param {object} [options.log] Optional logger object (e.g., console) with info, warn, and error methods.
59
57
  * @param {string} [options.dir] Optional directory for storage. Defaults to a path derived from the agent's name.
58
+ * @param {object} [options.log] Optional logger object (e.g. console) with info, warn, and error methods.
60
59
  */
61
- constructor ({ agentInstance, log, dir }) {
62
- this._agentInstance = agentInstance
60
+ constructor ({ agentInstance, dir, log = console }) {
61
+ let Storage
62
+ try {
63
+ Storage = require('@heisenware/storage')
64
+ } catch (err) {
65
+ throw new Error(
66
+ "The '@heisenware/storage' package is required to use VrpcPersistor. Please install it (`npm i @heisenware/storage`) and add it to your project's dependencies."
67
+ )
68
+ }
63
69
 
64
- // Define a no-operation function for the default logger.
65
- const noop = () => {}
66
- // Create a default logger that does nothing.
67
- const defaultLogger = { info: noop, warn: noop, error: noop }
68
- // Merge the user-provided logger with the default.
69
- // This makes the log property optional and prevents crashes if methods are missing.
70
- this._log = Object.assign({}, defaultLogger, log)
70
+ this._agentInstance = agentInstance
71
+ this._log = log
71
72
 
72
73
  this._dir =
73
74
  dir ||