MCPcopy Create free account
hub / github.com/Effect-TS/effect / string

Method string

packages/effect/src/encoding/SchemaBinary.ts:1510–1540  ·  view source on GitHub ↗
(s: string)

Source from the content-addressed store, hash-verified

1508 this.buf[p] = n
1509 }
1510 string(s: string) {
1511 const n = s.length
1512 if (n === 0) return
1513 this.ensure(n * 3)
1514 const buf = this.buf
1515 let p = this.start + this.len
1516 let i = 0
1517 for (; i + 4 <= n; i += 4) {
1518 const a = s.charCodeAt(i)
1519 const b = s.charCodeAt(i + 1)
1520 const c = s.charCodeAt(i + 2)
1521 const d = s.charCodeAt(i + 3)
1522 if ((a | b | c | d) > 0x7F) {
1523 this.len += utf8Encode.encodeInto(s, buf.subarray(this.start + this.len)).written
1524 return
1525 }
1526 buf[p++] = a
1527 buf[p++] = b
1528 buf[p++] = c
1529 buf[p++] = d
1530 }
1531 for (; i < n; i++) {
1532 const c = s.charCodeAt(i)
1533 if (c > 0x7F) {
1534 this.len += utf8Encode.encodeInto(s, buf.subarray(this.start + this.len)).written
1535 return
1536 }
1537 buf[p++] = c
1538 }
1539 this.len = p - this.start
1540 }
1541 out(): Uint8Array<ArrayBuffer> {
1542 // An assembled frame owns its bytes, so the arena is released as if unused.
1543 if (this.deferred.length > 0) {

Callers 15

markdown.test.tsFile · 0.45
layerFunction · 0.45
layerFunction · 0.45
titleBarDoubleClickMethod · 0.45
[Hash.symbol]Function · 0.45
[Hash.symbol]Method · 0.45
[Hash.symbol]Method · 0.45
HashRing.test.tsFile · 0.45
[Hash.symbol]Method · 0.45
[Hash.symbol]Method · 0.45
ByteSize.test.tsFile · 0.45

Calls 1

ensureMethod · 0.95

Tested by 8

[Hash.symbol]Function · 0.36
[Hash.symbol]Method · 0.36
[Hash.symbol]Method · 0.36
[Hash.symbol]Method · 0.36
[Hash.symbol]Method · 0.36
[Hash.symbol]Method · 0.36
[Hash.symbol]Method · 0.36
[Hash.symbol]Method · 0.36