(ctx: &Ctx<'js>, byte_ref: &[u8], length: usize)
| 136 | |
| 137 | if let Some(encoding) = encoding.0 { |
| 138 | let encoder = Encoder::from_str(&encoding).or_throw(&ctx)?; |
| 139 | let bytes = encoder.decode_from_string(string).or_throw(&ctx)?; |
| 140 | return alloc_byte_ref(&ctx, &bytes, length); |
| 141 | } |
| 142 | |
| 143 | let byte_ref = string.as_bytes(); |
| 144 | |
| 145 | return alloc_byte_ref(&ctx, byte_ref, length); |
| 146 | } |
| 147 | if let Some(value) = value.as_int() { |
| 148 | let bytes = vec![value as u8; length]; |