the-forest/client/node_modules/.cache/babel-loader/949fa947084fbb144d4ce3d4e7d8b6c5707e9b53fccb42fba306418e7ce67ed2.json

1 line
6.6 KiB
JSON
Raw Normal View History

2024-09-17 20:35:18 -04:00
{"ast":null,"code":"import { ResponseError } from \"./errors.js\";\nimport { valueFromProto } from \"./value.js\";\nexport function stmtResultFromProto(result) {\n return {\n affectedRowCount: result.affectedRowCount,\n lastInsertRowid: result.lastInsertRowid,\n columnNames: result.cols.map(col => col.name),\n columnDecltypes: result.cols.map(col => col.decltype)\n };\n}\nexport function rowsResultFromProto(result, intMode) {\n const stmtResult = stmtResultFromProto(result);\n const rows = result.rows.map(row => rowFromProto(stmtResult.columnNames, row, intMode));\n return {\n ...stmtResult,\n rows\n };\n}\nexport function rowResultFromProto(result, intMode) {\n const stmtResult = stmtResultFromProto(result);\n let row;\n if (result.rows.length > 0) {\n row = rowFromProto(stmtResult.columnNames, result.rows[0], intMode);\n }\n return {\n ...stmtResult,\n row\n };\n}\nexport function valueResultFromProto(result, intMode) {\n const stmtResult = stmtResultFromProto(result);\n let value;\n if (result.rows.length > 0 && stmtResult.columnNames.length > 0) {\n value = valueFromProto(result.rows[0][0], intMode);\n }\n return {\n ...stmtResult,\n value\n };\n}\nfunction rowFromProto(colNames, values, intMode) {\n const row = {};\n // make sure that the \"length\" property is not enumerable\n Object.defineProperty(row, \"length\", {\n value: values.length\n });\n for (let i = 0; i < values.length; ++i) {\n const value = valueFromProto(values[i], intMode);\n Object.defineProperty(row, i, {\n value\n });\n const colName = colNames[i];\n if (colName !== undefined && !Object.hasOwn(row, colName)) {\n Object.defineProperty(row, colName, {\n value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n }\n }\n return row;\n}\nexport function errorFromProto(error) {\n return new ResponseError(error.message, error);\n}","map":{"version":3,"names":["ResponseError","valueFromProto","stmtResultFromProto","result","affectedRowCount","lastInsertRowid","columnNames","cols","map","col","name","columnDecltypes","decltype","rowsResultFromProto","intMode","stmtResult","rows","row","rowFromProto","rowResultFromProto","length","valueResultFromProto","value","colNames","values","Object","defineProperty","i","colName","undefined","hasOwn","enumerable","configurable","writable","errorFromProto","error","message"],"sources":["/Users/shoofle/Projects/the-forest/node_modules/@libsql/hrana-client/lib-esm/result.js"],"sourcesContent":["import { ResponseError } from \"./errors.js\";\nimport { valueFromProto } from \"./value.js\";\nexport function stmtResultFromProto(result) {\n return {\n affectedRowCount: result.affectedRowCount,\n lastInsertRowid: result.lastInsertRowid,\n columnNames: result.cols.map(col => col.name),\n columnDecltypes: result.cols.map(col => col.decltype),\n };\n}\nexport function rowsResultFromProto(result, intMode) {\n const stmtResult = stmtResultFromProto(result);\n const rows = result.rows.map(row => rowFromProto(stmtResult.columnNames, row, intMode));\n return { ...stmtResult, rows };\n}\nexport function rowResultFromProto(result, intMode) {\n const stmtResult = stmtResultFromProto(result);\n let row;\n if (result.rows.length > 0) {\n row = rowFromProto(stmtResult.columnNames, result.rows[0], intMode);\n }\n return { ...stmtResult, row };\n}\nexport function valueResultFromProto(result, intMode) {\n const stmtResult = stmtResultFromProto(result);\n let value;\n if (result.rows.length > 0 && stmtResult.columnNames.length > 0) {\n value = valueFromProto(result.rows[0][0], intMode);\n }\n return { ...stmtResult, value };\n}\nfunction rowFromProto(colNames, values, intMode) {\n const row = {};\n // make sure that the \"length\" property is not enumerable\n Object.defineProperty(row, \"length\", { value: values.length });\n for (let i = 0; i < values.length; ++i) {\n const value = valueFromProto(v