1 line
5.3 KiB
JSON
1 line
5.3 KiB
JSON
|
{"ast":null,"code":"import { ProtoError } from \"../../errors.js\";\nexport function string(value) {\n if (typeof value === \"string\") {\n return value;\n }\n throw typeError(value, \"string\");\n}\nexport function 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}\nexport function number(value) {\n if (typeof value === \"number\") {\n return value;\n }\n throw typeError(value, \"number\");\n}\nexport function boolean(value) {\n if (typeof value === \"boolean\") {\n return value;\n }\n throw typeError(value, \"boolean\");\n}\nexport function array(value) {\n if (Array.isArray(value)) {\n return value;\n }\n throw typeError(value, \"array\");\n}\nexport function object(value) {\n if (value !== null && typeof value === \"object\" && !Array.isArray(value)) {\n return value;\n }\n throw typeError(value, \"object\");\n}\nexport function arrayObjectsMap(value, fun) {\n return array(value).map(elemValue => fun(object(elemValue)));\n}\nfunction typeError(value, expected) {\n if (value === undefined) {\n return new 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 ProtoError(`Expected ${expected}, received ${received}`);\n}\nexport function readJsonObject(value, fun) {\n return fun(object(value));\n}","map":{"version":3,"names":["ProtoError","string","value","typeError","stringOpt","undefined","number","boolean","array","Array","isArray","object","arrayObjectsMap","fun","map","elemValue","expected","received","readJsonObject"],"sources":["/Users/shoofle/Projects/the-forest/node_modules/@libsql/hrana-client/lib-esm/encoding/json/decode.js"],"sourcesContent":["import { ProtoError } from \"../../errors.js\";\nexport function string(value) {\n if (typeof value === \"string\") {\n return value;\n }\n throw typeError(value, \"string\");\n}\nexport function 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}\nexport function number(value) {\n if (typeof value === \"number\") {\n return value;\n }\n throw typeError(value, \"number\");\n}\nexport function boolean(value) {\n if (typeof value === \"boolean\") {\n return value;\n }\n throw typeError(value, \"boolean\");\n}\nexport function array(value) {\n if (Array.isArray(value)) {\n return value;\n }\n throw typeError(value, \"array\");\n}\nexport function object(value) {\n if (value !== null && typeof value === \"object\" && !Array.isArray(value)) {\n return value;\n }\n throw typeError(value, \"object\");\n}\nexport function arrayObjectsMap(value, fun) {\n return array(value).map((elemValue) => fun(object(elemValue)));\n}\nfunction typeError(value, expected) {\n if (value === undefined) {\n return new ProtoError(`Expected ${expected}, but the property was missing`);\n }\n let received = typeof value;\n if (value === null) {\n received = \"null\";\n }\n else if (Array.isArray(value)) {\n received = \"array\";\n }\n return new ProtoError(`Expected ${expected}, received ${received}`);\n}\nexport function readJsonObject(value, fun) {\n return fun(object(value));\n}\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,iBAAiB;AAC5C,OAAO,SAASC,MAAMA,CAACC,KAAK,EAAE;EAC1B,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOA,KAAK;EAChB;EACA,MAAMC,SAAS,CAACD,KAAK,EAAE,QAAQ,CAAC;AACpC;AACA,OAAO,SAASE,SAASA,CAACF,KAAK,EAAE;EAC7B,IAAIA,KAAK,KAAK,IAAI,IAAIA,KAAK,KAAKG,SAAS,EAAE;IACvC,OAAOA,SAAS;EACpB,CAAC,MACI,IAAI,OAAOH,KAAK,KAAK,QAAQ,EAAE;IAChC,OAAOA,KAAK;EAChB;EACA,MAAMC,SAAS,CAACD,KAAK,EAAE,gBAAgB,CAAC;AAC5C;AACA,OAAO,SAASI,MAAMA,CAACJ,KAAK,E
|