NeilFraser / JS-Interpreter

A sandboxed JavaScript interpreter in JavaScript.
Apache License 2.0
1.98k stars 355 forks source link

new Date(number) throws TypeError: Bind must be called on a function #223

Open jer-sen opened 2 years ago

jer-sen commented 2 years ago

Hello,

When calling new Date(1234) I get this error:

TypeError: Bind must be called on a function

I would expect just to get a Date with valueOf returning 1234.

NeilFraser commented 2 years ago

Can't recreate. My steps:

Actual result: An alert with "Wed Dec 31 1969 16:00:01 GMT-0800 (Pacific Standard Time)"

What steps are you using to get this error?

jer-sen commented 2 years ago

Just install js-interpreter npm module with npm install js-interpreter, then run node command in a terminal and then this JS code: (new (require('js-interpreter'))("new Date(1234)")).run();. You should get the error TypeError: Bind must be called on a function.

NeilFraser commented 2 years ago

Got it. This bug was previously raised and fixed in #218. Looks like the js-interpreter package you are using needs to be updated. Not sure whom to ping regarding that.

jer-sen commented 2 years ago

The npm package seems abandoned :( https://www.npmjs.com/package/js-interpreter

It is downloaded 3100 times a week. You don't want to publish your project on npm?

aminmarashi commented 2 years ago

@jer-sen @NeilFraser I have updated the package, sorry if this has been misleading, but the NPM package points to my repo which has this one as a submodule and publishes the package from there, I'll keep an eye on issues here in case the package related requests come up here.