purescript-deprecated/purescript-dom

Add `slice` for Blob

Closed this issue · 3 comments

The slice takes Integer number but using Int will not be correct because its range is smaller, then what this function can handle.
We should

  • either use Number, or
  • define a new data type Data.Int.Long or similar

if we define Data.Int.Long it should be like Int but instead of (n | 0) === n we should use Number.IsSafeInteger(n).

related purescript/purescript-integers#28

Regarding Data.Int.Long there actually is Data.Int53 in purescript-int-53 which I think we should use.

garyb commented

Int53 would definitely be suitable for this, but we try to avoid depending on "private" libraries in -contrib libraries, as it gets awkward if they become unmaintained etc.

Maybe we can do something here with StartByte / EndByte style newtypes that have smart constructors to perform the necessary rounding and clamping from Number instead.