morphir-elm
Version:
Elm bindings for Morphir
162 lines (161 loc) • 6.37 kB
JavaScript
;
// Generated by Morphir
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.encodeWholeNumberLiteral = exports.decodeWholeNumberLiteral = exports.WholeNumberLiteral = exports.encodeStringLiteral = exports.decodeStringLiteral = exports.StringLiteral = exports.encodeFloatLiteral = exports.decodeFloatLiteral = exports.FloatLiteral = exports.encodeDecimalLiteral = exports.decodeDecimalLiteral = exports.DecimalLiteral = exports.encodeCharLiteral = exports.decodeCharLiteral = exports.CharLiteral = exports.encodeBoolLiteral = exports.decodeBoolLiteral = exports.BoolLiteral = exports.encodeLiteral = exports.decodeLiteral = void 0;
const codecs = __importStar(require("./../../morphir/internal/codecs"));
function decodeLiteral(input) {
const kind = codecs.parseKindFromCustomTypeInput(input);
switch (kind) {
case "BoolLiteral":
return decodeBoolLiteral(input);
case "CharLiteral":
return decodeCharLiteral(input);
case "DecimalLiteral":
return decodeDecimalLiteral(input);
case "FloatLiteral":
return decodeFloatLiteral(input);
case "StringLiteral":
return decodeStringLiteral(input);
case "WholeNumberLiteral":
return decodeWholeNumberLiteral(input);
}
codecs.raiseDecodeErrorFromCustomType("Literal", kind);
}
exports.decodeLiteral = decodeLiteral;
function encodeLiteral(value) {
switch (value.kind) {
case "BoolLiteral":
return encodeBoolLiteral(value);
case "CharLiteral":
return encodeCharLiteral(value);
case "DecimalLiteral":
return encodeDecimalLiteral(value);
case "FloatLiteral":
return encodeFloatLiteral(value);
case "StringLiteral":
return encodeStringLiteral(value);
case "WholeNumberLiteral":
return encodeWholeNumberLiteral(value);
}
}
exports.encodeLiteral = encodeLiteral;
class BoolLiteral {
constructor(value) {
this.value = value;
this.kind = "BoolLiteral";
}
}
exports.BoolLiteral = BoolLiteral;
function decodeBoolLiteral(input) {
codecs.preprocessCustomTypeVariant("BoolLiteral", 1, input);
return new BoolLiteral(codecs.decodeBoolean(input[1]));
}
exports.decodeBoolLiteral = decodeBoolLiteral;
function encodeBoolLiteral(value) {
return [value.kind, codecs.encodeBoolean(value.value)];
}
exports.encodeBoolLiteral = encodeBoolLiteral;
class CharLiteral {
constructor(value) {
this.value = value;
this.kind = "CharLiteral";
}
}
exports.CharLiteral = CharLiteral;
function decodeCharLiteral(input) {
codecs.preprocessCustomTypeVariant("CharLiteral", 1, input);
return new CharLiteral(codecs.decodeChar(input[1]));
}
exports.decodeCharLiteral = decodeCharLiteral;
function encodeCharLiteral(value) {
return [value.kind, codecs.encodeChar(value.value)];
}
exports.encodeCharLiteral = encodeCharLiteral;
class DecimalLiteral {
constructor(value) {
this.value = value;
this.kind = "DecimalLiteral";
}
}
exports.DecimalLiteral = DecimalLiteral;
function decodeDecimalLiteral(input) {
codecs.preprocessCustomTypeVariant("DecimalLiteral", 1, input);
return new DecimalLiteral(codecs.decodeDecimal(input[1]));
}
exports.decodeDecimalLiteral = decodeDecimalLiteral;
function encodeDecimalLiteral(value) {
return [value.kind, codecs.encodeDecimal(value.value)];
}
exports.encodeDecimalLiteral = encodeDecimalLiteral;
class FloatLiteral {
constructor(value) {
this.value = value;
this.kind = "FloatLiteral";
}
}
exports.FloatLiteral = FloatLiteral;
function decodeFloatLiteral(input) {
codecs.preprocessCustomTypeVariant("FloatLiteral", 1, input);
return new FloatLiteral(codecs.decodeFloat(input[1]));
}
exports.decodeFloatLiteral = decodeFloatLiteral;
function encodeFloatLiteral(value) {
return [value.kind, codecs.encodeFloat(value.value)];
}
exports.encodeFloatLiteral = encodeFloatLiteral;
class StringLiteral {
constructor(value) {
this.value = value;
this.kind = "StringLiteral";
}
}
exports.StringLiteral = StringLiteral;
function decodeStringLiteral(input) {
codecs.preprocessCustomTypeVariant("StringLiteral", 1, input);
return new StringLiteral(codecs.decodeString(input[1]));
}
exports.decodeStringLiteral = decodeStringLiteral;
function encodeStringLiteral(value) {
return [value.kind, codecs.encodeString(value.value)];
}
exports.encodeStringLiteral = encodeStringLiteral;
class WholeNumberLiteral {
constructor(value) {
this.value = value;
this.kind = "WholeNumberLiteral";
}
}
exports.WholeNumberLiteral = WholeNumberLiteral;
function decodeWholeNumberLiteral(input) {
codecs.preprocessCustomTypeVariant("WholeNumberLiteral", 1, input);
return new WholeNumberLiteral(codecs.decodeInt(input[1]));
}
exports.decodeWholeNumberLiteral = decodeWholeNumberLiteral;
function encodeWholeNumberLiteral(value) {
return [value.kind, codecs.encodeInt(value.value)];
}
exports.encodeWholeNumberLiteral = encodeWholeNumberLiteral;
exports.default = {};