Skip to content

Commit

Permalink
Minor documentation and coding style update
Browse files Browse the repository at this point in the history
  • Loading branch information
blu3mania committed Sep 27, 2022
1 parent a8f55c1 commit c32ce45
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ Registry class also provides the normal registry operations:
corresponding JavaScript value types.

- disableLogging()

By default, methods in this package may log warnings and errors to console. If it's not desired, call this
method to turn off logging. Note, it does not turn off the warnings logged in finalizers when opened keys
and monitor tokens are not properly closed/stopped, because they indicate wrong usage of this package.
14 changes: 7 additions & 7 deletions lib/windows-registry.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const ref = require('ref-napi');
const ffi = require('ffi-napi');
const ref = require('ref-napi');

const {
error,
Expand Down Expand Up @@ -296,23 +296,23 @@ const EventApi = ffi.Library('kernel32', {
});

/** Finalizer for RegistryKey to ensure the underlying registry key handle is closed. */
const RegistryKeyFinalizer = new FinalizationRegistry(registryKeyData => {
const registryKeyFinalizer = new FinalizationRegistry(registryKeyData => {
if (registryKeyData.handle !== null) {
warning(`RegistryKey ${registryKeyData.path} is not properly closed! You should call RegistryKey.close() or Registry.closeKey() to close a key when it is no longer needed!`);
Registry.instance.closeKeyInternal(registryKeyData);
}
});

/** Finalizer for MonitoredRegistryKey to ensure the underlying event handle is closed. */
const MonitoredRegistryKeyFinalizer = new FinalizationRegistry(monitorData => {
const monitoredRegistryKeyFinalizer = new FinalizationRegistry(monitorData => {
if (monitorData.waitHandle !== null) {
warning(`MonitoredRegistryKey ${registryKeyData.path} is not properly stopped! You should call Registry.stopMonitor() to stop monitoring a key when it is no longer needed!`);
Registry.instance.stopMonitoredKeyInternal(monitorData);
}
});

/** Finalizer for MonitorToken to ensure the callback is unregistered. */
const MonitorTokenFinalizer = new FinalizationRegistry(tokenData => {
const monitorTokenFinalizer = new FinalizationRegistry(tokenData => {
if (!tokenData.calback !== null) {
warning(`MonitorToken on key ${tokenData.path} is not properly removed! You should call MonitorToken.stop() or Registry.stopMonitor() to stop monitoring a key when it is no longer needed!`);
Registry.instance.stopMonitorInternal(tokenData);
Expand Down Expand Up @@ -356,7 +356,7 @@ class RegistryKey {
this.open();

// Register this key in finalizer so we can be alerted if it's not properly closed
RegistryKeyFinalizer.register(this, this.keyData);
registryKeyFinalizer.register(this, this.keyData);
}

/**
Expand Down Expand Up @@ -740,7 +740,7 @@ class MonitoredRegistryKey extends RegistryKey {
this.start();

// Register this key in finalizer so we can be alerted if it's not properly stopped
MonitoredRegistryKeyFinalizer.register(this, this.monitorData);
monitoredRegistryKeyFinalizer.register(this, this.monitorData);
}

/**
Expand Down Expand Up @@ -898,7 +898,7 @@ class MonitorToken {
};

// Register this token in finalizer so we can be alerted if it's not properly stopped
MonitorTokenFinalizer.register(this, this.tokenData);
monitorTokenFinalizer.register(this, this.tokenData);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/windows-system-error-text.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const ref = require('ref-napi');
const ffi = require('ffi-napi');
const ref = require('ref-napi');

const { fromNullTerminatedWString } = require('./wstring.js');

Expand Down

0 comments on commit c32ce45

Please sign in to comment.