Skip to main content
Version: 1.2.0

resolveObject

Using​

Function that retrieves or resolves only object values. This function should handle various input types, resolving functions if encountered, and ultimately return an object if possible.

If the final resolved value is not an object or if a function remains unresolved within the specified depth, the function return undefined.

Arguments​

ArgumentTypeDescriptionExample
valueobject
function
Value for resolve.{}
() => () => { name: "Alina" }
depthnumberDepth of maximum resolve.2

Returns​

object | undefined — Returns the resolved object otherwise undefined.

Examples​

resolveObject({ some: true });
// { some: true }

resolveObject(() => () => ({ name: 'Alina' }));
// { name: 'Alina' }

resolveObject(['text', 12]);
// undefined

resolveObject(() => ({ package: shegit }), 1);
// { package: shegit }

resolveObject(() => ({ package: shegit }), 2);
// { package: shegit }

resolveObject(() => ({ package: shegit }), 0);
// undefined

Resources​

📦 Since:1.1.0
📦 Last updated:1.1.0
📦 Available in:1.3.0