134 lines
3.8 KiB
JavaScript
134 lines
3.8 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.Forward = exports.ForwardIterableAccess = exports.ForwardMapAccess = void 0;
|
|
const utils_1 = require("../utils");
|
|
const interface_1 = require("./interface");
|
|
class ForwardMapAccess extends interface_1.MapAccess {
|
|
constructor(keys, values) {
|
|
super();
|
|
Object.defineProperty(this, "_keys", {
|
|
enumerable: true,
|
|
configurable: true,
|
|
writable: true,
|
|
value: void 0
|
|
});
|
|
Object.defineProperty(this, "_values", {
|
|
enumerable: true,
|
|
configurable: true,
|
|
writable: true,
|
|
value: void 0
|
|
});
|
|
Object.defineProperty(this, "kindex", {
|
|
enumerable: true,
|
|
configurable: true,
|
|
writable: true,
|
|
value: 0
|
|
});
|
|
Object.defineProperty(this, "vindex", {
|
|
enumerable: true,
|
|
configurable: true,
|
|
writable: true,
|
|
value: 0
|
|
});
|
|
this._keys = keys;
|
|
this._values = values;
|
|
}
|
|
static fromObject(obj) {
|
|
return new ForwardMapAccess(Object.keys(obj), Object.values(obj));
|
|
}
|
|
nextKeySeed(_seed) {
|
|
return this.nextKey();
|
|
}
|
|
nextValueSeed(_seed) {
|
|
return this.nextValue();
|
|
}
|
|
nextKey() {
|
|
if (this.kindex < this.keys.length) {
|
|
return utils_1.IterResult.Next(this._keys[this.kindex++]);
|
|
}
|
|
else {
|
|
return utils_1.IterResult.Done();
|
|
}
|
|
}
|
|
nextValue() {
|
|
if (this.vindex < this.values.length) {
|
|
return utils_1.IterResult.Next(this._values[this.vindex++]);
|
|
}
|
|
else {
|
|
return utils_1.IterResult.Done();
|
|
}
|
|
}
|
|
}
|
|
exports.ForwardMapAccess = ForwardMapAccess;
|
|
class ForwardIterableAccess extends interface_1.IterableAccess {
|
|
constructor(items) {
|
|
super();
|
|
Object.defineProperty(this, "items", {
|
|
enumerable: true,
|
|
configurable: true,
|
|
writable: true,
|
|
value: void 0
|
|
});
|
|
Object.defineProperty(this, "index", {
|
|
enumerable: true,
|
|
configurable: true,
|
|
writable: true,
|
|
value: 0
|
|
});
|
|
this.items = items;
|
|
}
|
|
nextElement() {
|
|
if (this.index < this.items.length) {
|
|
return utils_1.IterResult.Next(this.items[this.index++]);
|
|
}
|
|
else {
|
|
return utils_1.IterResult.Done();
|
|
}
|
|
}
|
|
}
|
|
exports.ForwardIterableAccess = ForwardIterableAccess;
|
|
class Forward {
|
|
constructor(value) {
|
|
Object.defineProperty(this, "value", {
|
|
enumerable: true,
|
|
configurable: true,
|
|
writable: true,
|
|
value: void 0
|
|
});
|
|
this.value = value;
|
|
}
|
|
static with(value) {
|
|
return new this(value);
|
|
}
|
|
deserializeAny(_visitor) {
|
|
throw new Error("Can't forward to deserializeAny");
|
|
}
|
|
deserializeBoolean(visitor) {
|
|
return visitor.visitBoolean(this.value);
|
|
}
|
|
deserializeNumber(visitor) {
|
|
return visitor.visitNumber(this.value);
|
|
}
|
|
deserializeBigInt(visitor) {
|
|
return visitor.visitBigInt(this.value);
|
|
}
|
|
deserializeString(visitor) {
|
|
return visitor.visitString(this.value);
|
|
}
|
|
deserializeSymbol(visitor) {
|
|
return visitor.visitSymbol(this.value);
|
|
}
|
|
deserializeNull(visitor) {
|
|
return visitor.visitNull();
|
|
}
|
|
deserializeObject(visitor) {
|
|
return visitor.visitObject(ForwardMapAccess.fromObject(this.value));
|
|
}
|
|
deserializeIterable(visitor) {
|
|
return visitor.visitIterable(new ForwardIterableAccess(this.value));
|
|
}
|
|
deserializeFunction(_visitor) {
|
|
throw new Error('Method not implemented.');
|
|
}
|
|
}
|
|
exports.Forward = Forward;
|