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,EAAE;EAC1B,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOA,KAAK;EAChB;EACA,MAAMC,SAAS,CAACD,KAAK,EAAE,QAAQ,CAAC;AACpC;AACA,OAAO,SAASK,OAAOA,CAACL,KAAK,EAAE;EAC3B,IAAI,OAAOA,KAAK,KAAK,SAAS,EAAE;IAC5B,OAAOA,KAAK;EAChB;EACA,MAA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