Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 29 08:35
    @sjrd banned @8bitpitRBX_twitter
  • May 23 13:44
    @sjrd banned @BIGCRYPTO001_gitlab
  • May 01 14:31
    @sjrd banned @Certificates1_gitlab
  • Apr 22 15:31
    @sjrd banned @lerbatax
  • Jan 31 23:04
    sjrd commented #3555
  • Jan 31 22:56
    sjrd review_requested #3555
  • Jan 31 22:56
    sjrd opened #3555
  • Jan 31 21:06

    sjrd on 0.6.x

    Remove dead code: specific coll… Adapt the signature of `js.Arra… Merge pull request #3554 from s… (compare)

  • Jan 31 21:06
    sjrd closed #3554
  • Jan 31 20:54
    erikvanoosten commented #2665
  • Jan 31 16:33
    sjrd commented #3538
  • Jan 31 15:54

    sjrd on master

    Fix analyzer cycle detection to… Add toString methods to analyze… Do not provide linked ClassInfo… and 1 more (compare)

  • Jan 31 15:54
    sjrd closed #3552
  • Jan 31 15:54

    sjrd on master

    Remove Logger.success It is un… Make level helpers final Clean-up ScalaConsoleLogger cod… and 1 more (compare)

  • Jan 31 15:54
    sjrd closed #3553
  • Jan 31 15:33
    sjrd commented #2665
  • Jan 31 15:30
    erikvanoosten commented #2665
  • Jan 31 10:41
    sjrd review_requested #3554
  • Jan 31 10:41
    sjrd opened #3554
  • Jan 31 10:05
    gzm0 synchronize #3552
Mustafa Kuscu
@mcku
they ought to run the scalajs test case to reproduce the bug then, right?
Sébastien Doeraene
@sjrd
Yes.
But it's very possible that it won't reproduce on the JVM, because the JVM backend has a tendency to tolerate and fix things on the fly, whereas the Scala.js backend is more strict in what it accepts.
Eric K Richardson
@ekrich
Which versions of Scala.js emit ES5 or ES6?
For 1.0.0-M8 (Scala.js now emits ECMAScript 2015 code by default) is that ES5?
Sébastien Doeraene
@sjrd
2015 is 6
Eric K Richardson
@ekrich
So does 0.6.x also emit ES6?
Mustafa Kuscu
@mcku
yes, since 0.6.26 scalajs emits ES modules. Many people use ES/ES6 to mean ES2015 and newer.. ES5 is, roughly speaking, old, troublesome JS syntax which has no appeal..
Sébastien Doeraene
@sjrd
@ekrich 0.6.x can emit ES2015 if you ask it to. 1.x can also still emit ES5.1 if you ask it to. In both cases, you can ask them to emit scripts, CommonJS modules pour ES modules.
Eric K Richardson
@ekrich
Wow, ok thanks @sjrd and @mcku. Last time I did any serious web programming was in the IE8 era.
moritz bust
@busti
Can I call a native function that is defined multiple times with a differently typed parameter using a union type variable?
class WebSocket {
  def send(data: String): Unit = js.native
  def send(data: Blob): Unit = js.native
  def send(data: ArrayBuffer): Unit = js.native
}

val myData: String | Blob | ArrayBuffer = ???
websocketInstance.send(myData) // Error
Do I have to pattern match?
Should I wrap my data in case classes for each type to avoid having unions in my application code?
moritz bust
@busti
Also, I cannot seem to pattern match for that union.
[error]  found   : String
[error]  required: String | org.scalajs.dom.Blob | scala.scalajs.js.typedarray.ArrayBuffer
[error]     (which expands to)  String | org.scalajs.dom.raw.Blob | scala.scalajs.js.typedarray.ArrayBuffer
[error]             case d: String      => webSocket.send(d)
TATSUNO Yasuhiro
@exoego
IIUC, test uses fastOptJS-produced JS file by default. How to run test using fullOptJS? I need this to verify that full-optimied JS behave as same as fast-optimizes JS.
TATSUNO Yasuhiro
@exoego
I read this but not mentioned. https://www.scala-js.org/doc/project/testing.html
Sébastien Doeraene
@sjrd
set scalaJSStage in Global := FullOptStage before running test
TATSUNO Yasuhiro
@exoego
@sjrd Thanks !!
aappddeevv
@aappddeevv
@Busti For js functions that take complex arguments, in my definitions, I tend to break out methods with different argument types when the "js union" is too complex especially when js callback signatures are involved. But for unions with simple types, I often leave it as a union argument so you could have send above take a union type. You don't need to have myData be of type union for it to work, it could just be one of the union types. You have to widen the union result then test using js tests, it makes pattern matching much more verbose.
There is an example on stackoverflow.
mushtaq
@mushtaq

I am trying to write a facade for this npm module:
https://github.com/canjs/can-ndjson-stream/blob/master/can-ndjson-stream.js

as below:

@JSImport("can-ndjson-stream", JSImport.Namespace)
@js.native
object CanNdJsonStream extends js.Object {
  def ndjsonStream(response: ReadableStream[Uint8Array]): ReadableStream[js.Object] = js.native
}

But I get the following error:

scala.scalajs.js.JavaScriptException: TypeError: $i_can$002dndjson$002dstream.ndjsonStream is not a function

What am I missing?

Sébastien Doeraene
@sjrd
The function is exported as a default member, not under its name.
moritz bust
@busti
@aappddeevv Do you happen to have a link to that example? I cannot find it.
mushtaq
@mushtaq

thanks @sjrd I changed JSImport.Namespace to JSImport.Default, now the error is:

scala.scalajs.js.JavaScriptException: TypeError: $moduleDefault(...).ndjsonStream is not a function

Not sure I interpreted your suggestion correctly.

ok, this seems to work:
@JSImport("can-ndjson-stream", JSImport.Namespace)
@js.native
class CanNdJsonStream extends ReadableStream[Uint8Array] {
  def this(response: ReadableStream[Uint8Array]) = this()
}
mushtaq
@mushtaq
sorry, it should be extends ReadableStream[js.Object]
aappddeevv
@aappddeevv
@Busti here
Li Haoyi
@lihaoyi-databricks
Anyone know what's the current status of new java.text.DecimalFormat(template).format in Scala.js?
It seems it isn't supported in javalib, but not sure if there's a similar API I can use that does the same thing, or some third-party shim
presumably some amount of formatting ability must be present to make Float#toString work
Li Haoyi
@lihaoyi-databricks
https://github.com/cquiroz/scala-java-locales seems to support it but the library doesn't seem to be published to maven central
at least not for scala 2.13
Li Haoyi
@lihaoyi-databricks
Li Haoyi
@lihaoyi-databricks
CC @cquiroz
Li Haoyi
@lihaoyi-databricks
Seems like it doesn't like the java.util.Locale.ENGLISH locale
Li Haoyi
@lihaoyi-databricks
new java.text.DecimalFormat("0.000000E00").format(910) seems to return different values on scalajs/scalajvm
Li Haoyi
@lihaoyi-databricks
I wonder if there's a cheaper way if getting a EN/UK/US-only DecimalFormat if I don't care about other locales? Otherwise scala-java-locales adds almost a megabyte of compiled JS code
LeeTibbert
@LeeTibbert
Recently I have been porting, with thanks & appreciation, from scala-js to scalanative. I have come across two scala-js 'features' that I
changed for the SN port. Before I invest effort in creating PRs for scala-js, I thought I would describe the 'feature' and ask if it is a
candidate for a PR or if it is intended. Thank you for guidance.
The first feature is in java.util.AbstractCollection.scala. j.u.ArrayDeque.scala and, I believe, j.u.AbstractList.scala inherit toString from
LeeTibbert
@LeeTibbert
AbstractCollection. Scala JVM, and now Scala Native, format a Deque containing the elements a, b, and c as [a, b, c]. Scala-js
formats this as [a,b,c]. Note the lack of whitespace after the commas.
There is a strong requirement in SN to match JVM output where feasible. Scala-js may be trying to match some forms of CSV lists.
The fix is trivial. One character of code and probably a unit-test case. Please advise.
LeeTibbert
@LeeTibbert

The second feature is that HashMap.scala appears to be missing the getOrDefault method. Other missing methods may be identified
as I create a SN PR.

I offer these PRs in the spirit of feeding the ancestors, not of being critical of the hand that feeds me...

The HashMap.getOrDefault implementation is again trivial but will need to be reviewed for performance impact in scala-js.
I am told that a lot of work has been done in scala-js in that area and would hate to introduce a regression.
Carlos Quiroz
@cquiroz
@lihaoyi you should use the 0.3.x branch which is smaller and more robust, master which is on the 0.5 line is less maintained but it has Currency support
I have a long standing task of merging them into 0.6 and that should feature an sbt plugin to only select the locales you need
Unfortunately i haven’t had the time to complete the merge
Sébastien Doeraene
@sjrd
@LeeTibbert The space in toString can definitely be fixed. Before your PR in Scala Native, I had never realized that the JVM output was specified in the doc. We do want match the JVM where possible.
For getOrDefault, it's just that we never implemented most JDK 8 methods. A PR would also be welcome.