funcool / cuerdas

String manipulation library for Clojure(Script)
https://cljdoc.org/d/funcool/cuerdas/2020.03.26-3/
BSD 2-Clause "Simplified" License
304 stars 30 forks source link

range error for pad when length smaller than string #52

Closed thedavidmeister closed 6 years ago

thedavidmeister commented 7 years ago

i'm seeing this when length is smaller than the string for pad

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Resulting_string_too_large

thedavidmeister commented 7 years ago

actually, that's not the exact error, but it was a range error

niwinz commented 7 years ago

Can you provide a failing example please.

mt0erfztxt commented 7 years ago

@niwinz, any news on that issue? In case you still need failing case here it is:

(require '[cuerdas.core :as str])

(str/pad "12345" {:length 4 :padding "0"})
;; On JVM it prints "12345" but on JS it throws with following message
;; #object[RangeError RangeError: Invalid count value]
;;   Function.cuerdas.core.repeat.cljs$core$IFn$_invoke$arity$2 (jar:file:/home/mt0erfztxt/.m2/repository/funcool/cuerdas/2.0.3/cuerdas-2.0.3.jar!/cuerdas/core.cljc:305:16)
;;   cuerdas.core/repeat (jar:file:/home/mt0erfztxt/.m2/repository/funcool/cuerdas/2.0.3/cuerdas-2.0.3.jar!/cuerdas/core.cljc:299:1)
;;   Function.cuerdas.core.pad.cljs$core$IFn$_invoke$arity$variadic (jar:file:/home/mt0erfztxt/.m2/repository/funcool/cuerdas/2.0.3/cuerdas-2.0.3.jar!/cuerdas/core.cljc:691:22)
;;   cuerdas$core$pad (jar:file:/home/mt0erfztxt/.m2/repository/funcool/cuerdas/2.0.3/cuerdas-2.0.3.jar!/cuerdas/core.cljc:677:1)