@hairy/utils 1.29.0 → 1.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +32 -0
- package/dist/index.d.ts +9 -1
- package/dist/index.global.js +30 -0
- package/dist/index.js +31 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -111,6 +111,7 @@ __export(index_exports, {
|
|
|
111
111
|
percentage: () => percentage,
|
|
112
112
|
pipe: () => pipe,
|
|
113
113
|
plus: () => plus,
|
|
114
|
+
proxy: () => proxy,
|
|
114
115
|
randomArray: () => randomArray,
|
|
115
116
|
randomNumer: () => randomNumer,
|
|
116
117
|
riposte: () => riposte,
|
|
@@ -3278,6 +3279,36 @@ function pipe(...fns) {
|
|
|
3278
3279
|
}
|
|
3279
3280
|
pipe.promise = pPipe;
|
|
3280
3281
|
|
|
3282
|
+
// src/util/proxy.ts
|
|
3283
|
+
function proxy(initObject) {
|
|
3284
|
+
initObject && Reflect.set(initObject, "proxyUpdated", true);
|
|
3285
|
+
let target = initObject || { proxyUpdated: false };
|
|
3286
|
+
const proxy2 = new Proxy({}, {
|
|
3287
|
+
get: (_, p) => {
|
|
3288
|
+
return typeof target?.[p] === "function" ? target?.[p].bind(target) : target?.[p];
|
|
3289
|
+
},
|
|
3290
|
+
set: (_, p, v) => {
|
|
3291
|
+
target[p] = v;
|
|
3292
|
+
return true;
|
|
3293
|
+
}
|
|
3294
|
+
});
|
|
3295
|
+
function update(object) {
|
|
3296
|
+
if (!object) {
|
|
3297
|
+
target = void 0;
|
|
3298
|
+
return;
|
|
3299
|
+
}
|
|
3300
|
+
Reflect.set(object, "proxyUpdated", true);
|
|
3301
|
+
target = object;
|
|
3302
|
+
}
|
|
3303
|
+
return {
|
|
3304
|
+
proxy: proxy2,
|
|
3305
|
+
update
|
|
3306
|
+
};
|
|
3307
|
+
}
|
|
3308
|
+
proxy.resolve = (target) => {
|
|
3309
|
+
return Reflect.get(target, "proxyUpdated") ? target : void 0;
|
|
3310
|
+
};
|
|
3311
|
+
|
|
3281
3312
|
// src/util/random.ts
|
|
3282
3313
|
function randomNumer(min, max) {
|
|
3283
3314
|
return Math.random() * (max - min) + min;
|
|
@@ -3401,6 +3432,7 @@ function whenever(value, callback) {
|
|
|
3401
3432
|
percentage,
|
|
3402
3433
|
pipe,
|
|
3403
3434
|
plus,
|
|
3435
|
+
proxy,
|
|
3404
3436
|
randomArray,
|
|
3405
3437
|
randomNumer,
|
|
3406
3438
|
riposte,
|
package/dist/index.d.ts
CHANGED
|
@@ -459,6 +459,14 @@ declare namespace pipe {
|
|
|
459
459
|
var promise: typeof pPipe;
|
|
460
460
|
}
|
|
461
461
|
|
|
462
|
+
declare function proxy<T extends object>(initObject?: T): {
|
|
463
|
+
proxy: T;
|
|
464
|
+
update: (object?: T) => void;
|
|
465
|
+
};
|
|
466
|
+
declare namespace proxy {
|
|
467
|
+
var resolve: <T extends object>(target: T) => T | undefined;
|
|
468
|
+
}
|
|
469
|
+
|
|
462
470
|
declare function randomNumer(min: number, max: number): number;
|
|
463
471
|
declare function randomArray<T>(array: T[]): T;
|
|
464
472
|
|
|
@@ -469,4 +477,4 @@ declare function riposte<T>(...args: [cond: boolean, value: T][]): T;
|
|
|
469
477
|
declare function unwrap<T extends object>(value: T | (() => T)): T;
|
|
470
478
|
declare function whenever<T, C extends (value: Exclude<T, null | undefined>) => any>(value: T, callback: C): ReturnType<C> | undefined;
|
|
471
479
|
|
|
472
|
-
export { type AnyFn, type ArgumentsType, type Arrayable, type Awaitable, BIG_INTS, BigNum, type BooleanLike, type ConstructorType, type DecimalOptions, type DeepKeyof, type DeepMerge, type DeepPartial, type DeepReadonly, type DeepReplace, type DeepRequired, Deferred, type Delimiter, type Dimension, type DynamicObject, type ElementOf, type Fn$1 as Fn, type FormatGroupOptions, type FormatNumericOptions, type IfAny, type IsAny, type Key, type Looper, type MergeInsertions, type Noop, type Nullable, type NumberObject, type Numberish, type Numeric, type NumericObject, type Option, type PromiseFn, type PromiseType, type Promisify, type StringObject, type SymbolObject, type Typeof, arange, average, camelCase, capitalCase, compose, constantCase, cover, decimal, delay, dotCase, formToObject, formatNumeric, formatSize, formatUnit, getTypeof, gt, gte, integer, isAndroid, isBrowser, isChrome, isEdge, isFF, isFormData, isIE, isIE11, isIE9, isIOS, isMobile, isPhantomJS, isTruthy, isTypeof, isWeex, isWindow, jsonTryParse, kebabCase, loop, lt, lte, noCase, noop, numerfix, objectToForm, parseNumeric, pascalCase, pascalSnakeCase, pathCase, percentage, pipe, plus, randomArray, randomNumer, riposte, sentenceCase, snakeCase, to, trainCase, unwrap, whenever, zerofill, zeromove };
|
|
480
|
+
export { type AnyFn, type ArgumentsType, type Arrayable, type Awaitable, BIG_INTS, BigNum, type BooleanLike, type ConstructorType, type DecimalOptions, type DeepKeyof, type DeepMerge, type DeepPartial, type DeepReadonly, type DeepReplace, type DeepRequired, Deferred, type Delimiter, type Dimension, type DynamicObject, type ElementOf, type Fn$1 as Fn, type FormatGroupOptions, type FormatNumericOptions, type IfAny, type IsAny, type Key, type Looper, type MergeInsertions, type Noop, type Nullable, type NumberObject, type Numberish, type Numeric, type NumericObject, type Option, type PromiseFn, type PromiseType, type Promisify, type StringObject, type SymbolObject, type Typeof, arange, average, camelCase, capitalCase, compose, constantCase, cover, decimal, delay, dotCase, formToObject, formatNumeric, formatSize, formatUnit, getTypeof, gt, gte, integer, isAndroid, isBrowser, isChrome, isEdge, isFF, isFormData, isIE, isIE11, isIE9, isIOS, isMobile, isPhantomJS, isTruthy, isTypeof, isWeex, isWindow, jsonTryParse, kebabCase, loop, lt, lte, noCase, noop, numerfix, objectToForm, parseNumeric, pascalCase, pascalSnakeCase, pathCase, percentage, pipe, plus, proxy, randomArray, randomNumer, riposte, sentenceCase, snakeCase, to, trainCase, unwrap, whenever, zerofill, zeromove };
|
package/dist/index.global.js
CHANGED
|
@@ -4491,6 +4491,36 @@
|
|
|
4491
4491
|
}
|
|
4492
4492
|
pipe.promise = pPipe;
|
|
4493
4493
|
|
|
4494
|
+
// src/util/proxy.ts
|
|
4495
|
+
function proxy(initObject) {
|
|
4496
|
+
initObject && Reflect.set(initObject, "proxyUpdated", true);
|
|
4497
|
+
let target = initObject || { proxyUpdated: false };
|
|
4498
|
+
const proxy2 = new Proxy({}, {
|
|
4499
|
+
get: (_, p) => {
|
|
4500
|
+
return typeof target?.[p] === "function" ? target?.[p].bind(target) : target?.[p];
|
|
4501
|
+
},
|
|
4502
|
+
set: (_, p, v) => {
|
|
4503
|
+
target[p] = v;
|
|
4504
|
+
return true;
|
|
4505
|
+
}
|
|
4506
|
+
});
|
|
4507
|
+
function update(object) {
|
|
4508
|
+
if (!object) {
|
|
4509
|
+
target = void 0;
|
|
4510
|
+
return;
|
|
4511
|
+
}
|
|
4512
|
+
Reflect.set(object, "proxyUpdated", true);
|
|
4513
|
+
target = object;
|
|
4514
|
+
}
|
|
4515
|
+
return {
|
|
4516
|
+
proxy: proxy2,
|
|
4517
|
+
update
|
|
4518
|
+
};
|
|
4519
|
+
}
|
|
4520
|
+
proxy.resolve = (target) => {
|
|
4521
|
+
return Reflect.get(target, "proxyUpdated") ? target : void 0;
|
|
4522
|
+
};
|
|
4523
|
+
|
|
4494
4524
|
// src/util/random.ts
|
|
4495
4525
|
function randomNumer(min, max) {
|
|
4496
4526
|
return Math.random() * (max - min) + min;
|
package/dist/index.js
CHANGED
|
@@ -3146,6 +3146,36 @@ function pipe(...fns) {
|
|
|
3146
3146
|
}
|
|
3147
3147
|
pipe.promise = pPipe;
|
|
3148
3148
|
|
|
3149
|
+
// src/util/proxy.ts
|
|
3150
|
+
function proxy(initObject) {
|
|
3151
|
+
initObject && Reflect.set(initObject, "proxyUpdated", true);
|
|
3152
|
+
let target = initObject || { proxyUpdated: false };
|
|
3153
|
+
const proxy2 = new Proxy({}, {
|
|
3154
|
+
get: (_, p) => {
|
|
3155
|
+
return typeof target?.[p] === "function" ? target?.[p].bind(target) : target?.[p];
|
|
3156
|
+
},
|
|
3157
|
+
set: (_, p, v) => {
|
|
3158
|
+
target[p] = v;
|
|
3159
|
+
return true;
|
|
3160
|
+
}
|
|
3161
|
+
});
|
|
3162
|
+
function update(object) {
|
|
3163
|
+
if (!object) {
|
|
3164
|
+
target = void 0;
|
|
3165
|
+
return;
|
|
3166
|
+
}
|
|
3167
|
+
Reflect.set(object, "proxyUpdated", true);
|
|
3168
|
+
target = object;
|
|
3169
|
+
}
|
|
3170
|
+
return {
|
|
3171
|
+
proxy: proxy2,
|
|
3172
|
+
update
|
|
3173
|
+
};
|
|
3174
|
+
}
|
|
3175
|
+
proxy.resolve = (target) => {
|
|
3176
|
+
return Reflect.get(target, "proxyUpdated") ? target : void 0;
|
|
3177
|
+
};
|
|
3178
|
+
|
|
3149
3179
|
// src/util/random.ts
|
|
3150
3180
|
function randomNumer(min, max) {
|
|
3151
3181
|
return Math.random() * (max - min) + min;
|
|
@@ -3268,6 +3298,7 @@ export {
|
|
|
3268
3298
|
percentage,
|
|
3269
3299
|
pipe,
|
|
3270
3300
|
plus,
|
|
3301
|
+
proxy,
|
|
3271
3302
|
randomArray,
|
|
3272
3303
|
randomNumer,
|
|
3273
3304
|
riposte,
|