JaneaSystems / nodejs-mobile

Full-fledged Node.js on Android and iOS
https://code.janeasystems.com/nodejs-mobile
Other
2.58k stars 182 forks source link

Can't work with my nodejs project #198

Open phukhanhlee opened 5 years ago

phukhanhlee commented 5 years ago

My node js is simply to web socket relay kit. It works well on terminal but It crash when runing on iOS device. I build success with your demo project and I just put my node project on "nodejs-project" folder and run my project.

Here is the crash ! It seem NodeMobile doesn't support "... operator" in javascript ?

send(data, options, cb) { if (this.readyState === WebSocket.CONNECTING) { throw new Error('WebSocket is not open: readyState 0 (CONNECTING)'); }

if (typeof options === 'function') {
  cb = options;
  options = {};
}

if (typeof data === 'number') data = data.toString();

if (this.readyState !== WebSocket.OPEN) {
  sendAfterClose(this, data, cb);
  return;
}

const opts = {
  binary: typeof data !== 'string',
  mask: !this._isServer,
  compress: true,
  fin: true,
  ...options ->///////// error here ///////////////
};

if (!this._extensions[PerMessageDeflate.extensionName]) {
  opts.compress = false;
}

this._sender.send(data || EMPTY_BUFFER, opts, cb);

}

Screen Shot 2019-05-30 at 5 43 53 PM
phukhanhlee commented 5 years ago

After I replace ... operator with function :

function extendObj(obj, src) { for (var key in src) { if (src.hasOwnProperty(key)) obj[key] = src[key]; } return obj; }

Seem this library doesn't support new javascript style. I don't master JS but (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax) is quite used a lot in JS

jaimecbernardo commented 5 years ago

Hi @phukhanhlee ,

For iOS, nodejs-mobile uses ChakraCore, which seems to not have full support for the spread operator yet: https://github.com/nodejs/node-chakracore/issues/620

FrankFundel commented 4 years ago

Will this be added anytime soon?