UNPKG

etcd3-mock

Version:
32 lines (31 loc) 1.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Namespace = void 0; const util_1 = require("etcd3/lib/util"); const Builder = require("./builder"); const store_1 = require("./store"); const watch_1 = require("./watch"); class Namespace { constructor(prefix, store) { this.prefix = prefix; this.store = store; this.nsApplicator = new util_1.NSApplicator(this.prefix || util_1.toBuffer('')); this.store = store || new store_1.Store(); } put(key) { return new Builder.PutBuilder(this.store, key); } get(key) { return new Builder.SingleRangeBuilder(this.store, this.nsApplicator, key); } getAll() { return new Builder.MultiRangeBuilder(this.store, this.nsApplicator); } namespace(prefix) { return new Namespace(Buffer.concat([this.prefix, util_1.toBuffer(prefix)]), this.store); } watch() { return new watch_1.WatchBuilder(); } } exports.Namespace = Namespace;