ldez / cubejs

cube.js -- JavaScript library for modeling and solving the 3x3x3 Rubik's Cube
http://ldez.github.io/cubejs/
MIT License
309 stars 47 forks source link

Potential Worker Script Issue #11

Closed michaelcmelton closed 6 years ago

michaelcmelton commented 6 years ago

I'm having an issue using it on my own, in my project. I'm returning an importScripts is not a function issue in the Javascript console. I don't know much about worker scripts, so any help would be appreciated. Thanks.

ldez commented 6 years ago

Could you provide more information? (Github repo, sample, ...)

michaelcmelton commented 6 years ago

For your repo ldez/cubejs, I guess i don't know how I need to use it inside a node app. How do I initialize it and everything else?

ldez commented 6 years ago

I'm returning an importScripts is not a function issue in the Javascript console.

I want to know your code (your repo, your context).

const Cubejs = require('cubejs/lib/cube.js');

console.log(Cubejs.random())
console.log(Cubejs.inverse("U R"));
const Cubejs = require('cubejs/lib/cube.js');
require('cubejs/lib/solve.js');

Cubejs.initSolver();

const cube01 = new Cubejs();
console.log(cube01.solve());

const cube02 = Cubejs.random();
console.log(cube02.solve());
ldez commented 6 years ago

WebWorker is for browser because Node doesn't support natively WebWorker.

michaelcmelton commented 6 years ago

Makes sense, so I've revamped my code then. Now my server.js is returning a cube.scramble is not a function error

screen shot 2017-09-02 at 5 11 34 pm

Repo here

ldez commented 6 years ago

@michaelcmelton https://github.com/michaelcmelton/speedcubing-timer/pull/1