@dhmk/utils
Advanced tools
Comparing version 4.3.2 to 4.3.3
@@ -11,3 +11,3 @@ import { StrKeyOf, DeepReadonly, DeepPartial } from "./types"; | ||
export declare function objectMap<T extends object, V extends ValueMapper<T>>(src: T, mapValue: V): Record<StrKeyOf<T>, ReturnType<V>>; | ||
export declare function objectMap<T extends object>(src: T, mapValue: ValueMapper<T>, mapKey?: KeyMapper<T>): any; | ||
export declare function objectMap<T extends object>(src: T, mapValue: ValueMapper<T>, mapKey?: KeyMapper<T>, mapSymbol?: (v: T[keyof T & symbol], k: keyof T & symbol, src: T) => unknown): any; | ||
export declare function objectTransform<T extends object, K extends keyof any = keyof T, V = T[keyof T]>(src: T, mapEntry: (v: T[keyof T], k: keyof T, src: T) => readonly [K, V] | null): Record<K, V>; | ||
@@ -14,0 +14,0 @@ export declare function getter<T>(t: T, k: keyof T): Readonly<{ |
@@ -42,11 +42,15 @@ var __assign = (this && this.__assign) || function () { | ||
} | ||
export function objectMap(src, mapValue, mapKey) { | ||
export function objectMap(src, mapValue, mapKey, mapSymbol) { | ||
if (mapKey === void 0) { mapKey = id; } | ||
return objectFrom(Object.keys(src).map(function (k) { return [ | ||
mapKey(k, src[k], src), | ||
mapValue(src[k], k, src), | ||
]; })); | ||
if (mapSymbol === void 0) { mapSymbol = id; } | ||
return objectFrom(Object.keys(src) | ||
.map(function (k) { return [mapKey(k, src[k], src), mapValue(src[k], k, src)]; }) | ||
.concat(Object.getOwnPropertySymbols(src).map(function (k) { return [ | ||
k, | ||
mapSymbol(src[k], k, src), | ||
]; }))); | ||
} | ||
export function objectTransform(src, mapEntry) { | ||
return objectFrom(Object.keys(src) | ||
.concat(Object.getOwnPropertySymbols(src)) | ||
.map(function (k) { return mapEntry(src[k], k, src); }) | ||
@@ -53,0 +57,0 @@ .filter(Boolean)); |
@@ -11,3 +11,3 @@ import { StrKeyOf, DeepReadonly, DeepPartial } from "./types"; | ||
export declare function objectMap<T extends object, V extends ValueMapper<T>>(src: T, mapValue: V): Record<StrKeyOf<T>, ReturnType<V>>; | ||
export declare function objectMap<T extends object>(src: T, mapValue: ValueMapper<T>, mapKey?: KeyMapper<T>): any; | ||
export declare function objectMap<T extends object>(src: T, mapValue: ValueMapper<T>, mapKey?: KeyMapper<T>, mapSymbol?: (v: T[keyof T & symbol], k: keyof T & symbol, src: T) => unknown): any; | ||
export declare function objectTransform<T extends object, K extends keyof any = keyof T, V = T[keyof T]>(src: T, mapEntry: (v: T[keyof T], k: keyof T, src: T) => readonly [K, V] | null): Record<K, V>; | ||
@@ -14,0 +14,0 @@ export declare function getter<T>(t: T, k: keyof T): Readonly<{ |
@@ -51,8 +51,11 @@ "use strict"; | ||
exports.objectFrom = objectFrom; | ||
function objectMap(src, mapValue, mapKey) { | ||
function objectMap(src, mapValue, mapKey, mapSymbol) { | ||
if (mapKey === void 0) { mapKey = exports.id; } | ||
return objectFrom(Object.keys(src).map(function (k) { return [ | ||
mapKey(k, src[k], src), | ||
mapValue(src[k], k, src), | ||
]; })); | ||
if (mapSymbol === void 0) { mapSymbol = exports.id; } | ||
return objectFrom(Object.keys(src) | ||
.map(function (k) { return [mapKey(k, src[k], src), mapValue(src[k], k, src)]; }) | ||
.concat(Object.getOwnPropertySymbols(src).map(function (k) { return [ | ||
k, | ||
mapSymbol(src[k], k, src), | ||
]; }))); | ||
} | ||
@@ -62,2 +65,3 @@ exports.objectMap = objectMap; | ||
return objectFrom(Object.keys(src) | ||
.concat(Object.getOwnPropertySymbols(src)) | ||
.map(function (k) { return mapEntry(src[k], k, src); }) | ||
@@ -64,0 +68,0 @@ .filter(Boolean)); |
{ | ||
"name": "@dhmk/utils", | ||
"version": "4.3.2", | ||
"version": "4.3.3", | ||
"description": "A collection of frequently used functions and primitives", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
126423
2906