@bunt/util
Advanced tools
Comparing version 0.24.29 to 0.24.31
@@ -8,8 +8,2 @@ "use strict"; | ||
}; | ||
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { | ||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); | ||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); | ||
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); | ||
}; | ||
var _AsyncCallback_disposables, _AsyncCallback_pipeline, _AsyncCallback_queue; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -20,20 +14,20 @@ exports.AsyncCallback = void 0; | ||
class AsyncCallback { | ||
#disposables = []; | ||
#pipeline = []; | ||
#queue = []; | ||
constructor(link) { | ||
_AsyncCallback_disposables.set(this, []); | ||
_AsyncCallback_pipeline.set(this, []); | ||
_AsyncCallback_queue.set(this, []); | ||
__classPrivateFieldGet(this, _AsyncCallback_disposables, "f").push(this.pipe); | ||
this.#disposables.push(this.pipe); | ||
Promise.resolve(link(this.push)) | ||
.then((dispose) => { | ||
__classPrivateFieldGet(this, _AsyncCallback_disposables, "f").push(dispose); | ||
this.#disposables.push(dispose); | ||
}); | ||
} | ||
push(value) { | ||
if (__classPrivateFieldGet(this, _AsyncCallback_pipeline, "f").length) { | ||
if (this.#pipeline.length) { | ||
return this.pipe(value); | ||
} | ||
__classPrivateFieldGet(this, _AsyncCallback_queue, "f").push(value); | ||
this.#queue.push(value); | ||
} | ||
pull() { | ||
const value = __classPrivateFieldGet(this, _AsyncCallback_queue, "f").shift(); | ||
const value = this.#queue.shift(); | ||
if (value) { | ||
@@ -44,3 +38,3 @@ return Promise.resolve(value); | ||
} | ||
[(_AsyncCallback_disposables = new WeakMap(), _AsyncCallback_pipeline = new WeakMap(), _AsyncCallback_queue = new WeakMap(), Symbol.asyncIterator)]() { | ||
[Symbol.asyncIterator]() { | ||
return { | ||
@@ -66,3 +60,3 @@ next: async () => { | ||
async dispose() { | ||
const pending = __classPrivateFieldGet(this, _AsyncCallback_disposables, "f").map((fn) => Promise.resolve(fn())); | ||
const pending = this.#disposables.map((fn) => Promise.resolve(fn())); | ||
return Promise | ||
@@ -76,11 +70,11 @@ .all(pending) | ||
pipe(value) { | ||
__classPrivateFieldGet(this, _AsyncCallback_pipeline, "f").splice(0, __classPrivateFieldGet(this, _AsyncCallback_pipeline, "f").length) | ||
this.#pipeline.splice(0, this.#pipeline.length) | ||
.forEach((resolve) => resolve(value)); | ||
} | ||
sync(resolve) { | ||
const value = __classPrivateFieldGet(this, _AsyncCallback_queue, "f").shift(); | ||
const value = this.#queue.shift(); | ||
if (value) { | ||
return resolve(value); | ||
} | ||
__classPrivateFieldGet(this, _AsyncCallback_pipeline, "f").push(resolve); | ||
this.#pipeline.push(resolve); | ||
} | ||
@@ -87,0 +81,0 @@ } |
"use strict"; | ||
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { | ||
if (kind === "m") throw new TypeError("Private method is not writable"); | ||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); | ||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); | ||
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; | ||
}; | ||
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { | ||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); | ||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); | ||
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); | ||
}; | ||
var _AsyncPushPull_buffer, _AsyncPushPull_buffered, _AsyncPushPull_length, _AsyncPushPull_pending; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -18,12 +6,12 @@ exports.AsyncPushPull = void 0; | ||
class AsyncPushPull { | ||
#buffer = []; | ||
#buffered; | ||
#length; | ||
#pending = null; | ||
constructor(options = {}) { | ||
_AsyncPushPull_buffer.set(this, []); | ||
_AsyncPushPull_buffered.set(this, void 0); | ||
_AsyncPushPull_length.set(this, void 0); | ||
_AsyncPushPull_pending.set(this, null); | ||
__classPrivateFieldSet(this, _AsyncPushPull_length, options.length ?? 1000, "f"); | ||
__classPrivateFieldSet(this, _AsyncPushPull_buffered, options.buffered ?? true, "f"); | ||
this.#length = options.length ?? 1000; | ||
this.#buffered = options.buffered ?? true; | ||
} | ||
push(value) { | ||
if (__classPrivateFieldGet(this, _AsyncPushPull_pending, "f")?.settled) { | ||
if (this.#pending?.settled) { | ||
// eslint-disable-next-line | ||
@@ -33,25 +21,25 @@ console.warn(`AsyncPushPull.push failed call in destroyed state`); | ||
} | ||
if (__classPrivateFieldGet(this, _AsyncPushPull_pending, "f")) { | ||
__classPrivateFieldGet(this, _AsyncPushPull_pending, "f").resolve(value); | ||
__classPrivateFieldSet(this, _AsyncPushPull_pending, null, "f"); | ||
if (this.#pending) { | ||
this.#pending.resolve(value); | ||
this.#pending = null; | ||
return; | ||
} | ||
if (__classPrivateFieldGet(this, _AsyncPushPull_buffered, "f")) { | ||
if (__classPrivateFieldGet(this, _AsyncPushPull_buffer, "f").length > __classPrivateFieldGet(this, _AsyncPushPull_length, "f")) { | ||
if (this.#buffered) { | ||
if (this.#buffer.length > this.#length) { | ||
// eslint-disable-next-line | ||
console.warn(`AsyncPushPull.buffer reach maximum queue length, drop last one`); | ||
__classPrivateFieldGet(this, _AsyncPushPull_buffer, "f").splice(-__classPrivateFieldGet(this, _AsyncPushPull_length, "f")); | ||
this.#buffer.splice(-this.#length); | ||
} | ||
__classPrivateFieldGet(this, _AsyncPushPull_buffer, "f").push(value); | ||
this.#buffer.push(value); | ||
} | ||
} | ||
async pull() { | ||
if (__classPrivateFieldGet(this, _AsyncPushPull_buffer, "f").length) { | ||
return __classPrivateFieldGet(this, _AsyncPushPull_buffer, "f").shift(); | ||
if (this.#buffer.length) { | ||
return this.#buffer.shift(); | ||
} | ||
return __classPrivateFieldSet(this, _AsyncPushPull_pending, new _1.Defer(), "f"); | ||
return this.#pending = new _1.Defer(); | ||
} | ||
destroy() { | ||
if (__classPrivateFieldGet(this, _AsyncPushPull_pending, "f")) { | ||
__classPrivateFieldGet(this, _AsyncPushPull_pending, "f").resolve(undefined); | ||
if (this.#pending) { | ||
this.#pending.resolve(undefined); | ||
} | ||
@@ -61,3 +49,2 @@ } | ||
exports.AsyncPushPull = AsyncPushPull; | ||
_AsyncPushPull_buffer = new WeakMap(), _AsyncPushPull_buffered = new WeakMap(), _AsyncPushPull_length = new WeakMap(), _AsyncPushPull_pending = new WeakMap(); | ||
//# sourceMappingURL=AsyncPushPull.js.map |
"use strict"; | ||
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { | ||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); | ||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); | ||
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); | ||
}; | ||
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { | ||
if (kind === "m") throw new TypeError("Private method is not writable"); | ||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); | ||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); | ||
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; | ||
}; | ||
var _Defer_event, _Defer_pending, _Defer_state; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -18,34 +6,33 @@ exports.Defer = void 0; | ||
class Defer { | ||
#event = new events_1.EventEmitter(); | ||
#pending; | ||
#state = "pending"; | ||
constructor() { | ||
_Defer_event.set(this, new events_1.EventEmitter()); | ||
_Defer_pending.set(this, void 0); | ||
_Defer_state.set(this, "pending"); | ||
this.then = (onfulfilled, onrejected) => { | ||
return __classPrivateFieldGet(this, _Defer_pending, "f").then(onfulfilled, onrejected); | ||
}; | ||
this.resolve = (value) => { | ||
__classPrivateFieldGet(this, _Defer_event, "f").emit("resolve", value); | ||
}; | ||
this.reject = (error) => { | ||
__classPrivateFieldGet(this, _Defer_event, "f").emit("reject", error); | ||
}; | ||
__classPrivateFieldGet(this, _Defer_event, "f").once("resolve", () => __classPrivateFieldSet(this, _Defer_state, "fulfilled", "f")); | ||
__classPrivateFieldGet(this, _Defer_event, "f").once("reject", () => __classPrivateFieldSet(this, _Defer_state, "rejected", "f")); | ||
__classPrivateFieldSet(this, _Defer_pending, new Promise((resolve, reject) => { | ||
__classPrivateFieldGet(this, _Defer_event, "f").once("resolve", resolve); | ||
__classPrivateFieldGet(this, _Defer_event, "f").once("reject", reject); | ||
}), "f"); | ||
this.#event.once("resolve", () => this.#state = "fulfilled"); | ||
this.#event.once("reject", () => this.#state = "rejected"); | ||
this.#pending = new Promise((resolve, reject) => { | ||
this.#event.once("resolve", resolve); | ||
this.#event.once("reject", reject); | ||
}); | ||
} | ||
get settled() { | ||
return __classPrivateFieldGet(this, _Defer_state, "f") !== "pending"; | ||
return this.#state !== "pending"; | ||
} | ||
get rejected() { | ||
return this.settled && __classPrivateFieldGet(this, _Defer_state, "f") === "rejected"; | ||
return this.settled && this.#state === "rejected"; | ||
} | ||
get fulfilled() { | ||
return this.settled && __classPrivateFieldGet(this, _Defer_state, "f") === "fulfilled"; | ||
return this.settled && this.#state === "fulfilled"; | ||
} | ||
then = (onfulfilled, onrejected) => { | ||
return this.#pending.then(onfulfilled, onrejected); | ||
}; | ||
resolve = (value) => { | ||
this.#event.emit("resolve", value); | ||
}; | ||
reject = (error) => { | ||
this.#event.emit("reject", error); | ||
}; | ||
} | ||
exports.Defer = Defer; | ||
_Defer_event = new WeakMap(), _Defer_pending = new WeakMap(), _Defer_state = new WeakMap(); | ||
//# sourceMappingURL=Defer.js.map |
@@ -6,1 +6,3 @@ export declare function createAsyncTimeout(timeout: number): Promise<void>; | ||
export declare function all<P = unknown>(pending: Promise<P>[]): Promise<P[]>; | ||
export declare function toAsync<A extends any[], R>(fn: (...args: A) => R): (...args: A) => Promise<R>; | ||
export declare function asyncCall<A extends any[], R>(fn: (...args: A) => R, ...args: A): Promise<R>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.all = exports.throttle = exports.watch = exports.wait = exports.createAsyncTimeout = void 0; | ||
exports.asyncCall = exports.toAsync = exports.all = exports.throttle = exports.watch = exports.wait = exports.createAsyncTimeout = void 0; | ||
function createAsyncTimeout(timeout) { | ||
@@ -31,2 +31,12 @@ return new Promise((resolve) => setTimeout(resolve, timeout)); | ||
exports.all = all; | ||
function toAsync(fn) { | ||
return async (...args) => { | ||
return fn(...args); | ||
}; | ||
} | ||
exports.toAsync = toAsync; | ||
async function asyncCall(fn, ...args) { | ||
return fn(...args); | ||
} | ||
exports.asyncCall = asyncCall; | ||
//# sourceMappingURL=fn.js.map |
"use strict"; | ||
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { | ||
if (kind === "m") throw new TypeError("Private method is not writable"); | ||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); | ||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); | ||
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; | ||
}; | ||
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { | ||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); | ||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); | ||
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); | ||
}; | ||
var _DateTime_date; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -19,9 +7,9 @@ exports.DateTime = void 0; | ||
class DateTime { | ||
#date; | ||
constructor(date = new Date()) { | ||
_DateTime_date.set(this, void 0); | ||
__classPrivateFieldSet(this, _DateTime_date, new Date(date), "f"); | ||
(0, assert_1.assert)(__classPrivateFieldGet(this, _DateTime_date, "f").getTime() > 0); | ||
this.#date = new Date(date); | ||
(0, assert_1.assert)(this.#date.getTime() > 0); | ||
} | ||
get date() { | ||
return new Date(__classPrivateFieldGet(this, _DateTime_date, "f")); | ||
return new Date(this.#date); | ||
} | ||
@@ -32,3 +20,3 @@ static from(date = new Date()) { | ||
getTime() { | ||
return __classPrivateFieldGet(this, _DateTime_date, "f").getTime(); | ||
return this.#date.getTime(); | ||
} | ||
@@ -55,3 +43,2 @@ getDate() { | ||
exports.DateTime = DateTime; | ||
_DateTime_date = new WeakMap(); | ||
//# sourceMappingURL=DateTime.js.map |
@@ -7,2 +7,3 @@ "use strict"; | ||
class AssertionError extends ValidationError_1.ValidationError { | ||
details; | ||
constructor(message, details) { | ||
@@ -9,0 +10,0 @@ super(message || "Assertion fails"); |
"use strict"; | ||
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { | ||
if (kind === "m") throw new TypeError("Private method is not writable"); | ||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); | ||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); | ||
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; | ||
}; | ||
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { | ||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); | ||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); | ||
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); | ||
}; | ||
var _Logger_label; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -31,13 +19,15 @@ exports.Logger = void 0; | ||
class Logger { | ||
static severity = interfaces_1.SeverityLevel.INFO; | ||
static emergency = Logger.make(interfaces_1.SeverityLevel.EMERGENCY); | ||
static alert = Logger.make(interfaces_1.SeverityLevel.ALERT); | ||
static critical = Logger.make(interfaces_1.SeverityLevel.CRITICAL); | ||
static error = Logger.make(interfaces_1.SeverityLevel.ERROR); | ||
static warning = Logger.make(interfaces_1.SeverityLevel.WARNING); | ||
static notice = Logger.make(interfaces_1.SeverityLevel.NOTICE); | ||
static info = Logger.make(interfaces_1.SeverityLevel.INFO); | ||
static debug = Logger.make(interfaces_1.SeverityLevel.DEBUG); | ||
groupId; | ||
#label; | ||
constructor(label, groupId) { | ||
_Logger_label.set(this, void 0); | ||
this.emergency = (...args) => Logger.emergency(this, ...args); | ||
this.alert = (...args) => Logger.alert(this, ...args); | ||
this.critical = (...args) => Logger.critical(this, ...args); | ||
this.error = (...args) => Logger.error(this, ...args); | ||
this.warning = (...args) => Logger.warning(this, ...args); | ||
this.notice = (...args) => Logger.notice(this, ...args); | ||
this.info = (...args) => Logger.info(this, ...args); | ||
this.debug = (...args) => Logger.debug(this, ...args); | ||
__classPrivateFieldSet(this, _Logger_label, label, "f"); | ||
this.#label = label; | ||
this.groupId = (0, is_1.isNumber)(groupId) | ||
@@ -48,3 +38,3 @@ ? groupId.toString() | ||
get label() { | ||
return __classPrivateFieldGet(this, _Logger_label, "f"); | ||
return this.#label; | ||
} | ||
@@ -165,3 +155,3 @@ get severity() { | ||
setLabel(label) { | ||
__classPrivateFieldSet(this, _Logger_label, label, "f"); | ||
this.#label = label; | ||
} | ||
@@ -190,3 +180,3 @@ static async dispose() { | ||
} | ||
const perf = new Perf_1.Perf(__classPrivateFieldGet(this, _Logger_label, "f")); | ||
const perf = new Perf_1.Perf(this.#label); | ||
return () => { | ||
@@ -197,14 +187,12 @@ perf.finish(); | ||
} | ||
emergency = (...args) => Logger.emergency(this, ...args); | ||
alert = (...args) => Logger.alert(this, ...args); | ||
critical = (...args) => Logger.critical(this, ...args); | ||
error = (...args) => Logger.error(this, ...args); | ||
warning = (...args) => Logger.warning(this, ...args); | ||
notice = (...args) => Logger.notice(this, ...args); | ||
info = (...args) => Logger.info(this, ...args); | ||
debug = (...args) => Logger.debug(this, ...args); | ||
} | ||
exports.Logger = Logger; | ||
_Logger_label = new WeakMap(); | ||
Logger.severity = interfaces_1.SeverityLevel.INFO; | ||
Logger.emergency = Logger.make(interfaces_1.SeverityLevel.EMERGENCY); | ||
Logger.alert = Logger.make(interfaces_1.SeverityLevel.ALERT); | ||
Logger.critical = Logger.make(interfaces_1.SeverityLevel.CRITICAL); | ||
Logger.error = Logger.make(interfaces_1.SeverityLevel.ERROR); | ||
Logger.warning = Logger.make(interfaces_1.SeverityLevel.WARNING); | ||
Logger.notice = Logger.make(interfaces_1.SeverityLevel.NOTICE); | ||
Logger.info = Logger.make(interfaces_1.SeverityLevel.INFO); | ||
Logger.debug = Logger.make(interfaces_1.SeverityLevel.DEBUG); | ||
//# sourceMappingURL=Logger.js.map |
"use strict"; | ||
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { | ||
if (kind === "m") throw new TypeError("Private method is not writable"); | ||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); | ||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); | ||
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; | ||
}; | ||
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { | ||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); | ||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); | ||
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); | ||
}; | ||
var _InOutTransportAbstract_format; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.InOutTransportAbstract = void 0; | ||
class InOutTransportAbstract { | ||
#format; | ||
constructor(formatter) { | ||
_InOutTransportAbstract_format.set(this, void 0); | ||
__classPrivateFieldSet(this, _InOutTransportAbstract_format, formatter, "f"); | ||
this.#format = formatter; | ||
} | ||
@@ -26,3 +14,3 @@ get writable() { | ||
if (this.test(log)) { | ||
this.stream.write(__classPrivateFieldGet(this, _InOutTransportAbstract_format, "f").call(this, log)); | ||
this.stream.write(this.#format(log)); | ||
} | ||
@@ -32,3 +20,2 @@ } | ||
exports.InOutTransportAbstract = InOutTransportAbstract; | ||
_InOutTransportAbstract_format = new WeakMap(); | ||
//# sourceMappingURL=InOutTransportAbstract.js.map |
"use strict"; | ||
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { | ||
if (kind === "m") throw new TypeError("Private method is not writable"); | ||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); | ||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); | ||
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; | ||
}; | ||
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { | ||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); | ||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); | ||
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); | ||
}; | ||
var _XMap_initializer; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -19,13 +7,13 @@ exports.XMap = void 0; | ||
class XMap extends Map { | ||
#initializer; | ||
constructor(...args) { | ||
super(); | ||
_XMap_initializer.set(this, void 0); | ||
const [valuesOr, initializer] = args; | ||
__classPrivateFieldSet(this, _XMap_initializer, initializer, "f"); | ||
this.#initializer = initializer; | ||
if ((0, is_1.isArray)(valuesOr)) { | ||
valuesOr.forEach(([key, value]) => this.set(key, value)); | ||
__classPrivateFieldSet(this, _XMap_initializer, initializer, "f"); | ||
this.#initializer = initializer; | ||
} | ||
if ((0, is_1.isFunction)(valuesOr)) { | ||
__classPrivateFieldSet(this, _XMap_initializer, valuesOr, "f"); | ||
this.#initializer = valuesOr; | ||
} | ||
@@ -39,3 +27,3 @@ } | ||
} | ||
ensure(key, initializer = __classPrivateFieldGet(this, _XMap_initializer, "f")) { | ||
ensure(key, initializer = this.#initializer) { | ||
const exists = this.has(key); | ||
@@ -57,3 +45,2 @@ if (!exists && (0, is_1.isFunction)(initializer)) { | ||
exports.XMap = XMap; | ||
_XMap_initializer = new WeakMap(); | ||
//# sourceMappingURL=XMap.js.map |
@@ -11,2 +11,5 @@ "use strict"; | ||
class Argv { | ||
args; | ||
options; | ||
flags; | ||
constructor(input) { | ||
@@ -13,0 +16,0 @@ const { flags, args, options } = this.parse(input); |
"use strict"; | ||
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { | ||
if (kind === "m") throw new TypeError("Private method is not writable"); | ||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); | ||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); | ||
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; | ||
}; | ||
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { | ||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); | ||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); | ||
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); | ||
}; | ||
var _Env_store; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -18,5 +6,5 @@ exports.Env = void 0; | ||
class Env { | ||
#store; | ||
constructor(env) { | ||
_Env_store.set(this, void 0); | ||
__classPrivateFieldSet(this, _Env_store, new Map(Object.entries(env)), "f"); | ||
this.#store = new Map(Object.entries(env)); | ||
} | ||
@@ -27,3 +15,3 @@ static factory(env = process.env) { | ||
get(key, defaultValue) { | ||
return __classPrivateFieldGet(this, _Env_store, "f").get(key) ?? defaultValue; | ||
return this.#store.get(key) ?? defaultValue; | ||
} | ||
@@ -38,3 +26,3 @@ ensure(key, fn) { | ||
set(key, override) { | ||
__classPrivateFieldGet(this, _Env_store, "f").set(key, override); | ||
this.#store.set(key, override); | ||
return this; | ||
@@ -50,3 +38,2 @@ } | ||
exports.Env = Env; | ||
_Env_store = new WeakMap(); | ||
//# sourceMappingURL=Env.js.map |
@@ -6,2 +6,3 @@ "use strict"; | ||
class Program { | ||
args; | ||
constructor(argv) { | ||
@@ -8,0 +9,0 @@ this.args = new Argv_1.Argv(argv || process.argv.slice(2)); |
"use strict"; | ||
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { | ||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); | ||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); | ||
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); | ||
}; | ||
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { | ||
if (kind === "m") throw new TypeError("Private method is not writable"); | ||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); | ||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); | ||
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; | ||
}; | ||
var _Perf_finish; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -19,5 +7,6 @@ exports.Perf = void 0; | ||
class Perf { | ||
label; | ||
start = perf_hooks_1.performance.now(); | ||
#finish = 0; | ||
constructor(...labels) { | ||
this.start = perf_hooks_1.performance.now(); | ||
_Perf_finish.set(this, 0); | ||
this.label = labels.map((label) => (0, is_1.isString)(label) ? label : label.constructor.name) | ||
@@ -27,3 +16,3 @@ .join(" -> "); | ||
get time() { | ||
return __classPrivateFieldGet(this, _Perf_finish, "f") > 0 ? __classPrivateFieldGet(this, _Perf_finish, "f") - this.start : -1; | ||
return this.#finish > 0 ? this.#finish - this.start : -1; | ||
} | ||
@@ -34,3 +23,3 @@ static make(label) { | ||
finish() { | ||
__classPrivateFieldSet(this, _Perf_finish, perf_hooks_1.performance.now(), "f"); | ||
this.#finish = perf_hooks_1.performance.now(); | ||
return this; | ||
@@ -42,3 +31,3 @@ } | ||
start: this.start, | ||
finish: __classPrivateFieldGet(this, _Perf_finish, "f"), | ||
finish: this.#finish, | ||
time: this.time, | ||
@@ -49,3 +38,2 @@ }; | ||
exports.Perf = Perf; | ||
_Perf_finish = new WeakMap(); | ||
//# sourceMappingURL=Perf.js.map |
"use strict"; | ||
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { | ||
if (kind === "m") throw new TypeError("Private method is not writable"); | ||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); | ||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); | ||
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; | ||
}; | ||
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { | ||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); | ||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); | ||
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); | ||
}; | ||
var _SingleRef_ref; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -19,11 +7,11 @@ exports.SingleRef = void 0; | ||
class SingleRef { | ||
#ref; | ||
constructor(ref = {}) { | ||
_SingleRef_ref.set(this, void 0); | ||
__classPrivateFieldSet(this, _SingleRef_ref, ref, "f"); | ||
this.#ref = ref; | ||
} | ||
has() { | ||
return store.has(__classPrivateFieldGet(this, _SingleRef_ref, "f")); | ||
return store.has(this.#ref); | ||
} | ||
get() { | ||
return store.get(__classPrivateFieldGet(this, _SingleRef_ref, "f")); | ||
return store.get(this.#ref); | ||
} | ||
@@ -40,5 +28,5 @@ ensure() { | ||
create(fn) { | ||
const value = store.get(__classPrivateFieldGet(this, _SingleRef_ref, "f")) ?? fn(); | ||
const value = store.get(this.#ref) ?? fn(); | ||
if (!this.has()) { | ||
store.set(__classPrivateFieldGet(this, _SingleRef_ref, "f"), value); | ||
store.set(this.#ref, value); | ||
} | ||
@@ -49,3 +37,2 @@ return value; | ||
exports.SingleRef = SingleRef; | ||
_SingleRef_ref = new WeakMap(); | ||
//# sourceMappingURL=SingleRef.js.map |
{ | ||
"name": "@bunt/util", | ||
"version": "0.24.29", | ||
"version": "0.24.31", | ||
"keywords": [ | ||
@@ -29,3 +29,3 @@ "typescript" | ||
"license": "MIT", | ||
"gitHead": "13acf27e20c7af9a3a8bdf8c7a41411ddcfc9260" | ||
"gitHead": "180701f52e6625a339988ed667e9de2c1e07dfea" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
135501
2172