@uxf/core 11.89.0 → 11.90.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -422,6 +422,27 @@ isNotNil([]); /* returns true */
422
422
  isNotNil("string"); /* returns true */
423
423
  ```
424
424
 
425
+ ## isPlainObject
426
+
427
+ Type guard that checks if a value is a plain object. Returns `false` for arrays, `null`, `Date`, `Map`, `Set`, `RegExp`, and other non-plain-object types.
428
+
429
+ ```tsx
430
+ import { isPlainObject } from "@uxf/core/utils/is-plain-object";
431
+
432
+ isPlainObject({}); /* returns true */
433
+ isPlainObject({ a: 1 }); /* returns true */
434
+ isPlainObject([]); /* returns false */
435
+ isPlainObject([1, 2, 3]); /* returns false */
436
+ isPlainObject(new Date()); /* returns false */
437
+ isPlainObject(new Map()); /* returns false */
438
+ isPlainObject(new Set()); /* returns false */
439
+ isPlainObject(/regex/); /* returns false */
440
+ isPlainObject(null); /* returns false */
441
+ isPlainObject(undefined); /* returns false */
442
+ isPlainObject("string"); /* returns false */
443
+ isPlainObject(123); /* returns false */
444
+ ```
445
+
425
446
  ## last
426
447
 
427
448
  ```tsx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/core",
3
- "version": "11.89.0",
3
+ "version": "11.90.0",
4
4
  "description": "UXF Core",
5
5
  "author": "Petr Vejvoda <vejvoda@uxf.cz>",
6
6
  "homepage": "https://gitlab.com/uxf-npm/core#readme",
package/types/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export type Nullish = null | undefined;
2
2
  export type Noop = () => void;
3
3
  export type AnyObject = Partial<Record<string, any>>;
4
+ export type UnknownObject = Partial<Record<string, unknown>>;
4
5
  export type AnyJSON = any;
5
6
  export interface FileResponse {
6
7
  id: number;
@@ -0,0 +1,2 @@
1
+ import { UnknownObject } from "../types";
2
+ export declare function isPlainObject(value: unknown): value is UnknownObject;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isPlainObject = isPlainObject;
4
+ function isPlainObject(value) {
5
+ var _a;
6
+ if (typeof value !== "object" || value === null) {
7
+ return false;
8
+ }
9
+ if (Object.prototype.toString.call(value) !== "[object Object]") {
10
+ return false;
11
+ }
12
+ const proto = Object.getPrototypeOf(value);
13
+ if (proto === null) {
14
+ return true;
15
+ }
16
+ // Handle cross-realm objects by checking if proto's constructor is named "Object"
17
+ return ((_a = proto.constructor) === null || _a === void 0 ? void 0 : _a.name) === "Object";
18
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const is_plain_object_1 = require("./is-plain-object");
4
+ test("is-plain-object", () => {
5
+ [{}, { a: 1 }, Object.create(null)].map((value) => expect((0, is_plain_object_1.isPlainObject)(value)).toBeTruthy());
6
+ const emptyFn = () => undefined;
7
+ [
8
+ null,
9
+ undefined,
10
+ "",
11
+ "string",
12
+ 0,
13
+ 1,
14
+ true,
15
+ false,
16
+ NaN,
17
+ Infinity,
18
+ Symbol("test"),
19
+ emptyFn,
20
+ [],
21
+ [1, 2, 3],
22
+ new Date(),
23
+ new Map(),
24
+ new Set(),
25
+ /regex/,
26
+ ].map((value) => expect((0, is_plain_object_1.isPlainObject)(value)).toBeFalsy());
27
+ });