template-saas/apps/backend/node_modules/postgres-bytea/index.js
rckrdmrd 26f0e52ca7 feat: Initial commit - template-saas
Template base para proyectos SaaS multi-tenant.

Estructura inicial:
- apps/backend (NestJS API)
- apps/frontend (React/Vite)
- apps/database (PostgreSQL DDL)
- docs/ (Documentación)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 04:41:24 -06:00

34 lines
863 B
JavaScript

'use strict'
var bufferFrom = Buffer.from || Buffer
module.exports = function parseBytea (input) {
if (/^\\x/.test(input)) {
// new 'hex' style response (pg >9.0)
return bufferFrom(input.substr(2), 'hex')
}
var output = ''
var i = 0
while (i < input.length) {
if (input[i] !== '\\') {
output += input[i]
++i
} else {
if (/[0-7]{3}/.test(input.substr(i + 1, 3))) {
output += String.fromCharCode(parseInt(input.substr(i + 1, 3), 8))
i += 4
} else {
var backslashes = 1
while (i + backslashes < input.length && input[i + backslashes] === '\\') {
backslashes++
}
for (var k = 0; k < Math.floor(backslashes / 2); ++k) {
output += '\\'
}
i += Math.floor(backslashes / 2) * 2
}
}
}
return bufferFrom(output, 'binary')
}