Skip to content

Commit

Permalink
Revert javascript interface changes
Browse files Browse the repository at this point in the history
  • Loading branch information
implausible committed Apr 8, 2020
1 parent d094f8c commit 05d1863
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
10 changes: 0 additions & 10 deletions js/spec/index-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -673,14 +673,4 @@ describe('Node Sentinel File Watcher', function() {
}
});
});

describe('Garbage collection', function() {
it('can garbage collect all instances', async function () {
this.timeout(60000);
while (nsfw.getAllocatedInstanceCount() > 0) {
global.gc();
await sleep(0);
}
});
});
});
15 changes: 10 additions & 5 deletions js/src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const { promises: fs } = require('fs');
const path = require('path');
const { promisify } = require('util');

const NSFW = require('../../build/Release/nsfw.node');
const { NSFW } = require('../../build/Release/nsfw.node');

function NSFWFilePoller(watchPath, eventCallback, debounceMS) {
const { CREATED, DELETED, MODIFIED } = nsfw.actions;
Expand Down Expand Up @@ -71,7 +72,7 @@ const buildNSFW = async (watchPath, eventCallback, { debounceMS = 500, errorCall
}

if (stats.isDirectory()) {
return new NSFW(watchPath, eventCallback, { debounceMS, errorCallback });
return new NSFW(debounceMS, watchPath, eventCallback, errorCallback);
} else if (stats.isFile()) {
return new NSFWFilePoller(watchPath, eventCallback, debounceMS);
} else {
Expand All @@ -85,9 +86,13 @@ function nsfw(watchPath, eventCallback, options) {
}

const implementation = watchPath;

this.start = () => implementation.start();
this.stop = () => implementation.stop();
if (implementation instanceof NSFW) {
this.start = promisify((callback) => implementation.start(callback));
this.stop = promisify((callback) => implementation.stop(callback));
} else {
this.start = () => implementation.start();
this.stop = () => implementation.stop();
}
}

nsfw.actions = {
Expand Down

0 comments on commit 05d1863

Please sign in to comment.