Explorer

definy.json-escape-range

description
The bytes of value from start to end escaped for a JSON string (bytes is core.string-to-bytes of value. Halves the range so the recursion stays shallow)
type
Fn(value: String, bytes: List<Number>, start: Number, end: Number) -> String
expression
fn(value$0, bytes$1, start$2, end$3) =>
  let length$4 = @core.minus(left: $3, right: $2);
  match @core.less-than(left: $4, right: 2) {
    true =>
      match @core.equal(left: $4, right: 1) {
        true =>
          match @core.list-get(list: $1, index: $2) {
            #some(byte$5) =>
              @definy.json-escape-byte(value: $0, byte: $5, start: $2),
            #none(_) =>
              ""
          },
        false =>
          ""
      },
    false =>
      let middle$6 = @core.plus(left: $2, right: @core.divide(left: $4, right: 2));
      @core.string-concat(
        left: @definy.json-escape-range(value: $0, bytes: $1, start: $2, end: $6),
        right: @definy.json-escape-range(value: $0, bytes: $1, start: $6, end: $3)
      )
  }
visibility
public
definy.json-escape-range (project definy, branch main, snapshot lJpAw9BqYQqBEmdLe29QUgZrI1HBApaYuiMJ31XPtKw)
id: ZO5_IDNR-n147dFBcHOGL15AEK8Ugq3yiywXHEPWbNQ
content hash: aXov0UthON7-BlOIJYenqYDp-cN6v22L1ZS7IgDexUM