@bunt/util
Advanced tools
Comparing version 0.29.13 to 0.29.14
@@ -1,4 +0,4 @@ | ||
import { DecoratorTarget } from "./interfaces.js"; | ||
import { DecoratorTarget } from "@bunt/type"; | ||
export declare function memoize(target: DecoratorTarget, key: string): PropertyDescriptor; | ||
export declare function bind<T extends (...args: any[]) => any>(target: Record<any, any>, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void; | ||
//# sourceMappingURL=decorator.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.bind = exports.memoize = void 0; | ||
const assert_js_1 = require("./assert.js"); | ||
const is_js_1 = require("./is.js"); | ||
const assert_1 = require("@bunt/assert"); | ||
const is_1 = require("@bunt/is"); | ||
function memoize(target, key) { | ||
const descriptor = Reflect.getOwnPropertyDescriptor(target, key); | ||
(0, assert_js_1.assert)(!(0, is_js_1.isUndefined)(descriptor)); | ||
(0, assert_js_1.assert)((0, is_js_1.isFunction)(descriptor.value) || (0, is_js_1.isFunction)(descriptor.get), "Memoization should be apply only to methods"); | ||
(0, assert_1.assert)(!(0, is_1.isUndefined)(descriptor)); | ||
(0, assert_1.assert)((0, is_1.isFunction)(descriptor.value) || (0, is_1.isFunction)(descriptor.get), "Memoization should be apply only to methods"); | ||
const memoizeCache = new WeakMap(); | ||
@@ -11,0 +11,0 @@ if (descriptor.value) { |
@@ -1,2 +0,2 @@ | ||
import { Promisify } from "./interfaces.js"; | ||
import { Promisify } from "@bunt/type"; | ||
export declare const noop: (..._args: any[]) => void; | ||
@@ -3,0 +3,0 @@ export declare function not<A extends any[]>(fn: (...args: A) => boolean): (...args: A) => boolean; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.safeMap = exports.voidify = exports.toArray = exports.makeSafe = exports.curry = exports.not = exports.noop = void 0; | ||
const is_js_1 = require("./is.js"); | ||
const fn_js_1 = require("./Async/fn.js"); | ||
const async_1 = require("@bunt/async"); | ||
const is_1 = require("@bunt/is"); | ||
const noop = (..._args) => void 0; | ||
@@ -32,3 +32,3 @@ exports.noop = noop; | ||
function toArray(value) { | ||
if ((0, is_js_1.isArray)(value)) { | ||
if ((0, is_1.isArray)(value)) { | ||
return value; | ||
@@ -53,5 +53,5 @@ } | ||
} | ||
return (0, fn_js_1.all)(result); | ||
return (0, async_1.all)(result); | ||
} | ||
exports.safeMap = safeMap; | ||
//# sourceMappingURL=function.js.map |
@@ -1,4 +0,6 @@ | ||
export * from "./is.js"; | ||
export * from "@bunt/is"; | ||
export * from "@bunt/assert"; | ||
export * from "@bunt/type"; | ||
export * from "@bunt/async"; | ||
export * from "./stream.js"; | ||
export * from "./assert.js"; | ||
export * from "./object.js"; | ||
@@ -11,10 +13,7 @@ export * from "./string.js"; | ||
export * from "./Logger/index.js"; | ||
export * from "./Exception/index.js"; | ||
export * from "./Node/index.js"; | ||
export * from "./Perf/index.js"; | ||
export * from "./Async/index.js"; | ||
export * from "./Ref/index.js"; | ||
export * from "./Map/index.js"; | ||
export * from "./interfaces.js"; | ||
export * from "./qs.js"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -17,5 +17,7 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./is.js"), exports); | ||
__exportStar(require("@bunt/is"), exports); | ||
__exportStar(require("@bunt/assert"), exports); | ||
__exportStar(require("@bunt/type"), exports); | ||
__exportStar(require("@bunt/async"), exports); | ||
__exportStar(require("./stream.js"), exports); | ||
__exportStar(require("./assert.js"), exports); | ||
__exportStar(require("./object.js"), exports); | ||
@@ -28,10 +30,7 @@ __exportStar(require("./string.js"), exports); | ||
__exportStar(require("./Logger/index.js"), exports); | ||
__exportStar(require("./Exception/index.js"), exports); | ||
__exportStar(require("./Node/index.js"), exports); | ||
__exportStar(require("./Perf/index.js"), exports); | ||
__exportStar(require("./Async/index.js"), exports); | ||
__exportStar(require("./Ref/index.js"), exports); | ||
__exportStar(require("./Map/index.js"), exports); | ||
__exportStar(require("./interfaces.js"), exports); | ||
__exportStar(require("./qs.js"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,3 @@ | ||
import { ILogable, ILogger, Logable, LoggerOwner } from "./interfaces.js"; | ||
import { ILogable, Logable } from "@bunt/type"; | ||
import { ILogger, LoggerOwner } from "./interfaces.js"; | ||
export declare function isLoggerOwner(target: LoggerOwner): target is ILogger; | ||
@@ -3,0 +4,0 @@ export declare function isLogable(target: Logable): target is ILogable<any>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.logger = exports.isLogable = exports.isLoggerOwner = void 0; | ||
const is_js_1 = require("../is.js"); | ||
const is_1 = require("@bunt/is"); | ||
const Logger_js_1 = require("./Logger.js"); | ||
@@ -11,3 +11,3 @@ function isLoggerOwner(target) { | ||
function isLogable(target) { | ||
return (0, is_js_1.isObject)(target) && "getLogValue" in target; | ||
return (0, is_1.isObject)(target) && "getLogValue" in target; | ||
} | ||
@@ -14,0 +14,0 @@ exports.isLogable = isLogable; |
@@ -1,2 +0,2 @@ | ||
import { Func, Promisify } from "../interfaces.js"; | ||
import { Func, Logable, LogableType, Promisify } from "@bunt/type"; | ||
import { Logger } from "./Logger.js"; | ||
@@ -24,7 +24,2 @@ export declare enum SeverityLevel { | ||
export type LoggerOwner = Record<any, any> | ILogger | Func; | ||
export type LogableType = string | Record<any, any> | number | bigint | null | undefined | boolean | Date | unknown; | ||
export interface ILogable<T extends LogableType> { | ||
getLogValue(): T; | ||
} | ||
export type Logable = ILogable<LogableType> | LogableType | Logable[]; | ||
export type LogFn = (message: string, ...args: Logable[]) => void; | ||
@@ -31,0 +26,0 @@ export type LogWrapFn = (logger: Logger, message: string, ...args: LogableType[]) => void; |
@@ -1,2 +0,3 @@ | ||
import { ILogger, ILoggerTransport, Logable, LogableType, LogFn, LoggerOwner, LogWrapFn, SeverityLevel } from "./interfaces.js"; | ||
import { Logable, LogableType } from "@bunt/type"; | ||
import { ILogger, ILoggerTransport, LogFn, LoggerOwner, LogWrapFn, SeverityLevel } from "./interfaces.js"; | ||
export declare class Logger { | ||
@@ -3,0 +4,0 @@ #private; |
@@ -6,4 +6,4 @@ "use strict"; | ||
const util_1 = require("util"); | ||
const assert_js_1 = require("../assert.js"); | ||
const is_js_1 = require("../is.js"); | ||
const is_1 = require("@bunt/is"); | ||
const assert_1 = require("@bunt/assert"); | ||
const index_js_1 = require("../Perf/index.js"); | ||
@@ -33,3 +33,3 @@ const function_js_1 = require("../function.js"); | ||
this.#label = label; | ||
this.groupId = (0, is_js_1.isNumber)(groupId) | ||
this.groupId = (0, is_1.isNumber)(groupId) | ||
? groupId.toString() | ||
@@ -81,3 +81,3 @@ : groupId; | ||
static createLogger(target) { | ||
const label = (0, is_js_1.isFunction)(target) ? target.name : target.constructor.name; | ||
const label = (0, is_1.isFunction)(target) ? target.name : target.constructor.name; | ||
if ((0, functions_js_1.isLoggerOwner)(target)) { | ||
@@ -96,3 +96,3 @@ const logger = new this(target.getLogLabel?.() ?? label, target.getLogGroupId?.()); | ||
const matched = [...message.match(placeholderRegex) ?? []]; | ||
(0, assert_js_1.assert)(matched.length <= args.length, "Logger.format(message, ...args): args count less than placeholders"); | ||
(0, assert_1.assert)(matched.length <= args.length, "Logger.format(message, ...args): args count less than placeholders"); | ||
return { | ||
@@ -126,7 +126,7 @@ message: (0, util_1.format)(message, ...args.slice(0, matched.length)), | ||
for (const arg of args) { | ||
if ((0, is_js_1.isInstanceOf)(arg, Error)) { | ||
if ((0, is_1.isInstanceOf)(arg, Error)) { | ||
const error = { message: arg.message, stack: arg.stack }; | ||
if ((0, functions_js_1.isLogable)(arg)) { | ||
const logValue = arg.getLogValue(); | ||
if ((0, is_js_1.isDefined)(logValue)) { | ||
if ((0, is_1.isDefined)(logValue)) { | ||
error.extra = arg.getLogValue(); | ||
@@ -173,3 +173,3 @@ } | ||
add(child) { | ||
if (child.logger === this || (0, is_js_1.isDefined)(child.logger.groupId) || (0, is_js_1.isUndefined)(this.groupId)) { | ||
if (child.logger === this || (0, is_1.isDefined)(child.logger.groupId) || (0, is_1.isUndefined)(this.groupId)) { | ||
return; | ||
@@ -176,0 +176,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.debugLogFormat = exports.readableJSONLogFormat = exports.defaultLogFormat = void 0; | ||
const is_js_1 = require("../../is.js"); | ||
const is_1 = require("@bunt/is"); | ||
const interfaces_js_1 = require("../interfaces.js"); | ||
@@ -24,6 +24,6 @@ const defaultLogFormat = (log) => { | ||
]; | ||
const debug = [info.filter(is_js_1.isDefined).join(" "), message]; | ||
(0, is_js_1.isDefined)(system) && debug.push(JSON.stringify(system, null, 2)); | ||
(0, is_js_1.isDefined)(args) && debug.push(...args.map((arg) => { | ||
if ((0, is_js_1.isString)(arg)) { | ||
const debug = [info.filter(is_1.isDefined).join(" "), message]; | ||
(0, is_1.isDefined)(system) && debug.push(JSON.stringify(system, null, 2)); | ||
(0, is_1.isDefined)(args) && debug.push(...args.map((arg) => { | ||
if ((0, is_1.isString)(arg)) { | ||
return arg; | ||
@@ -30,0 +30,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { Promisify } from "../../interfaces.js"; | ||
import { Promisify } from "@bunt/type"; | ||
import { ILoggerTransport, LogFormat, LogMessage } from "../interfaces.js"; | ||
@@ -3,0 +3,0 @@ export interface ILoggerStreamCallback<T> { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.XMap = void 0; | ||
const assert_js_1 = require("../assert.js"); | ||
const is_js_1 = require("../is.js"); | ||
const assert_1 = require("@bunt/assert"); | ||
const is_1 = require("@bunt/is"); | ||
class XMap extends Map { | ||
@@ -12,7 +12,7 @@ #initializer; | ||
this.#initializer = initializer; | ||
if ((0, is_js_1.isArray)(valuesOr)) { | ||
if ((0, is_1.isArray)(valuesOr)) { | ||
valuesOr.forEach(([key, value]) => this.set(key, value)); | ||
this.#initializer = initializer; | ||
} | ||
if ((0, is_js_1.isFunction)(valuesOr)) { | ||
if ((0, is_1.isFunction)(valuesOr)) { | ||
this.#initializer = valuesOr; | ||
@@ -29,3 +29,3 @@ } | ||
const exists = this.has(key); | ||
if (!exists && (0, is_js_1.isFunction)(initializer)) { | ||
if (!exists && (0, is_1.isFunction)(initializer)) { | ||
const value = initializer(key); | ||
@@ -35,3 +35,3 @@ this.set(key, value); | ||
} | ||
(0, assert_js_1.assert)(exists, `The key doesn't exists: ${key}`); | ||
(0, assert_1.assert)(exists, `The key doesn't exists: ${key}`); | ||
return this.get(key); | ||
@@ -38,0 +38,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Argv = void 0; | ||
const assert_js_1 = require("../assert.js"); | ||
const is_js_1 = require("../is.js"); | ||
const is_1 = require("@bunt/is"); | ||
const assert_1 = require("@bunt/assert"); | ||
const object_js_1 = require("../object.js"); | ||
@@ -34,3 +34,3 @@ const OPTION_REGEX = /^--([a-z0-9_-]+)=(.+)$/i; | ||
const value = this.options.get(name); | ||
if ((0, is_js_1.isDefined)(value) && (0, is_js_1.isNumber)(defaultValue)) { | ||
if ((0, is_1.isDefined)(value) && (0, is_1.isNumber)(defaultValue)) { | ||
return parseInt(value, 10); | ||
@@ -70,3 +70,3 @@ } | ||
const res = value.match(re); | ||
(0, assert_js_1.assert)(res && res[index]); | ||
(0, assert_1.assert)(res && res[index]); | ||
return res[index]; | ||
@@ -73,0 +73,0 @@ } |
/// <reference types="node" /> | ||
import { KeyOf } from "../interfaces.js"; | ||
import { KeyOf } from "@bunt/type"; | ||
import { Dict } from "./interfaces.js"; | ||
@@ -4,0 +4,0 @@ export type EnvValue = string | undefined; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Env = void 0; | ||
const assert_js_1 = require("../assert.js"); | ||
const assert_1 = require("@bunt/assert"); | ||
class Env { | ||
@@ -18,3 +18,3 @@ #store; | ||
const value = this.get(key); | ||
(0, assert_js_1.assert)(value, `The key doesn't exists: ${key}`); | ||
(0, assert_1.assert)(value, `The key doesn't exists: ${key}`); | ||
return fn | ||
@@ -21,0 +21,0 @@ ? fn(value) |
@@ -1,2 +0,2 @@ | ||
import { DecoratorTarget } from "./interfaces.js"; | ||
import { DecoratorTarget } from "@bunt/type"; | ||
export declare const freeze: <S extends { | ||
@@ -3,0 +3,0 @@ [key: string]: any; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getClassName = exports.entriesReverse = exports.freeze = void 0; | ||
const is_js_1 = require("./is.js"); | ||
const is_1 = require("@bunt/is"); | ||
const freeze = (source) => { | ||
@@ -9,3 +9,3 @@ const target = Object.freeze(Object.assign(Object.create(null), source)); | ||
// @check for plain object | ||
if ((0, is_js_1.isObject)(value)) { | ||
if ((0, is_1.isObject)(value)) { | ||
target[key] = (0, exports.freeze)(target[key]); | ||
@@ -12,0 +12,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { ILogable } from "../Logger/index.js"; | ||
import { ILogable } from "@bunt/type"; | ||
import { IPerfValue, PerfLabel } from "./interfaces.js"; | ||
@@ -3,0 +3,0 @@ export declare class Perf implements ILogable<IPerfValue> { |
@@ -5,3 +5,3 @@ "use strict"; | ||
const perf_hooks_1 = require("perf_hooks"); | ||
const is_js_1 = require("../is.js"); | ||
const is_1 = require("@bunt/is"); | ||
class Perf { | ||
@@ -12,3 +12,3 @@ label; | ||
constructor(...labels) { | ||
this.label = labels.map((label) => (0, is_js_1.isString)(label) ? label : label.constructor.name) | ||
this.label = labels.map((label) => (0, is_1.isString)(label) ? label : label.constructor.name) | ||
.join(" -> "); | ||
@@ -15,0 +15,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SingleRef = void 0; | ||
const assert_js_1 = require("../assert.js"); | ||
const assert_1 = require("@bunt/assert"); | ||
const store = new WeakMap(); | ||
@@ -19,7 +19,7 @@ class SingleRef { | ||
const ref = this.get(); | ||
(0, assert_js_1.assert)(ref, "Unknown reference"); | ||
(0, assert_1.assert)(ref, "Unknown reference"); | ||
return ref; | ||
} | ||
once(fn) { | ||
(0, assert_js_1.assert)(!this.has(), "Cannot getting twice"); | ||
(0, assert_1.assert)(!this.has(), "Cannot getting twice"); | ||
return this.create(fn); | ||
@@ -26,0 +26,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isTransformStream = exports.isDuplexStream = exports.isWritableStream = exports.isReadableStream = exports.isStream = void 0; | ||
const is_js_1 = require("./is.js"); | ||
const is_1 = require("@bunt/is"); | ||
const isStream = (stream) => (stream !== null && | ||
(0, is_js_1.isObject)(stream) && | ||
(0, is_1.isObject)(stream) && | ||
typeof stream.pipe === "function"); | ||
@@ -8,0 +8,0 @@ exports.isStream = isStream; |
@@ -1,2 +0,2 @@ | ||
import { Promisify } from "../interfaces.js"; | ||
import { Promisify } from "@bunt/type"; | ||
export type TypeToJSON<T> = T extends Date ? string | number : any; | ||
@@ -3,0 +3,0 @@ export type TransformFunction<T> = (value: TypeToJSON<T>) => Promisify<T>; |
@@ -1,2 +0,2 @@ | ||
import { Promisify } from "../interfaces.js"; | ||
import { Promisify } from "@bunt/type"; | ||
import { JSONInput, Transformable, TransformOut, TransformSchema } from "./interfaces.js"; | ||
@@ -3,0 +3,0 @@ export declare class TransformInput { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TransformInput = void 0; | ||
const is_js_1 = require("../is.js"); | ||
const is_1 = require("@bunt/is"); | ||
class TransformInput { | ||
static async transform(data, schema) { | ||
if ((0, is_js_1.isArray)(data)) { | ||
if ((0, is_1.isArray)(data)) { | ||
return Promise.all(data.map((item) => this.transform(item, schema))); | ||
@@ -15,7 +15,7 @@ } | ||
const sourceValue = Reflect.get(data, property); | ||
if ((0, is_js_1.isFunction)(transform)) { | ||
if ((0, is_1.isFunction)(transform)) { | ||
Reflect.set(data, property, await transform(sourceValue)); | ||
continue; | ||
} | ||
if ((0, is_js_1.isObject)(transform)) { | ||
if ((0, is_1.isObject)(transform)) { | ||
await this.transform(sourceValue, transform); | ||
@@ -22,0 +22,0 @@ } |
@@ -1,4 +0,4 @@ | ||
import { DecoratorTarget } from "./interfaces.js"; | ||
import { DecoratorTarget } from "@bunt/type"; | ||
export declare function memoize(target: DecoratorTarget, key: string): PropertyDescriptor; | ||
export declare function bind<T extends (...args: any[]) => any>(target: Record<any, any>, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void; | ||
//# sourceMappingURL=decorator.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.bind = exports.memoize = void 0; | ||
const assert_js_1 = require("./assert.js"); | ||
const is_js_1 = require("./is.js"); | ||
const assert_1 = require("@bunt/assert"); | ||
const is_1 = require("@bunt/is"); | ||
function memoize(target, key) { | ||
const descriptor = Reflect.getOwnPropertyDescriptor(target, key); | ||
(0, assert_js_1.assert)(!(0, is_js_1.isUndefined)(descriptor)); | ||
(0, assert_js_1.assert)((0, is_js_1.isFunction)(descriptor.value) || (0, is_js_1.isFunction)(descriptor.get), "Memoization should be apply only to methods"); | ||
(0, assert_1.assert)(!(0, is_1.isUndefined)(descriptor)); | ||
(0, assert_1.assert)((0, is_1.isFunction)(descriptor.value) || (0, is_1.isFunction)(descriptor.get), "Memoization should be apply only to methods"); | ||
const memoizeCache = new WeakMap(); | ||
@@ -11,0 +11,0 @@ if (descriptor.value) { |
@@ -1,2 +0,2 @@ | ||
import { Promisify } from "./interfaces.js"; | ||
import { Promisify } from "@bunt/type"; | ||
export declare const noop: (..._args: any[]) => void; | ||
@@ -3,0 +3,0 @@ export declare function not<A extends any[]>(fn: (...args: A) => boolean): (...args: A) => boolean; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.safeMap = exports.voidify = exports.toArray = exports.makeSafe = exports.curry = exports.not = exports.noop = void 0; | ||
const is_js_1 = require("./is.js"); | ||
const fn_js_1 = require("./Async/fn.js"); | ||
const async_1 = require("@bunt/async"); | ||
const is_1 = require("@bunt/is"); | ||
const noop = (..._args) => void 0; | ||
@@ -32,3 +32,3 @@ exports.noop = noop; | ||
function toArray(value) { | ||
if ((0, is_js_1.isArray)(value)) { | ||
if ((0, is_1.isArray)(value)) { | ||
return value; | ||
@@ -53,5 +53,5 @@ } | ||
} | ||
return (0, fn_js_1.all)(result); | ||
return (0, async_1.all)(result); | ||
} | ||
exports.safeMap = safeMap; | ||
//# sourceMappingURL=function.js.map |
@@ -1,4 +0,6 @@ | ||
export * from "./is.js"; | ||
export * from "@bunt/is"; | ||
export * from "@bunt/assert"; | ||
export * from "@bunt/type"; | ||
export * from "@bunt/async"; | ||
export * from "./stream.js"; | ||
export * from "./assert.js"; | ||
export * from "./object.js"; | ||
@@ -11,10 +13,7 @@ export * from "./string.js"; | ||
export * from "./Logger/index.js"; | ||
export * from "./Exception/index.js"; | ||
export * from "./Node/index.js"; | ||
export * from "./Perf/index.js"; | ||
export * from "./Async/index.js"; | ||
export * from "./Ref/index.js"; | ||
export * from "./Map/index.js"; | ||
export * from "./interfaces.js"; | ||
export * from "./qs.js"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -17,5 +17,7 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./is.js"), exports); | ||
__exportStar(require("@bunt/is"), exports); | ||
__exportStar(require("@bunt/assert"), exports); | ||
__exportStar(require("@bunt/type"), exports); | ||
__exportStar(require("@bunt/async"), exports); | ||
__exportStar(require("./stream.js"), exports); | ||
__exportStar(require("./assert.js"), exports); | ||
__exportStar(require("./object.js"), exports); | ||
@@ -28,10 +30,7 @@ __exportStar(require("./string.js"), exports); | ||
__exportStar(require("./Logger/index.js"), exports); | ||
__exportStar(require("./Exception/index.js"), exports); | ||
__exportStar(require("./Node/index.js"), exports); | ||
__exportStar(require("./Perf/index.js"), exports); | ||
__exportStar(require("./Async/index.js"), exports); | ||
__exportStar(require("./Ref/index.js"), exports); | ||
__exportStar(require("./Map/index.js"), exports); | ||
__exportStar(require("./interfaces.js"), exports); | ||
__exportStar(require("./qs.js"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,3 @@ | ||
import { ILogable, ILogger, Logable, LoggerOwner } from "./interfaces.js"; | ||
import { ILogable, Logable } from "@bunt/type"; | ||
import { ILogger, LoggerOwner } from "./interfaces.js"; | ||
export declare function isLoggerOwner(target: LoggerOwner): target is ILogger; | ||
@@ -3,0 +4,0 @@ export declare function isLogable(target: Logable): target is ILogable<any>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.logger = exports.isLogable = exports.isLoggerOwner = void 0; | ||
const is_js_1 = require("../is.js"); | ||
const is_1 = require("@bunt/is"); | ||
const Logger_js_1 = require("./Logger.js"); | ||
@@ -11,3 +11,3 @@ function isLoggerOwner(target) { | ||
function isLogable(target) { | ||
return (0, is_js_1.isObject)(target) && "getLogValue" in target; | ||
return (0, is_1.isObject)(target) && "getLogValue" in target; | ||
} | ||
@@ -14,0 +14,0 @@ exports.isLogable = isLogable; |
@@ -1,2 +0,2 @@ | ||
import { Func, Promisify } from "../interfaces.js"; | ||
import { Func, Logable, LogableType, Promisify } from "@bunt/type"; | ||
import { Logger } from "./Logger.js"; | ||
@@ -24,7 +24,2 @@ export declare enum SeverityLevel { | ||
export type LoggerOwner = Record<any, any> | ILogger | Func; | ||
export type LogableType = string | Record<any, any> | number | bigint | null | undefined | boolean | Date | unknown; | ||
export interface ILogable<T extends LogableType> { | ||
getLogValue(): T; | ||
} | ||
export type Logable = ILogable<LogableType> | LogableType | Logable[]; | ||
export type LogFn = (message: string, ...args: Logable[]) => void; | ||
@@ -31,0 +26,0 @@ export type LogWrapFn = (logger: Logger, message: string, ...args: LogableType[]) => void; |
@@ -1,2 +0,3 @@ | ||
import { ILogger, ILoggerTransport, Logable, LogableType, LogFn, LoggerOwner, LogWrapFn, SeverityLevel } from "./interfaces.js"; | ||
import { Logable, LogableType } from "@bunt/type"; | ||
import { ILogger, ILoggerTransport, LogFn, LoggerOwner, LogWrapFn, SeverityLevel } from "./interfaces.js"; | ||
export declare class Logger { | ||
@@ -3,0 +4,0 @@ #private; |
@@ -29,4 +29,4 @@ "use strict"; | ||
const util_1 = require("util"); | ||
const assert_js_1 = require("../assert.js"); | ||
const is_js_1 = require("../is.js"); | ||
const is_1 = require("@bunt/is"); | ||
const assert_1 = require("@bunt/assert"); | ||
const index_js_1 = require("../Perf/index.js"); | ||
@@ -56,3 +56,3 @@ const function_js_1 = require("../function.js"); | ||
this.#label = label; | ||
this.groupId = (0, is_js_1.isNumber)(groupId) | ||
this.groupId = (0, is_1.isNumber)(groupId) | ||
? groupId.toString() | ||
@@ -104,3 +104,3 @@ : groupId; | ||
static createLogger(target) { | ||
const label = (0, is_js_1.isFunction)(target) ? target.name : target.constructor.name; | ||
const label = (0, is_1.isFunction)(target) ? target.name : target.constructor.name; | ||
if ((0, functions_js_1.isLoggerOwner)(target)) { | ||
@@ -119,3 +119,3 @@ const logger = new this(target.getLogLabel?.() ?? label, target.getLogGroupId?.()); | ||
const matched = [...message.match(placeholderRegex) ?? []]; | ||
(0, assert_js_1.assert)(matched.length <= args.length, "Logger.format(message, ...args): args count less than placeholders"); | ||
(0, assert_1.assert)(matched.length <= args.length, "Logger.format(message, ...args): args count less than placeholders"); | ||
return { | ||
@@ -149,7 +149,7 @@ message: (0, util_1.format)(message, ...args.slice(0, matched.length)), | ||
for (const arg of args) { | ||
if ((0, is_js_1.isInstanceOf)(arg, Error)) { | ||
if ((0, is_1.isInstanceOf)(arg, Error)) { | ||
const error = { message: arg.message, stack: arg.stack }; | ||
if ((0, functions_js_1.isLogable)(arg)) { | ||
const logValue = arg.getLogValue(); | ||
if ((0, is_js_1.isDefined)(logValue)) { | ||
if ((0, is_1.isDefined)(logValue)) { | ||
error.extra = arg.getLogValue(); | ||
@@ -196,3 +196,3 @@ } | ||
add(child) { | ||
if (child.logger === this || (0, is_js_1.isDefined)(child.logger.groupId) || (0, is_js_1.isUndefined)(this.groupId)) { | ||
if (child.logger === this || (0, is_1.isDefined)(child.logger.groupId) || (0, is_1.isUndefined)(this.groupId)) { | ||
return; | ||
@@ -199,0 +199,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.debugLogFormat = exports.readableJSONLogFormat = exports.defaultLogFormat = void 0; | ||
const is_js_1 = require("../../is.js"); | ||
const is_1 = require("@bunt/is"); | ||
const interfaces_js_1 = require("../interfaces.js"); | ||
@@ -24,6 +24,6 @@ const defaultLogFormat = (log) => { | ||
]; | ||
const debug = [info.filter(is_js_1.isDefined).join(" "), message]; | ||
(0, is_js_1.isDefined)(system) && debug.push(JSON.stringify(system, null, 2)); | ||
(0, is_js_1.isDefined)(args) && debug.push(...args.map((arg) => { | ||
if ((0, is_js_1.isString)(arg)) { | ||
const debug = [info.filter(is_1.isDefined).join(" "), message]; | ||
(0, is_1.isDefined)(system) && debug.push(JSON.stringify(system, null, 2)); | ||
(0, is_1.isDefined)(args) && debug.push(...args.map((arg) => { | ||
if ((0, is_1.isString)(arg)) { | ||
return arg; | ||
@@ -30,0 +30,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { Promisify } from "../../interfaces.js"; | ||
import { Promisify } from "@bunt/type"; | ||
import { ILoggerTransport, LogFormat, LogMessage } from "../interfaces.js"; | ||
@@ -3,0 +3,0 @@ export interface ILoggerStreamCallback<T> { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.XMap = void 0; | ||
const assert_js_1 = require("../assert.js"); | ||
const is_js_1 = require("../is.js"); | ||
const assert_1 = require("@bunt/assert"); | ||
const is_1 = require("@bunt/is"); | ||
class XMap extends Map { | ||
@@ -12,7 +12,7 @@ #initializer; | ||
this.#initializer = initializer; | ||
if ((0, is_js_1.isArray)(valuesOr)) { | ||
if ((0, is_1.isArray)(valuesOr)) { | ||
valuesOr.forEach(([key, value]) => this.set(key, value)); | ||
this.#initializer = initializer; | ||
} | ||
if ((0, is_js_1.isFunction)(valuesOr)) { | ||
if ((0, is_1.isFunction)(valuesOr)) { | ||
this.#initializer = valuesOr; | ||
@@ -29,3 +29,3 @@ } | ||
const exists = this.has(key); | ||
if (!exists && (0, is_js_1.isFunction)(initializer)) { | ||
if (!exists && (0, is_1.isFunction)(initializer)) { | ||
const value = initializer(key); | ||
@@ -35,3 +35,3 @@ this.set(key, value); | ||
} | ||
(0, assert_js_1.assert)(exists, `The key doesn't exists: ${key}`); | ||
(0, assert_1.assert)(exists, `The key doesn't exists: ${key}`); | ||
return this.get(key); | ||
@@ -38,0 +38,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Argv = void 0; | ||
const assert_js_1 = require("../assert.js"); | ||
const is_js_1 = require("../is.js"); | ||
const is_1 = require("@bunt/is"); | ||
const assert_1 = require("@bunt/assert"); | ||
const object_js_1 = require("../object.js"); | ||
@@ -34,3 +34,3 @@ const OPTION_REGEX = /^--([a-z0-9_-]+)=(.+)$/i; | ||
const value = this.options.get(name); | ||
if ((0, is_js_1.isDefined)(value) && (0, is_js_1.isNumber)(defaultValue)) { | ||
if ((0, is_1.isDefined)(value) && (0, is_1.isNumber)(defaultValue)) { | ||
return parseInt(value, 10); | ||
@@ -70,3 +70,3 @@ } | ||
const res = value.match(re); | ||
(0, assert_js_1.assert)(res && res[index]); | ||
(0, assert_1.assert)(res && res[index]); | ||
return res[index]; | ||
@@ -73,0 +73,0 @@ } |
/// <reference types="node" /> | ||
import { KeyOf } from "../interfaces.js"; | ||
import { KeyOf } from "@bunt/type"; | ||
import { Dict } from "./interfaces.js"; | ||
@@ -4,0 +4,0 @@ export type EnvValue = string | undefined; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Env = void 0; | ||
const assert_js_1 = require("../assert.js"); | ||
const assert_1 = require("@bunt/assert"); | ||
class Env { | ||
@@ -18,3 +18,3 @@ #store; | ||
const value = this.get(key); | ||
(0, assert_js_1.assert)(value, `The key doesn't exists: ${key}`); | ||
(0, assert_1.assert)(value, `The key doesn't exists: ${key}`); | ||
return fn | ||
@@ -21,0 +21,0 @@ ? fn(value) |
@@ -1,2 +0,2 @@ | ||
import { DecoratorTarget } from "./interfaces.js"; | ||
import { DecoratorTarget } from "@bunt/type"; | ||
export declare const freeze: <S extends { | ||
@@ -3,0 +3,0 @@ [key: string]: any; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getClassName = exports.entriesReverse = exports.freeze = void 0; | ||
const is_js_1 = require("./is.js"); | ||
const is_1 = require("@bunt/is"); | ||
const freeze = (source) => { | ||
@@ -9,3 +9,3 @@ const target = Object.freeze(Object.assign(Object.create(null), source)); | ||
// @check for plain object | ||
if ((0, is_js_1.isObject)(value)) { | ||
if ((0, is_1.isObject)(value)) { | ||
target[key] = (0, exports.freeze)(target[key]); | ||
@@ -12,0 +12,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { ILogable } from "../Logger/index.js"; | ||
import { ILogable } from "@bunt/type"; | ||
import { IPerfValue, PerfLabel } from "./interfaces.js"; | ||
@@ -3,0 +3,0 @@ export declare class Perf implements ILogable<IPerfValue> { |
@@ -5,3 +5,3 @@ "use strict"; | ||
const perf_hooks_1 = require("perf_hooks"); | ||
const is_js_1 = require("../is.js"); | ||
const is_1 = require("@bunt/is"); | ||
class Perf { | ||
@@ -12,3 +12,3 @@ label; | ||
constructor(...labels) { | ||
this.label = labels.map((label) => (0, is_js_1.isString)(label) ? label : label.constructor.name) | ||
this.label = labels.map((label) => (0, is_1.isString)(label) ? label : label.constructor.name) | ||
.join(" -> "); | ||
@@ -15,0 +15,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SingleRef = void 0; | ||
const assert_js_1 = require("../assert.js"); | ||
const assert_1 = require("@bunt/assert"); | ||
const store = new WeakMap(); | ||
@@ -19,7 +19,7 @@ class SingleRef { | ||
const ref = this.get(); | ||
(0, assert_js_1.assert)(ref, "Unknown reference"); | ||
(0, assert_1.assert)(ref, "Unknown reference"); | ||
return ref; | ||
} | ||
once(fn) { | ||
(0, assert_js_1.assert)(!this.has(), "Cannot getting twice"); | ||
(0, assert_1.assert)(!this.has(), "Cannot getting twice"); | ||
return this.create(fn); | ||
@@ -26,0 +26,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isTransformStream = exports.isDuplexStream = exports.isWritableStream = exports.isReadableStream = exports.isStream = void 0; | ||
const is_js_1 = require("./is.js"); | ||
const is_1 = require("@bunt/is"); | ||
const isStream = (stream) => (stream !== null && | ||
(0, is_js_1.isObject)(stream) && | ||
(0, is_1.isObject)(stream) && | ||
typeof stream.pipe === "function"); | ||
@@ -8,0 +8,0 @@ exports.isStream = isStream; |
@@ -1,2 +0,2 @@ | ||
import { Promisify } from "../interfaces.js"; | ||
import { Promisify } from "@bunt/type"; | ||
export type TypeToJSON<T> = T extends Date ? string | number : any; | ||
@@ -3,0 +3,0 @@ export type TransformFunction<T> = (value: TypeToJSON<T>) => Promisify<T>; |
@@ -1,2 +0,2 @@ | ||
import { Promisify } from "../interfaces.js"; | ||
import { Promisify } from "@bunt/type"; | ||
import { JSONInput, Transformable, TransformOut, TransformSchema } from "./interfaces.js"; | ||
@@ -3,0 +3,0 @@ export declare class TransformInput { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TransformInput = void 0; | ||
const is_js_1 = require("../is.js"); | ||
const is_1 = require("@bunt/is"); | ||
class TransformInput { | ||
static async transform(data, schema) { | ||
if ((0, is_js_1.isArray)(data)) { | ||
if ((0, is_1.isArray)(data)) { | ||
return Promise.all(data.map((item) => this.transform(item, schema))); | ||
@@ -15,7 +15,7 @@ } | ||
const sourceValue = Reflect.get(data, property); | ||
if ((0, is_js_1.isFunction)(transform)) { | ||
if ((0, is_1.isFunction)(transform)) { | ||
Reflect.set(data, property, await transform(sourceValue)); | ||
continue; | ||
} | ||
if ((0, is_js_1.isObject)(transform)) { | ||
if ((0, is_1.isObject)(transform)) { | ||
await this.transform(sourceValue, transform); | ||
@@ -22,0 +22,0 @@ } |
{ | ||
"name": "@bunt/util", | ||
"version": "0.29.13", | ||
"keywords": [ | ||
"typescript" | ||
], | ||
"author": { | ||
"name": "Artur Bier", | ||
"email": "izatop@gmail.com" | ||
}, | ||
"main": "dist/cjs/index.js", | ||
"module": "dist/esm/index.js", | ||
"types": "dist/cjs/index.d.ts", | ||
"exports": { | ||
".": { | ||
"import": { | ||
"types": "./dist/esm/index.d.ts", | ||
"default": "./dist/esm/index.js" | ||
}, | ||
"require": { | ||
"types": "./dist/cjs/index.d.ts", | ||
"default": "./dist/cjs/index.js" | ||
} | ||
} | ||
}, | ||
"files": [ | ||
"dist/", | ||
"LICENSE" | ||
], | ||
"description": "Utils", | ||
"repository": "git@github.com:izatop/bunt.git", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"license": "MIT", | ||
"gitHead": "8eb5e57f43cfb71c79b4b5183207b2894ec4726d" | ||
"name": "@bunt/util", | ||
"version": "0.29.14", | ||
"keywords": [ | ||
"typescript" | ||
], | ||
"author": { | ||
"name": "Artur Bier", | ||
"email": "izatop@gmail.com" | ||
}, | ||
"main": "dist/cjs/index.js", | ||
"module": "dist/esm/index.js", | ||
"types": "dist/cjs/index.d.ts", | ||
"exports": { | ||
".": { | ||
"import": { | ||
"types": "./dist/esm/index.d.ts", | ||
"default": "./dist/esm/index.js" | ||
}, | ||
"require": { | ||
"types": "./dist/cjs/index.d.ts", | ||
"default": "./dist/cjs/index.js" | ||
} | ||
} | ||
}, | ||
"files": [ | ||
"dist/", | ||
"LICENSE" | ||
], | ||
"dependencies": { | ||
"@bunt/assert": "^0.29.14", | ||
"@bunt/async": "^0.29.14", | ||
"@bunt/is": "^0.29.14", | ||
"@bunt/type": "^0.29.14" | ||
}, | ||
"description": "Utils", | ||
"repository": "git@github.com:izatop/bunt.git", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"license": "MIT", | ||
"gitHead": "d4766cbd69a88380fe736738fa9a68604f77d305" | ||
} |
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
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
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
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
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
358520
4
269
2595
+ Added@bunt/assert@^0.29.14
+ Added@bunt/async@^0.29.14
+ Added@bunt/is@^0.29.14
+ Added@bunt/type@^0.29.14
+ Added@bunt/assert@0.29.19(transitive)
+ Added@bunt/async@0.29.19(transitive)
+ Added@bunt/is@0.29.19(transitive)
+ Added@bunt/type@0.29.19(transitive)