1 line
6.8 KiB
JSON
1 line
6.8 KiB
JSON
|
{"ast":null,"code":"\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.readJsonObject = exports.arrayObjectsMap = exports.object = exports.array = exports.boolean = exports.number = exports.stringOpt = exports.string = void 0;\nconst errors_js_1 = require(\"../../errors.js\");\nfunction string(value) {\n if (typeof value === \"string\") {\n return value;\n }\n throw typeError(value, \"string\");\n}\nexports.string = string;\nfunction stringOpt(value) {\n if (value === null || value === undefined) {\n return undefined;\n } else if (typeof value === \"string\") {\n return value;\n }\n throw typeError(value, \"string or null\");\n}\nexports.stringOpt = stringOpt;\nfunction number(value) {\n if (typeof value === \"number\") {\n return value;\n }\n throw typeError(value, \"number\");\n}\nexports.number = number;\nfunction boolean(value) {\n if (typeof value === \"boolean\") {\n return value;\n }\n throw typeError(value, \"boolean\");\n}\nexports.boolean = boolean;\nfunction array(value) {\n if (Array.isArray(value)) {\n return value;\n }\n throw typeError(value, \"array\");\n}\nexports.array = array;\nfunction object(value) {\n if (value !== null && typeof value === \"object\" && !Array.isArray(value)) {\n return value;\n }\n throw typeError(value, \"object\");\n}\nexports.object = object;\nfunction arrayObjectsMap(value, fun) {\n return array(value).map(elemValue => fun(object(elemValue)));\n}\nexports.arrayObjectsMap = arrayObjectsMap;\nfunction typeError(value, expected) {\n if (value === undefined) {\n return new errors_js_1.ProtoError(`Expected ${expected}, but the property was missing`);\n }\n let received = typeof value;\n if (value === null) {\n received = \"null\";\n } else if (Array.isArray(value)) {\n received = \"array\";\n }\n return new errors_js_1.ProtoError(`Expected ${expected}, received ${received}`);\n}\nfunction readJsonObject(value, fun) {\n return fun(object(value));\n}\nexports.readJsonObject = readJsonObject;","map":{"version":3,"names":["Object","defineProperty","exports","value","readJsonObject","arrayObjectsMap","object","array","boolean","number","stringOpt","string","errors_js_1","require","typeError","undefined","Array","isArray","fun","map","elemValue","expected","ProtoError","received"],"sources":["/Users/shoofle/Projects/the-forest/node_modules/@libsql/hrana-client/lib-cjs/encoding/json/decode.js"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.readJsonObject = exports.arrayObjectsMap = exports.object = exports.array = exports.boolean = exports.number = exports.stringOpt = exports.string = void 0;\nconst errors_js_1 = require(\"../../errors.js\");\nfunction string(value) {\n if (typeof value === \"string\") {\n return value;\n }\n throw typeError(value, \"string\");\n}\nexports.string = string;\nfunction stringOpt(value) {\n if (value === null || value === undefined) {\n return undefined;\n }\n else if (typeof value === \"string\") {\n return value;\n }\n throw typeError(value, \"string or null\");\n}\nexports.stringOpt = stringOpt;\nfunction number(value) {\n if (typeof value === \"number\") {\n return value;\n }\n throw typeError(value, \"number\");\n}\nexports.number = number;\nfunction boolean(value) {\n if (typeof value === \"boolean\") {\n return value;\n }\n throw typeError(value, \"boolean\");\n}\nexports.boolean = boolean;\nfunction array(value) {\n if (Array.isArray(value)) {\n return value;\n }\n throw typeError(value, \"array\");\n}\nexports.array = array;\nfunction object(value) {\n if (value !== null && typeof value === \"object\" && !Array.isArray(value)) {\n return value;\n }\n throw typeError(value, \"object\");\n}\nexports.object = object;\nfunction arrayObjectsMap(value, fun) {\n return array(value).map((elemValue) => fun(object(elemValue)));\n}\nexports.arrayObjectsMap = arrayObjectsMap;\nfunction t
|