ReScript seems to be missing multiple native JavaScript functions, like padStart
. Is there any preprogramed way to use them or do they need to be hand-coded? I currently have
/**
Mimics MDN's `padStart` function
*/
let padStart = (original, num, padding) => {
let numAdd = Js.Math.max_int(0, num - original->Js.String2.length)
let timesAdd = numAdd / padding->Js.String2.length
let extraChars = numAdd->mod(padding->Js.String2.length)
padding->Js.String2.repeat(timesAdd) ++
padding->Js.String2.substring(~from=0, ~to_=extraChars) ++
original
}
as my custom approach but was wondering if there is any plans to create a native approach or if such an approach already exists.