54 lines
1.6 KiB
JavaScript
54 lines
1.6 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.IterableAccess = exports.MapAccess = void 0;
|
|
const utils_1 = require("../utils");
|
|
class MapAccess {
|
|
nextEntrySeed(kseed, vseed) {
|
|
const key = this.nextKeySeed(kseed);
|
|
if (!key.done) {
|
|
const value = this.nextValueSeed(vseed);
|
|
if (!value.done) {
|
|
return utils_1.IterResult.Next([key.value, value.value]);
|
|
}
|
|
}
|
|
return utils_1.IterResult.Done();
|
|
}
|
|
nextEntry() {
|
|
const key = this.nextKey();
|
|
if (!key.done) {
|
|
const value = this.nextValue();
|
|
if (!value.done) {
|
|
return utils_1.IterResult.Next([key.value, value.value]);
|
|
}
|
|
}
|
|
return utils_1.IterResult.Done();
|
|
}
|
|
*generate(next) {
|
|
let item;
|
|
while ((item = next())) {
|
|
yield item.value;
|
|
}
|
|
}
|
|
keys(seed) {
|
|
return this.generate(seed == null ?
|
|
this.nextKey.bind(this) :
|
|
this.nextKeySeed.bind(this, seed));
|
|
}
|
|
values(seed) {
|
|
return this.generate(seed == null ?
|
|
this.nextValue.bind(this) :
|
|
this.nextValueSeed.bind(this, seed));
|
|
}
|
|
entries(kseed, vseed) {
|
|
return this.generate(kseed == null || vseed == null ?
|
|
this.nextEntry.bind(this) :
|
|
this.nextEntrySeed.bind(this, kseed, vseed));
|
|
}
|
|
[Symbol.iterator]() {
|
|
return this.entries();
|
|
}
|
|
}
|
|
exports.MapAccess = MapAccess;
|
|
class IterableAccess {
|
|
}
|
|
exports.IterableAccess = IterableAccess;
|