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

Function parseCommandTag

packages/sql/pg/src/PgConnection.ts:1653–1667  ·  view source on GitHub ↗
(tag: string)

Source from the content-addressed store, hash-verified

1651 * that splitting on every space would.
1652 */
1653const parseCommandTag = (tag: string): { command: string; rowCount: number; oid: number | null } => {
1654 const firstSpace = tag.indexOf(" ")
1655 if (firstSpace < 0) return { command: tag, oid: null, rowCount: 0 }
1656 const command = tag.slice(0, firstSpace)
1657 const secondSpace = tag.indexOf(" ", firstSpace + 1)
1658 if (command === "INSERT" && secondSpace > 0) {
1659 return {
1660 command,
1661 oid: Number(tag.slice(firstSpace + 1, secondSpace)),
1662 rowCount: Number(tag.slice(secondSpace + 1))
1663 }
1664 }
1665 const last = tag.slice((secondSpace < 0 ? firstSpace : secondSpace) + 1)
1666 return { command, oid: null, rowCount: isDigits(last) ? Number(last) : 0 }
1667}
1668
1669const isDigits = (value: string): boolean => {
1670 if (value.length === 0) return false

Callers 1

onMessageMethod · 0.85

Calls 3

isDigitsFunction · 0.85
sliceMethod · 0.80
NumberFunction · 0.50

Tested by

no test coverage detected