mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-19 11:01:15 +00:00
fix(editor): Rename and move isObjectLiteral utility function (no-changelog) (#7565)
This commit is contained in:
20
packages/editor-ui/src/utils/objectUtils.ts
Normal file
20
packages/editor-ui/src/utils/objectUtils.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
type ObjectOrArray = Record<string, unknown> | unknown[];
|
||||
|
||||
export function isDateObject(maybeDate: unknown): maybeDate is Date {
|
||||
return maybeDate instanceof Date;
|
||||
}
|
||||
|
||||
export function isObjectOrArray(maybeObject: unknown): maybeObject is ObjectOrArray {
|
||||
return typeof maybeObject === 'object' && maybeObject !== null && !isDateObject(maybeObject);
|
||||
}
|
||||
|
||||
export function isObject(maybeObject: unknown): maybeObject is Record<string, unknown> {
|
||||
return isObjectOrArray(maybeObject) && !Array.isArray(maybeObject);
|
||||
}
|
||||
|
||||
export const searchInObject = (obj: ObjectOrArray, searchString: string): boolean =>
|
||||
(Array.isArray(obj) ? obj : Object.entries(obj)).some((entry) =>
|
||||
isObjectOrArray(entry)
|
||||
? searchInObject(entry, searchString)
|
||||
: entry?.toString().includes(searchString),
|
||||
);
|
||||
Reference in New Issue
Block a user