Add objLength and isObjEmpty util fns (#3605)

### Description

Add `objLength` and `isObjEmpty` utils

### Related issues

Fixes https://github.com/hyperlane-xyz/issues/issues/1199

### Backward compatibility

Yes
pull/3620/head
J M Rossy 7 months ago committed by GitHub
parent 9a32971050
commit 2b3f75836a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      .changeset/poor-kings-fold.md
  2. 2
      typescript/utils/src/index.ts
  3. 8
      typescript/utils/src/objects.ts

@ -0,0 +1,5 @@
---
'@hyperlane-xyz/utils': patch
---
Add objLength and isObjEmpty utils

@ -100,9 +100,11 @@ export {
deepCopy,
deepEquals,
invertKeysAndValues,
isObjEmpty,
isObject,
objFilter,
objKeys,
objLength,
objMap,
objMapEntries,
objMerge,

@ -17,6 +17,14 @@ export function objKeys<T extends string | number>(obj: Record<T, any>): T[] {
return Object.keys(obj) as T[];
}
export function objLength(obj: Record<any, any>) {
return Object.keys(obj).length;
}
export function isObjEmpty(obj: Record<any, any>) {
return objLength(obj) === 0;
}
export function objMapEntries<
M extends Record<K, I>,
K extends keyof M,

Loading…
Cancel
Save