@zag-js/utils
Advanced tools
Comparing version 0.68.0 to 0.68.1
@@ -38,2 +38,3 @@ declare function toArray<T>(v: T | T[] | undefined | null): T[]; | ||
declare const isBoolean: (v: any) => v is boolean; | ||
declare const isObjectLike: (v: any) => v is Record<string, any>; | ||
declare const isObject: (v: any) => v is Record<string, any>; | ||
@@ -45,2 +46,3 @@ declare const isNumber: (v: any) => v is number; | ||
declare const hasProp: <T extends string>(obj: any, prop: T) => obj is Record<T, any>; | ||
declare const isPlainObject: (v: any) => boolean; | ||
@@ -61,2 +63,2 @@ declare function compact<T extends Record<string, unknown> | undefined>(obj: T): T; | ||
export { type IndexOptions, type MaybeFunction, type Nullable, add, addOrRemove, callAll, cast, chunk, clear, compact, createSplitProps, first, fromLength, has, hasProp, invariant, isArray, isBoolean, isDev, isEmpty, isEqual, isFunction, isNull, isNumber, isObject, isString, json, last, match, next, nextIndex, noop, omit, pick, prev, prevIndex, remove, removeAt, runIfFn, splitProps, toArray, tryCatch, uniq, uuid, warn }; | ||
export { type IndexOptions, type MaybeFunction, type Nullable, add, addOrRemove, callAll, cast, chunk, clear, compact, createSplitProps, first, fromLength, has, hasProp, invariant, isArray, isBoolean, isDev, isEmpty, isEqual, isFunction, isNull, isNumber, isObject, isObjectLike, isPlainObject, isString, json, last, match, next, nextIndex, noop, omit, pick, prev, prevIndex, remove, removeAt, runIfFn, splitProps, toArray, tryCatch, uniq, uuid, warn }; |
@@ -45,2 +45,4 @@ "use strict"; | ||
isObject: () => isObject, | ||
isObjectLike: () => isObjectLike, | ||
isPlainObject: () => isPlainObject, | ||
isString: () => isString, | ||
@@ -199,3 +201,4 @@ json: () => json, | ||
var isBoolean = (v) => v === true || v === false; | ||
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v)); | ||
var isObjectLike = (v) => v != null && typeof v === "object"; | ||
var isObject = (v) => isObjectLike(v) && !isArray(v); | ||
var isNumber = (v) => typeof v === "number" && !Number.isNaN(v); | ||
@@ -206,2 +209,12 @@ var isString = (v) => typeof v === "string"; | ||
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop); | ||
var baseGetTag = (v) => Object.prototype.toString.call(v); | ||
var fnToString = Function.prototype.toString; | ||
var objectCtorString = fnToString.call(Object); | ||
var isPlainObject = (v) => { | ||
if (!isObjectLike(v) || baseGetTag(v) != "[object Object]") return false; | ||
const proto = Object.getPrototypeOf(v); | ||
if (proto === null) return true; | ||
const Ctor = hasProp(proto, "constructor") && proto.constructor; | ||
return typeof Ctor == "function" && Ctor instanceof Ctor && fnToString.call(Ctor) == objectCtorString; | ||
}; | ||
@@ -230,3 +243,3 @@ // src/split-props.ts | ||
function compact(obj) { | ||
if (!isPlainObject(obj) || obj === void 0) { | ||
if (!isPlainObject2(obj) || obj === void 0) { | ||
return obj; | ||
@@ -247,3 +260,3 @@ } | ||
} | ||
var isPlainObject = (value) => { | ||
var isPlainObject2 = (value) => { | ||
return value && typeof value === "object" && value.constructor === Object; | ||
@@ -304,2 +317,4 @@ }; | ||
isObject, | ||
isObjectLike, | ||
isPlainObject, | ||
isString, | ||
@@ -306,0 +321,0 @@ json, |
{ | ||
"name": "@zag-js/utils", | ||
"version": "0.68.0", | ||
"version": "0.68.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
export const isDev = () => process.env.NODE_ENV !== "production" | ||
export const isArray = (v: any): v is any[] => Array.isArray(v) | ||
export const isBoolean = (v: any): v is boolean => v === true || v === false | ||
export const isObject = (v: any): v is Record<string, any> => !(v == null || typeof v !== "object" || isArray(v)) | ||
export const isObjectLike = (v: any): v is Record<string, any> => v != null && typeof v === "object" | ||
export const isObject = (v: any): v is Record<string, any> => isObjectLike(v) && !isArray(v) | ||
export const isNumber = (v: any): v is number => typeof v === "number" && !Number.isNaN(v) | ||
@@ -12,1 +13,13 @@ export const isString = (v: any): v is string => typeof v === "string" | ||
Object.prototype.hasOwnProperty.call(obj, prop) | ||
const baseGetTag = (v: any) => Object.prototype.toString.call(v) | ||
const fnToString = Function.prototype.toString | ||
const objectCtorString = fnToString.call(Object) | ||
export const isPlainObject = (v: any) => { | ||
if (!isObjectLike(v) || baseGetTag(v) != "[object Object]") return false | ||
const proto = Object.getPrototypeOf(v) | ||
if (proto === null) return true | ||
const Ctor = hasProp(proto, "constructor") && proto.constructor | ||
return typeof Ctor == "function" && Ctor instanceof Ctor && fnToString.call(Ctor) == objectCtorString | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
63115
872