topkat-utils 1.3.7 → 1.3.8
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/README.md +1 -0
- package/coverage/clover.xml +31 -15
- package/coverage/coverage-final.json +3 -3
- package/coverage/lcov-report/clean-stack-trace.ts.html +7 -7
- package/coverage/lcov-report/config.ts.html +1 -1
- package/coverage/lcov-report/error-utils.ts.html +1 -1
- package/coverage/lcov-report/index.html +20 -20
- package/coverage/lcov-report/is-empty.ts.html +1 -1
- package/coverage/lcov-report/is-nodejs.ts.html +1 -1
- package/coverage/lcov-report/is-object.ts.html +1 -1
- package/coverage/lcov-report/isset.ts.html +1 -1
- package/coverage/lcov-report/logger-utils.ts.html +3 -3
- package/coverage/lcov-report/loop-utils.ts.html +1 -1
- package/coverage/lcov-report/math-utils.ts.html +1 -1
- package/coverage/lcov-report/object-utils.ts.html +57 -9
- package/coverage/lcov-report/regexp-utils.ts.html +1 -1
- package/coverage/lcov-report/remove-circular-json-stringify.ts.html +1 -1
- package/coverage/lcov-report/string-utils.ts.html +1 -1
- package/coverage/lcov-report/timer-utils.ts.html +1 -1
- package/coverage/lcov-report/transaction-utils.ts.html +1 -1
- package/coverage/lcov.info +34 -22
- package/dist/src/object-utils.d.ts +5 -0
- package/dist/src/object-utils.js +14 -1
- package/dist/src/object-utils.js.map +1 -1
- package/package.json +1 -1
- package/src/object-utils.ts +17 -1
package/src/object-utils.ts
CHANGED
|
@@ -441,4 +441,20 @@ export function mergeObjectArrays<T extends Record<string, any[]>>(obj: T) {
|
|
|
441
441
|
}
|
|
442
442
|
|
|
443
443
|
export const keys = objKeys
|
|
444
|
-
export const entries = objEntries
|
|
444
|
+
export const entries = objEntries
|
|
445
|
+
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
/** A Helper to create JavascriptProxies, will add __isProxy and toJSON helper to prevent error when logging the proxy and to be able to check if the object is proxyfied */
|
|
449
|
+
export function createProxy<T extends Record<string, any>>(obj: T, optn: {
|
|
450
|
+
getter: Required<ProxyHandler<T>>['get'],
|
|
451
|
+
jsonRepresentation?: (obj: T) => string
|
|
452
|
+
}) {
|
|
453
|
+
return new Proxy(obj, {
|
|
454
|
+
get(target, prop, receiver) {
|
|
455
|
+
if (prop === '__isProxy') return true
|
|
456
|
+
else if (prop === 'toJSON') return optn?.jsonRepresentation?.(target) || '[TopkatUtils Proxy]'
|
|
457
|
+
return optn.getter(target, prop, receiver)
|
|
458
|
+
}
|
|
459
|
+
})
|
|
460
|
+
}
|