Files
klz-cables.com/.pnpm-store/v10/files/b3/069812506fc82eccb5d2d9685acb1ee40e9a1c3c3246ee0d437c08050d47888d2d4e9ec11307fecf884bbe82cf34cb9d27ab001dcc8afd770b9eaf781529da
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

47 lines
1.2 KiB
Plaintext

const textParsers = require('./lib/textParsers')
const binaryParsers = require('./lib/binaryParsers')
const builtinTypes = require('./lib/builtins')
exports.getTypeParser = getTypeParser
exports.setTypeParser = setTypeParser
exports.builtins = builtinTypes
const typeParsers = {
text: {},
binary: {}
}
// the empty parse function
const noParse = String
// returns a function used to convert a specific type (specified by
// oid) into a result javascript type
// note: the oid can be obtained via the following sql query:
// SELECT oid FROM pg_type WHERE typname = 'TYPE_NAME_HERE';
function getTypeParser (oid, format) {
format = format || 'text'
if (!typeParsers[format]) {
return noParse
}
return typeParsers[format][oid] || noParse
};
function setTypeParser (oid, format, parseFn) {
if (typeof format === 'function') {
parseFn = format
format = 'text'
}
if (!Number.isInteger(oid)) {
throw new TypeError('oid must be an integer: ' + oid)
}
typeParsers[format][oid] = parseFn
};
textParsers.init(function (oid, converter) {
typeParsers.text[oid] = converter
})
binaryParsers.init(function (oid, converter) {
typeParsers.binary[oid] = converter
})