| 1996 | size < 0 ? null : textDecoder.decode(bytes.subarray(offset, offset + size)) |
| 1997 | |
| 1998 | const makeTextReader = ( |
| 1999 | fields: ReadonlyArray<PgProtocol.FieldDescription> |
| 2000 | ): EffectResult.Result<PgProtocol.FieldReader<string | null>, PgTypes.CodecError> => { |
| 2001 | for (let index = 0; index < fields.length; index++) { |
| 2002 | if (fields[index].format !== 0) { |
| 2003 | return EffectResult.fail( |
| 2004 | new PgTypes.CodecError({ |
| 2005 | message: `Only the text format is supported, column ${index} has format ${fields[index].format}` |
| 2006 | }) |
| 2007 | ) |
| 2008 | } |
| 2009 | } |
| 2010 | return EffectResult.succeed(readText) |
| 2011 | } |
| 2012 | |
| 2013 | /** Turns one decoded row into an object keyed by column name. */ |
| 2014 | type RowBuilder = (rowValues: ReadonlyArray<unknown>) => Row |