-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed to run in Node #385
Comments
well, here are the files if anyone wants to modify them: MidiJson.ts
midi-json-parser-worker : module.ts
midi-json-parser-worker: src/midi-file-parser.ts
k, hope that helps someone. |
Hi @fornof, thanks picking this up again. I got inspired and came up with this. let listener;
let result;
globalThis.self = {
addEventListener: (...args) => listener = args[1],
postMessage: (...args) => ({result} = args[0]),
removeEventListener: () => { }
};
require('midi-json-parser-worker');
delete globalThis.self;
let id = 0;
const parseArrayBuffer = (arrayBuffer) => {
listener({
data: {
id,
method: 'parse',
params: { arrayBuffer }
}
});
id += 1;
return result;
}
const parseBuffer = (buffer) => parseArrayBuffer(buffer.buffer);
module.exports = { parseArrayBuffer, parseBuffer }; It should work as long as you can still use CommonJS in your project and you don't use TypeScript. It's maybe a bit cleaner since you don't have to patch the existing package. But overall I think supporting Node.js should be possible with a few tweaks these days. I've already created two packages to abstract away the usage of Web Workers. It should be possible to adapt those to work with |
This is going to be super for testing that midi files were saved properly.
The code for the converted is very basic - 100 lines tops. Please let me know how you would like to proceed - a fork perhaps? or I can paste in comments?
I'm also horrible at making libraries in javascript, so it's currently just importing the file
import {parseArrayBuffer} from "../../../midi-json-fornof-worker/src/module"
perhaps you can help me fix that? Otherwise it looks hackish but still works.
Issues
I'm mainly going off of this issue that Node isn't supported but it can be ported, but also off of the requests for it to be ported to Node
#371
#378
#371
Solution:
The text was updated successfully, but these errors were encountered: