(
this: This<Object<'_>>,
ctx: Ctx,
encoding: Opt<String>,
start: Opt<i32>,
end: Opt<i32>,
)
| 398 | } |
| 399 | |
| 400 | fn to_string( |
| 401 | this: This<Object<'_>>, |
| 402 | ctx: Ctx, |
| 403 | encoding: Opt<String>, |
| 404 | start: Opt<i32>, |
| 405 | end: Opt<i32>, |
| 406 | ) -> Result<String> { |
| 407 | let typed_array = TypedArray::<u8>::from_object(this.0)?; |
| 408 | let bytes: &[u8] = typed_array.as_ref(); |
| 409 | |
| 410 | let start = start |
| 411 | .0 |
| 412 | .map(|s| s.max(0) as usize) |
| 413 | .unwrap_or(0) |
| 414 | .min(bytes.len()); |
| 415 | let end = end |
| 416 | .0 |
| 417 | .map(|e| e.max(0) as usize) |
| 418 | .unwrap_or(bytes.len()) |
| 419 | .min(bytes.len()); |
| 420 | let bytes = &bytes[start..end]; |
| 421 | |
| 422 | let encoder = Encoder::from_optional_str(encoding.as_deref()).or_throw(&ctx)?; |
| 423 | encoder.encode_to_string(bytes, true).or_throw(&ctx) |
| 424 | } |
| 425 | |
| 426 | fn write<'js>( |
| 427 | this: This<Object<'js>>, |
nothing calls this directly
no test coverage detected