7

So, I implemented this node.js module which uses deasync.js (as I needed some synchronous computations, and javascript promise was not good enough)

Now, I had to import that to frontend side, and call it from the browser.

But, it seems like browserify.js cannot make it happen. (I see errors complaining about deasync.js part , and it does not work)

Is there any ways to make this happen? Probably frontend version of deasync.js?

I looked at npm module that does the similar job, (synchronous.js), but it seems like browserify.js doesn't like it too. (Since it depends on node(?))

Thanks.

  • 1
    No. No. No. You won't get this to happen. – Bergi Dec 09 '16 at 01:36
  • Please tell us about your actual problem. You'll about never absolutely need a synchronous computation, especially on the server side where you can control everything. – Bergi Dec 09 '16 at 01:37
  • Oh, yes. It was more of a U/X problem rather than a functionality. I could easily do the same thing with JS promises. If you think about how promise looks like, it's quite ugly compared to other languages. For, e.g. if you have var a = computeVal(user); it's much better if you could do console.log(a); instead of a.then(a=>console.log(a)). – kevinJiang99 Dec 09 '16 at 07:22
  • So, deAsync.js is not possible in the front end? I assume that's because it depends on Node. Then, my question is, what makes browserify to not support Node? other than the size issue. – kevinJiang99 Dec 09 '16 at 07:25
  • `deasync` works on node because you can hack that. You can't hack a browser. – Bergi Dec 09 '16 at 10:27
  • You really should use promises then (and improve ux using concurrency). If you want nicer syntax, use `async`/`await`. – Bergi Dec 09 '16 at 10:28
  • I see. Thanks @Bergi – kevinJiang99 Dec 15 '16 at 02:16
  • Here's an interesting related article: [What color is your function?](http://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function/) While `async` / `await` provides a nice syntactic abstraction, it doesn't necessarily solve the underlying problem described in this question. – Patrick Roberts Dec 20 '19 at 18:37

0 Answers0