Initial commit: New MoreminiMore website with fresh design
This commit is contained in:
70
node_modules/@libsql/hrana-client/lib-cjs/encoding/json/decode.js
generated
vendored
Normal file
70
node_modules/@libsql/hrana-client/lib-cjs/encoding/json/decode.js
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.readJsonObject = exports.arrayObjectsMap = exports.object = exports.array = exports.boolean = exports.number = exports.stringOpt = exports.string = void 0;
|
||||
const errors_js_1 = require("../../errors.js");
|
||||
function string(value) {
|
||||
if (typeof value === "string") {
|
||||
return value;
|
||||
}
|
||||
throw typeError(value, "string");
|
||||
}
|
||||
exports.string = string;
|
||||
function stringOpt(value) {
|
||||
if (value === null || value === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
else if (typeof value === "string") {
|
||||
return value;
|
||||
}
|
||||
throw typeError(value, "string or null");
|
||||
}
|
||||
exports.stringOpt = stringOpt;
|
||||
function number(value) {
|
||||
if (typeof value === "number") {
|
||||
return value;
|
||||
}
|
||||
throw typeError(value, "number");
|
||||
}
|
||||
exports.number = number;
|
||||
function boolean(value) {
|
||||
if (typeof value === "boolean") {
|
||||
return value;
|
||||
}
|
||||
throw typeError(value, "boolean");
|
||||
}
|
||||
exports.boolean = boolean;
|
||||
function array(value) {
|
||||
if (Array.isArray(value)) {
|
||||
return value;
|
||||
}
|
||||
throw typeError(value, "array");
|
||||
}
|
||||
exports.array = array;
|
||||
function object(value) {
|
||||
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
||||
return value;
|
||||
}
|
||||
throw typeError(value, "object");
|
||||
}
|
||||
exports.object = object;
|
||||
function arrayObjectsMap(value, fun) {
|
||||
return array(value).map((elemValue) => fun(object(elemValue)));
|
||||
}
|
||||
exports.arrayObjectsMap = arrayObjectsMap;
|
||||
function typeError(value, expected) {
|
||||
if (value === undefined) {
|
||||
return new errors_js_1.ProtoError(`Expected ${expected}, but the property was missing`);
|
||||
}
|
||||
let received = typeof value;
|
||||
if (value === null) {
|
||||
received = "null";
|
||||
}
|
||||
else if (Array.isArray(value)) {
|
||||
received = "array";
|
||||
}
|
||||
return new errors_js_1.ProtoError(`Expected ${expected}, received ${received}`);
|
||||
}
|
||||
function readJsonObject(value, fun) {
|
||||
return fun(object(value));
|
||||
}
|
||||
exports.readJsonObject = readJsonObject;
|
||||
77
node_modules/@libsql/hrana-client/lib-cjs/encoding/json/encode.js
generated
vendored
Normal file
77
node_modules/@libsql/hrana-client/lib-cjs/encoding/json/encode.js
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.writeJsonObject = exports.ObjectWriter = void 0;
|
||||
class ObjectWriter {
|
||||
#output;
|
||||
#isFirst;
|
||||
constructor(output) {
|
||||
this.#output = output;
|
||||
this.#isFirst = false;
|
||||
}
|
||||
begin() {
|
||||
this.#output.push('{');
|
||||
this.#isFirst = true;
|
||||
}
|
||||
end() {
|
||||
this.#output.push('}');
|
||||
this.#isFirst = false;
|
||||
}
|
||||
#key(name) {
|
||||
if (this.#isFirst) {
|
||||
this.#output.push('"');
|
||||
this.#isFirst = false;
|
||||
}
|
||||
else {
|
||||
this.#output.push(',"');
|
||||
}
|
||||
this.#output.push(name);
|
||||
this.#output.push('":');
|
||||
}
|
||||
string(name, value) {
|
||||
this.#key(name);
|
||||
this.#output.push(JSON.stringify(value));
|
||||
}
|
||||
stringRaw(name, value) {
|
||||
this.#key(name);
|
||||
this.#output.push('"');
|
||||
this.#output.push(value);
|
||||
this.#output.push('"');
|
||||
}
|
||||
number(name, value) {
|
||||
this.#key(name);
|
||||
this.#output.push("" + value);
|
||||
}
|
||||
boolean(name, value) {
|
||||
this.#key(name);
|
||||
this.#output.push(value ? "true" : "false");
|
||||
}
|
||||
object(name, value, valueFun) {
|
||||
this.#key(name);
|
||||
this.begin();
|
||||
valueFun(this, value);
|
||||
this.end();
|
||||
}
|
||||
arrayObjects(name, values, valueFun) {
|
||||
this.#key(name);
|
||||
this.#output.push('[');
|
||||
for (let i = 0; i < values.length; ++i) {
|
||||
if (i !== 0) {
|
||||
this.#output.push(',');
|
||||
}
|
||||
this.begin();
|
||||
valueFun(this, values[i]);
|
||||
this.end();
|
||||
}
|
||||
this.#output.push(']');
|
||||
}
|
||||
}
|
||||
exports.ObjectWriter = ObjectWriter;
|
||||
function writeJsonObject(value, fun) {
|
||||
const output = [];
|
||||
const writer = new ObjectWriter(output);
|
||||
writer.begin();
|
||||
fun(writer, value);
|
||||
writer.end();
|
||||
return output.join("");
|
||||
}
|
||||
exports.writeJsonObject = writeJsonObject;
|
||||
Reference in New Issue
Block a user