Bitvested / ta.js

Financial Technical Analysis in JavaScript
MIT License
142 stars 33 forks source link

'return' outside of function #9

Closed ezcafe closed 2 years ago

ezcafe commented 2 years ago

Hi, Thanks for your amazing work.

I got this issue when import this in react app

.../node_modules/ta.js/multi/multi.js
SyntaxError: .../node_modules/ta.js/multi/multi.js: 'return' outside of function. (4:2)

  2 |   const { Worker } = require('worker_threads');
  3 | } catch(e) {
> 4 |   return module.exports = require('../index').sim;
    |   ^
  5 | } finally {
  6 |   async function sim(d, length, sims, perc) {
  7 |     var sd = [], length = (!length) ? 50 : length, sims = (!sims) ? 1000 : sims;

My code

import ta from 'ta.js';
const sma6 = ta.sma([...], 6);
Vultwo commented 2 years ago

Hey,

This is a known react issue. The only workaround at the moment is to import the module via UNPKG https://unpkg.com/ta.js/ta.min.js

Vultwo commented 2 years ago

I have created a react compatible version of this package here: https://github.com/Bitvested/ta.web

ezcafe commented 2 years ago

thank you