-
Notifications
You must be signed in to change notification settings - Fork 117
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
The module's structure makes it hard to customize #136
Comments
Hi @jean-emmanuel, Thanks for the note. I'm not sure I understand the issue you faced when trying to override osc.js' implementation. Can you provide any more details? There is a pull request from @okofish, #92, which has been languishing for a long time due to lack of time on my part, but it also introduces UTF-8 encoding support. Could be a good opportunity to get this into a release. Thanks again! |
Hi, thanks for your answer ! Well at first I tried the following but it didn't work because var osc = require('osc'),
utf8 = require('utf8')
osc.writeUtfString = (str)=>{
return osc.writeString(utf8.encode(str))
}
osc.readUtfString = (dv, offsetState)=>{
return utf8.decode(osc.readString(dv, offsetState))
}
osc.argumentTypes.s = osc.argumentTypes.S = {
reader: 'readUtfString',
writer: 'writeUtfString'
}
module.exports = osc I opened this issue more to share the workaround rather than to point a flaw in the lib by the way. I had not read this PR, it sound cool indeed, I'll try to get into its details and help if I can. |
The design of osc.js was always intended to be as public and shared as possible and to avoid the sorts of encapsulation that prevent user modification, monkey patching, and unanticipated user change (for many, this may be a controversial or confusing statement, but I've written about this in more detail elsewhere). The mechanism by which modules are loaded into the shared So I agree with you @jean-emmanuel that this is a bug and should be fixed. I'm glad you've got a work-around for now, since it may take some time before I can address this. It is of course at least peripherally related to #119, too. Thanks for explaining the issue you encountered, and sorry for the trouble. |
Not really an issue, but while trying to add support for utf8 encoded string arguments to my application, I found out osc's reader / writer functions could not be overridden easily due to the module's structure that uses a scoped copy of the
osc
variable (if I understood correctly).Anyway, I ended up with the following workaround:
The text was updated successfully, but these errors were encountered: