Explorer

std.bytes-to-stream

description
Wrap a byte list into a pull-based byte stream ({ initialState, next })
type
Fn(bytes: List<Number>) -> Record{
  initialState: Number,
  next: Fn(state: Number) -> Union{#yield(Record{chunk: List<Number>, nextState: Number}), #done}
}
expression
fn(bytes$1) =>
  {
    initialState: 0,
    next: fn(state$2) =>
      match @core.and(
          left: @core.equal(left: $2, right: 0),
          right: @core.greater-than(left: @core.list-length(value: $1), right: 0)
        ) {
        true =>
          #yield({chunk: $1, nextState: 1}),
        false =>
          #done
      }
  }
visibility
public
std.bytes-to-stream (project definy, branch quote-encoded-parts, snapshot LbKb9vIRs5vdtsu6TiOqZ_NMUZJ6k1s6WlbZOc6x3-I)
id: qNclGmQncJlu4yhTTRJM2mLNGlZLwUmoZXzil4NSWSk
content hash: SmsEHXkIa-JZnJscCF_nVQ4P3ZQqHSMKup62BmeYdFU