Skip to content

Commit 192abc2

Browse files
added isPlainObject
1 parent 026b5f2 commit 192abc2

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/index.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,19 @@ export function memo<T, P extends keyof T>(
171171
}
172172
return result;
173173
}
174+
175+
/**
176+
* Validate if a value is an object
177+
*
178+
* @param {object} source
179+
* @returns {Boolean}
180+
*/
181+
export function isPlainObject(source: Object): boolean {
182+
const typeofSource: string = typeof source;
183+
const sourcePrototype: string = Object.prototype.toString.call(source);
184+
return (
185+
typeofSource === 'object' &&
186+
source !== null &&
187+
sourcePrototype === '[object Object]'
188+
);
189+
}

0 commit comments

Comments
 (0)