New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details β†’ β†’
Socket
Book a DemoSign in
Socket

@httpx/plain-object

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@httpx/plain-object - npm Package Compare versions

Comparing version
2.0.9
to
2.1.0
+1
-1
dist/index.cjs.map

@@ -1,1 +0,1 @@

{"version":3,"sources":["../src/is-plain-object.ts","../src/assert-plain-object.ts","../src/is-static-built-in-class.ts"],"names":["isPlainObject","v","proto","assertPlainObject","msgOrErrorFactory","isStaticBuiltInClass"],"mappings":"aAqDO,IAAMA,CAGXC,CAAAA,CAAAA,EAGyB,CACzB,GAAIA,CAAM,GAAA,IAAA,EAAQ,OAAOA,CAAAA,EAAM,QAC7B,CAAA,OAAO,MAGT,CAAA,IAAMC,CAAQ,CAAA,MAAA,CAAO,cAAeD,CAAAA,CAAC,CACrC,CAAA,OACEC,CAAU,GAAA,IAAA,EACVA,CAAU,GAAA,MAAA,CAAO,SAEjB,EAAA,MAAA,CAAO,cAAeA,CAAAA,CAAK,CAAM,GAAA,IAErC,EC5BO,SAASC,CAGdF,CAAAA,CAAAA,CACAG,CAGsB,CAAA,CACtB,GAAI,CAACJ,CAAsBC,CAAAA,CAAC,CAC1B,CAAA,MACEG,CAAsB,GAAA,MAAA,EACtB,OAAOA,CAAAA,EAAsB,QAEvB,CAAA,IAAI,SAAUA,CAAAA,CAAAA,EAAqB,mBAAmB,CAAA,CAExDA,CAAkB,EAE5B,CC1DO,IAAMC,CAAwBJ,CAAAA,CAAAA,EAC5BA,CAAM,GAAA,IAAA,EAAQA,CAAM,GAAA,IAAA,EAAQA,CAAM,GAAA","file":"index.cjs","sourcesContent":["import type { BasePlainObject, DefaultBasePlainObject } from './internal.types';\nimport type { PlainObject } from './plain-object.types';\n\n/**\n * Check if a value is a plain object\n *\n * A plain object is a basic JavaScript object, such as {}, { data: [] }, new Object() or Object.create(null).\n *\n * @example\n * ```typescript\n * import { isPlainObject } from '@httpx/plain-object';\n *\n * // βœ…πŸ‘‡ True\n *\n * isPlainObject({ }); // βœ…\n * isPlainObject({ key: 'value' }); // βœ…\n * isPlainObject({ key: new Date() }); // βœ…\n * isPlainObject(new Object()); // βœ…\n * isPlainObject(Object.create(null)); // βœ…\n * isPlainObject({ nested: { key: true} }); // βœ…\n * isPlainObject(new Proxy({}, {})); // βœ…\n * isPlainObject({ [Symbol('tag')]: 'A' }); // βœ…\n *\n * // βœ…πŸ‘‡ (node context, workers, ...)\n * const runInNewContext = await import('node:vm').then(\n * (mod) => mod.runInNewContext\n * );\n * isPlainObject(runInNewContext('({})')); // βœ…\n *\n * // βŒπŸ‘‡ False\n *\n * class Test { };\n * isPlainObject(new Test()) // ❌\n * isPlainObject(10); // ❌\n * isPlainObject(null); // ❌\n * isPlainObject('hello'); // ❌\n * isPlainObject([]); // ❌\n * isPlainObject(new Date()); // ❌\n * isPlainObject(new Uint8Array([1])); // ❌\n * isPlainObject(Buffer.from('ABC')); // ❌\n * isPlainObject(Promise.resolve({})); // ❌\n * isPlainObject(Object.create({})); // ❌\n * isPlainObject(new (class Cls {})); // ❌\n * isPlainObject(globalThis); // ❌\n *\n * // βœ…πŸ‘‡ Note that static built-in classes are treated as plain objects\n * // check for `isStaticBuiltInClass` to exclude if needed\n *\n * isPlainObject(Math); // βœ…\n * isPlainObject(JSON); // βœ…\n * isPlainObject(Atomics); // βœ…\n * ```\n */\nexport const isPlainObject = <\n TValue extends BasePlainObject = DefaultBasePlainObject,\n>(\n v: unknown\n): v is TValue extends DefaultBasePlainObject\n ? BasePlainObject\n : PlainObject<TValue> => {\n if (v === null || typeof v !== 'object') {\n return false;\n }\n\n const proto = Object.getPrototypeOf(v) as typeof Object.prototype | null;\n return (\n proto === null ||\n proto === Object.prototype ||\n // Required to support node:vm.runInNewContext({})\n Object.getPrototypeOf(proto) === null\n );\n};\n","import type {\n BasePlainObject,\n DefaultBasePlainObject,\n MsgOrErrorFactory,\n} from './internal.types';\nimport { isPlainObject } from './is-plain-object';\nimport type { PlainObject } from './plain-object.types';\n\n/**\n * Assert a value is a plain object\n *\n * @example\n * ```typescript\n * import { assertPlainObject } from '@httpx/plain-object';\n * import type { PlainObject } from '@httpx/plain-object';\n *\n * function fn(value: unknown) {\n *\n * // πŸ‘‡ Throws `new TypeError('Not a plain object')` if not a plain object\n * assertPlainObject(value);\n *\n * // πŸ‘‡ Throws `new TypeError('Custom message')` if not a plain object\n * assertPlainObject(value, 'Custom message');\n *\n * // πŸ‘‡ Throws custom error if not a plain object\n * assertPlainObject(value, () => {\n * throw new HttpBadRequest('Custom message');\n * });\n *\n * return value;\n * }\n *\n * try {\n * const value = fn({ key: 'value' });\n * // βœ… Value is known to be PlainObject<unknown>\n * assertType<PlainObject>(value);\n * } catch (error) {\n * console.error(error);\n * }\n * ```\n *\n * @throws TypeError\n */\nexport function assertPlainObject<\n TValue extends BasePlainObject = DefaultBasePlainObject,\n>(\n v: unknown,\n msgOrErrorFactory?: MsgOrErrorFactory\n): asserts v is TValue extends DefaultBasePlainObject\n ? BasePlainObject\n : PlainObject<TValue> {\n if (!isPlainObject<TValue>(v)) {\n if (\n msgOrErrorFactory === undefined ||\n typeof msgOrErrorFactory === 'string'\n ) {\n throw new TypeError(msgOrErrorFactory ?? `Not a PlainObject`);\n }\n throw msgOrErrorFactory();\n }\n}\n","export type StaticBuiltInClass = Math | JSON | Atomics;\n\nexport const isStaticBuiltInClass = (v: unknown): v is StaticBuiltInClass => {\n return v === Math || v === JSON || v === Atomics;\n};\n"]}
{"version":3,"sources":["../src/is-plain-object.ts","../src/assert-plain-object.ts","../src/is-static-built-in-class.ts"],"names":["isPlainObject","v","proto","assertPlainObject","msgOrErrorFactory","isStaticBuiltInClass"],"mappings":"aAqDO,IAAMA,CAAAA,CAGXC,CAAAA,EAGyB,CACzB,GAAIA,CAAAA,GAAM,IAAA,EAAQ,OAAOA,CAAAA,EAAM,QAAA,CAC7B,OAAO,MAAA,CAGT,IAAMC,CAAAA,CAAQ,MAAA,CAAO,cAAA,CAAeD,CAAC,CAAA,CACrC,OACEC,CAAAA,GAAU,IAAA,EACVA,CAAAA,GAAU,MAAA,CAAO,SAAA,EAEjB,MAAA,CAAO,cAAA,CAAeA,CAAK,CAAA,GAAM,IAErC,EC5BO,SAASC,CAAAA,CAGdF,CAAAA,CACAG,CAAAA,CAGsB,CACtB,GAAI,CAACJ,CAAAA,CAAsBC,CAAC,CAAA,CAC1B,MACEG,CAAAA,GAAsB,MAAA,EACtB,OAAOA,CAAAA,EAAsB,QAAA,CAEvB,IAAI,SAAA,CAAUA,CAAAA,EAAqB,mBAAmB,CAAA,CAExDA,CAAAA,EAEV,CC1DO,IAAMC,CAAAA,CAAwBJ,CAAAA,EAC5BA,CAAAA,GAAM,IAAA,EAAQA,CAAAA,GAAM,IAAA,EAAQA,CAAAA,GAAM","file":"index.cjs","sourcesContent":["import type { BasePlainObject, DefaultBasePlainObject } from './internal.types';\nimport type { PlainObject } from './plain-object.types';\n\n/**\n * Check if a value is a plain object\n *\n * A plain object is a basic JavaScript object, such as {}, { data: [] }, new Object() or Object.create(null).\n *\n * @example\n * ```typescript\n * import { isPlainObject } from '@httpx/plain-object';\n *\n * // βœ…πŸ‘‡ True\n *\n * isPlainObject({ }); // βœ…\n * isPlainObject({ key: 'value' }); // βœ…\n * isPlainObject({ key: new Date() }); // βœ…\n * isPlainObject(new Object()); // βœ…\n * isPlainObject(Object.create(null)); // βœ…\n * isPlainObject({ nested: { key: true} }); // βœ…\n * isPlainObject(new Proxy({}, {})); // βœ…\n * isPlainObject({ [Symbol('tag')]: 'A' }); // βœ…\n *\n * // βœ…πŸ‘‡ (node context, workers, ...)\n * const runInNewContext = await import('node:vm').then(\n * (mod) => mod.runInNewContext\n * );\n * isPlainObject(runInNewContext('({})')); // βœ…\n *\n * // βŒπŸ‘‡ False\n *\n * class Test { };\n * isPlainObject(new Test()) // ❌\n * isPlainObject(10); // ❌\n * isPlainObject(null); // ❌\n * isPlainObject('hello'); // ❌\n * isPlainObject([]); // ❌\n * isPlainObject(new Date()); // ❌\n * isPlainObject(new Uint8Array([1])); // ❌\n * isPlainObject(Buffer.from('ABC')); // ❌\n * isPlainObject(Promise.resolve({})); // ❌\n * isPlainObject(Object.create({})); // ❌\n * isPlainObject(new (class Cls {})); // ❌\n * isPlainObject(globalThis); // ❌\n *\n * // βœ…πŸ‘‡ Note that static built-in classes are treated as plain objects\n * // check for `isStaticBuiltInClass` to exclude if needed\n *\n * isPlainObject(Math); // βœ…\n * isPlainObject(JSON); // βœ…\n * isPlainObject(Atomics); // βœ…\n * ```\n */\nexport const isPlainObject = <\n TValue extends BasePlainObject = DefaultBasePlainObject,\n>(\n v: unknown\n): v is TValue extends DefaultBasePlainObject\n ? BasePlainObject\n : PlainObject<TValue> => {\n if (v === null || typeof v !== 'object') {\n return false;\n }\n\n const proto = Object.getPrototypeOf(v) as typeof Object.prototype | null;\n return (\n proto === null ||\n proto === Object.prototype ||\n // Required to support node:vm.runInNewContext({})\n Object.getPrototypeOf(proto) === null\n );\n};\n","import type {\n BasePlainObject,\n DefaultBasePlainObject,\n MsgOrErrorFactory,\n} from './internal.types';\nimport { isPlainObject } from './is-plain-object';\nimport type { PlainObject } from './plain-object.types';\n\n/**\n * Assert a value is a plain object\n *\n * @example\n * ```typescript\n * import { assertPlainObject } from '@httpx/plain-object';\n * import type { PlainObject } from '@httpx/plain-object';\n *\n * function fn(value: unknown) {\n *\n * // πŸ‘‡ Throws `new TypeError('Not a plain object')` if not a plain object\n * assertPlainObject(value);\n *\n * // πŸ‘‡ Throws `new TypeError('Custom message')` if not a plain object\n * assertPlainObject(value, 'Custom message');\n *\n * // πŸ‘‡ Throws custom error if not a plain object\n * assertPlainObject(value, () => {\n * throw new HttpBadRequest('Custom message');\n * });\n *\n * return value;\n * }\n *\n * try {\n * const value = fn({ key: 'value' });\n * // βœ… Value is known to be PlainObject<unknown>\n * assertType<PlainObject>(value);\n * } catch (error) {\n * console.error(error);\n * }\n * ```\n *\n * @throws TypeError\n */\nexport function assertPlainObject<\n TValue extends BasePlainObject = DefaultBasePlainObject,\n>(\n v: unknown,\n msgOrErrorFactory?: MsgOrErrorFactory\n): asserts v is TValue extends DefaultBasePlainObject\n ? BasePlainObject\n : PlainObject<TValue> {\n if (!isPlainObject<TValue>(v)) {\n if (\n msgOrErrorFactory === undefined ||\n typeof msgOrErrorFactory === 'string'\n ) {\n throw new TypeError(msgOrErrorFactory ?? `Not a PlainObject`);\n }\n throw msgOrErrorFactory();\n }\n}\n","export type StaticBuiltInClass = Math | JSON | Atomics;\n\nexport const isStaticBuiltInClass = (v: unknown): v is StaticBuiltInClass => {\n return v === Math || v === JSON || v === Atomics;\n};\n"]}

@@ -1,1 +0,1 @@

{"version":3,"sources":["../src/is-plain-object.ts","../src/assert-plain-object.ts","../src/is-static-built-in-class.ts"],"names":["isPlainObject","v","proto","assertPlainObject","msgOrErrorFactory","isStaticBuiltInClass"],"mappings":"AAqDO,IAAMA,CAGXC,CAAAA,CAAAA,EAGyB,CACzB,GAAIA,CAAM,GAAA,IAAA,EAAQ,OAAOA,CAAAA,EAAM,QAC7B,CAAA,OAAO,MAGT,CAAA,IAAMC,CAAQ,CAAA,MAAA,CAAO,cAAeD,CAAAA,CAAC,CACrC,CAAA,OACEC,CAAU,GAAA,IAAA,EACVA,CAAU,GAAA,MAAA,CAAO,SAEjB,EAAA,MAAA,CAAO,cAAeA,CAAAA,CAAK,CAAM,GAAA,IAErC,EC5BO,SAASC,CAGdF,CAAAA,CAAAA,CACAG,CAGsB,CAAA,CACtB,GAAI,CAACJ,CAAsBC,CAAAA,CAAC,CAC1B,CAAA,MACEG,CAAsB,GAAA,MAAA,EACtB,OAAOA,CAAAA,EAAsB,QAEvB,CAAA,IAAI,SAAUA,CAAAA,CAAAA,EAAqB,mBAAmB,CAAA,CAExDA,CAAkB,EAE5B,CC1DO,IAAMC,CAAwBJ,CAAAA,CAAAA,EAC5BA,CAAM,GAAA,IAAA,EAAQA,CAAM,GAAA,IAAA,EAAQA,CAAM,GAAA","file":"index.mjs","sourcesContent":["import type { BasePlainObject, DefaultBasePlainObject } from './internal.types';\nimport type { PlainObject } from './plain-object.types';\n\n/**\n * Check if a value is a plain object\n *\n * A plain object is a basic JavaScript object, such as {}, { data: [] }, new Object() or Object.create(null).\n *\n * @example\n * ```typescript\n * import { isPlainObject } from '@httpx/plain-object';\n *\n * // βœ…πŸ‘‡ True\n *\n * isPlainObject({ }); // βœ…\n * isPlainObject({ key: 'value' }); // βœ…\n * isPlainObject({ key: new Date() }); // βœ…\n * isPlainObject(new Object()); // βœ…\n * isPlainObject(Object.create(null)); // βœ…\n * isPlainObject({ nested: { key: true} }); // βœ…\n * isPlainObject(new Proxy({}, {})); // βœ…\n * isPlainObject({ [Symbol('tag')]: 'A' }); // βœ…\n *\n * // βœ…πŸ‘‡ (node context, workers, ...)\n * const runInNewContext = await import('node:vm').then(\n * (mod) => mod.runInNewContext\n * );\n * isPlainObject(runInNewContext('({})')); // βœ…\n *\n * // βŒπŸ‘‡ False\n *\n * class Test { };\n * isPlainObject(new Test()) // ❌\n * isPlainObject(10); // ❌\n * isPlainObject(null); // ❌\n * isPlainObject('hello'); // ❌\n * isPlainObject([]); // ❌\n * isPlainObject(new Date()); // ❌\n * isPlainObject(new Uint8Array([1])); // ❌\n * isPlainObject(Buffer.from('ABC')); // ❌\n * isPlainObject(Promise.resolve({})); // ❌\n * isPlainObject(Object.create({})); // ❌\n * isPlainObject(new (class Cls {})); // ❌\n * isPlainObject(globalThis); // ❌\n *\n * // βœ…πŸ‘‡ Note that static built-in classes are treated as plain objects\n * // check for `isStaticBuiltInClass` to exclude if needed\n *\n * isPlainObject(Math); // βœ…\n * isPlainObject(JSON); // βœ…\n * isPlainObject(Atomics); // βœ…\n * ```\n */\nexport const isPlainObject = <\n TValue extends BasePlainObject = DefaultBasePlainObject,\n>(\n v: unknown\n): v is TValue extends DefaultBasePlainObject\n ? BasePlainObject\n : PlainObject<TValue> => {\n if (v === null || typeof v !== 'object') {\n return false;\n }\n\n const proto = Object.getPrototypeOf(v) as typeof Object.prototype | null;\n return (\n proto === null ||\n proto === Object.prototype ||\n // Required to support node:vm.runInNewContext({})\n Object.getPrototypeOf(proto) === null\n );\n};\n","import type {\n BasePlainObject,\n DefaultBasePlainObject,\n MsgOrErrorFactory,\n} from './internal.types';\nimport { isPlainObject } from './is-plain-object';\nimport type { PlainObject } from './plain-object.types';\n\n/**\n * Assert a value is a plain object\n *\n * @example\n * ```typescript\n * import { assertPlainObject } from '@httpx/plain-object';\n * import type { PlainObject } from '@httpx/plain-object';\n *\n * function fn(value: unknown) {\n *\n * // πŸ‘‡ Throws `new TypeError('Not a plain object')` if not a plain object\n * assertPlainObject(value);\n *\n * // πŸ‘‡ Throws `new TypeError('Custom message')` if not a plain object\n * assertPlainObject(value, 'Custom message');\n *\n * // πŸ‘‡ Throws custom error if not a plain object\n * assertPlainObject(value, () => {\n * throw new HttpBadRequest('Custom message');\n * });\n *\n * return value;\n * }\n *\n * try {\n * const value = fn({ key: 'value' });\n * // βœ… Value is known to be PlainObject<unknown>\n * assertType<PlainObject>(value);\n * } catch (error) {\n * console.error(error);\n * }\n * ```\n *\n * @throws TypeError\n */\nexport function assertPlainObject<\n TValue extends BasePlainObject = DefaultBasePlainObject,\n>(\n v: unknown,\n msgOrErrorFactory?: MsgOrErrorFactory\n): asserts v is TValue extends DefaultBasePlainObject\n ? BasePlainObject\n : PlainObject<TValue> {\n if (!isPlainObject<TValue>(v)) {\n if (\n msgOrErrorFactory === undefined ||\n typeof msgOrErrorFactory === 'string'\n ) {\n throw new TypeError(msgOrErrorFactory ?? `Not a PlainObject`);\n }\n throw msgOrErrorFactory();\n }\n}\n","export type StaticBuiltInClass = Math | JSON | Atomics;\n\nexport const isStaticBuiltInClass = (v: unknown): v is StaticBuiltInClass => {\n return v === Math || v === JSON || v === Atomics;\n};\n"]}
{"version":3,"sources":["../src/is-plain-object.ts","../src/assert-plain-object.ts","../src/is-static-built-in-class.ts"],"names":["isPlainObject","v","proto","assertPlainObject","msgOrErrorFactory","isStaticBuiltInClass"],"mappings":"AAqDO,IAAMA,CAAAA,CAGXC,CAAAA,EAGyB,CACzB,GAAIA,CAAAA,GAAM,IAAA,EAAQ,OAAOA,CAAAA,EAAM,QAAA,CAC7B,OAAO,MAAA,CAGT,IAAMC,CAAAA,CAAQ,MAAA,CAAO,cAAA,CAAeD,CAAC,CAAA,CACrC,OACEC,CAAAA,GAAU,IAAA,EACVA,CAAAA,GAAU,MAAA,CAAO,SAAA,EAEjB,MAAA,CAAO,cAAA,CAAeA,CAAK,CAAA,GAAM,IAErC,EC5BO,SAASC,CAAAA,CAGdF,CAAAA,CACAG,CAAAA,CAGsB,CACtB,GAAI,CAACJ,CAAAA,CAAsBC,CAAC,CAAA,CAC1B,MACEG,CAAAA,GAAsB,MAAA,EACtB,OAAOA,CAAAA,EAAsB,QAAA,CAEvB,IAAI,SAAA,CAAUA,CAAAA,EAAqB,mBAAmB,CAAA,CAExDA,CAAAA,EAEV,CC1DO,IAAMC,CAAAA,CAAwBJ,CAAAA,EAC5BA,CAAAA,GAAM,IAAA,EAAQA,CAAAA,GAAM,IAAA,EAAQA,CAAAA,GAAM","file":"index.mjs","sourcesContent":["import type { BasePlainObject, DefaultBasePlainObject } from './internal.types';\nimport type { PlainObject } from './plain-object.types';\n\n/**\n * Check if a value is a plain object\n *\n * A plain object is a basic JavaScript object, such as {}, { data: [] }, new Object() or Object.create(null).\n *\n * @example\n * ```typescript\n * import { isPlainObject } from '@httpx/plain-object';\n *\n * // βœ…πŸ‘‡ True\n *\n * isPlainObject({ }); // βœ…\n * isPlainObject({ key: 'value' }); // βœ…\n * isPlainObject({ key: new Date() }); // βœ…\n * isPlainObject(new Object()); // βœ…\n * isPlainObject(Object.create(null)); // βœ…\n * isPlainObject({ nested: { key: true} }); // βœ…\n * isPlainObject(new Proxy({}, {})); // βœ…\n * isPlainObject({ [Symbol('tag')]: 'A' }); // βœ…\n *\n * // βœ…πŸ‘‡ (node context, workers, ...)\n * const runInNewContext = await import('node:vm').then(\n * (mod) => mod.runInNewContext\n * );\n * isPlainObject(runInNewContext('({})')); // βœ…\n *\n * // βŒπŸ‘‡ False\n *\n * class Test { };\n * isPlainObject(new Test()) // ❌\n * isPlainObject(10); // ❌\n * isPlainObject(null); // ❌\n * isPlainObject('hello'); // ❌\n * isPlainObject([]); // ❌\n * isPlainObject(new Date()); // ❌\n * isPlainObject(new Uint8Array([1])); // ❌\n * isPlainObject(Buffer.from('ABC')); // ❌\n * isPlainObject(Promise.resolve({})); // ❌\n * isPlainObject(Object.create({})); // ❌\n * isPlainObject(new (class Cls {})); // ❌\n * isPlainObject(globalThis); // ❌\n *\n * // βœ…πŸ‘‡ Note that static built-in classes are treated as plain objects\n * // check for `isStaticBuiltInClass` to exclude if needed\n *\n * isPlainObject(Math); // βœ…\n * isPlainObject(JSON); // βœ…\n * isPlainObject(Atomics); // βœ…\n * ```\n */\nexport const isPlainObject = <\n TValue extends BasePlainObject = DefaultBasePlainObject,\n>(\n v: unknown\n): v is TValue extends DefaultBasePlainObject\n ? BasePlainObject\n : PlainObject<TValue> => {\n if (v === null || typeof v !== 'object') {\n return false;\n }\n\n const proto = Object.getPrototypeOf(v) as typeof Object.prototype | null;\n return (\n proto === null ||\n proto === Object.prototype ||\n // Required to support node:vm.runInNewContext({})\n Object.getPrototypeOf(proto) === null\n );\n};\n","import type {\n BasePlainObject,\n DefaultBasePlainObject,\n MsgOrErrorFactory,\n} from './internal.types';\nimport { isPlainObject } from './is-plain-object';\nimport type { PlainObject } from './plain-object.types';\n\n/**\n * Assert a value is a plain object\n *\n * @example\n * ```typescript\n * import { assertPlainObject } from '@httpx/plain-object';\n * import type { PlainObject } from '@httpx/plain-object';\n *\n * function fn(value: unknown) {\n *\n * // πŸ‘‡ Throws `new TypeError('Not a plain object')` if not a plain object\n * assertPlainObject(value);\n *\n * // πŸ‘‡ Throws `new TypeError('Custom message')` if not a plain object\n * assertPlainObject(value, 'Custom message');\n *\n * // πŸ‘‡ Throws custom error if not a plain object\n * assertPlainObject(value, () => {\n * throw new HttpBadRequest('Custom message');\n * });\n *\n * return value;\n * }\n *\n * try {\n * const value = fn({ key: 'value' });\n * // βœ… Value is known to be PlainObject<unknown>\n * assertType<PlainObject>(value);\n * } catch (error) {\n * console.error(error);\n * }\n * ```\n *\n * @throws TypeError\n */\nexport function assertPlainObject<\n TValue extends BasePlainObject = DefaultBasePlainObject,\n>(\n v: unknown,\n msgOrErrorFactory?: MsgOrErrorFactory\n): asserts v is TValue extends DefaultBasePlainObject\n ? BasePlainObject\n : PlainObject<TValue> {\n if (!isPlainObject<TValue>(v)) {\n if (\n msgOrErrorFactory === undefined ||\n typeof msgOrErrorFactory === 'string'\n ) {\n throw new TypeError(msgOrErrorFactory ?? `Not a PlainObject`);\n }\n throw msgOrErrorFactory();\n }\n}\n","export type StaticBuiltInClass = Math | JSON | Atomics;\n\nexport const isStaticBuiltInClass = (v: unknown): v is StaticBuiltInClass => {\n return v === Math || v === JSON || v === Atomics;\n};\n"]}
{
"name": "@httpx/plain-object",
"description": "Fast and lightweight utility functions to check if a value is a plain object.",
"version": "2.0.9",
"version": "2.1.0",
"license": "MIT",

@@ -54,4 +54,4 @@ "author": {

"check-dist": "run-s check-dist-esm check-dist-cjs",
"check-dist-cjs": "es-check --not './dist/*.map.js' -v es2022 './dist/**/*.cjs'",
"check-dist-esm": "es-check --not './dist/*.map.js' -v es2022 --module './dist/**/*.mjs'",
"check-dist-cjs": "es-check --not './dist/*.map.js' -v es2023 './dist/**/*.cjs'",
"check-dist-esm": "es-check --not './dist/*.map.js' -v es2023 --module './dist/**/*.mjs'",
"check-pub": "attw --pack && publint",

@@ -75,14 +75,14 @@ "check-size": "size-limit",

"devDependencies": {
"@arethetypeswrong/cli": "0.18.1",
"@belgattitude/eslint-config-bases": "7.0.0",
"@arethetypeswrong/cli": "0.18.2",
"@belgattitude/eslint-config-bases": "7.3.0",
"@httpx/devtools-vitest": "workspace:^",
"@sindresorhus/is": "7.0.1",
"@sindresorhus/is": "7.0.2",
"@size-limit/file": "11.2.0",
"@size-limit/webpack": "11.2.0",
"@types/lodash-es": "4.17.12",
"browserslist": "4.25.0",
"browserslist": "4.25.1",
"browserslist-to-esbuild": "2.1.1",
"cross-env": "7.0.3",
"es-check": "9.1.2",
"es-toolkit": "1.38.0",
"es-check": "9.1.4",
"es-toolkit": "1.39.5",
"esbuild": "0.25.5",

@@ -94,18 +94,17 @@ "eslint": "8.57.1",

"npm-run-all2": "8.0.4",
"prettier": "3.5.3",
"prettier": "3.6.1",
"publint": "0.3.12",
"redux": "5.0.1",
"rimraf": "6.0.1",
"rollup": "4.41.1",
"size-limit": "11.2.0",
"tsup": "8.5.0",
"typedoc": "0.28.5",
"typedoc-plugin-markdown": "4.6.4",
"typedoc-plugin-markdown": "4.7.0",
"typescript": "5.8.3",
"vitest": "3.1.4",
"vitest": "3.2.4",
"webpack": "5.99.9"
},
"engines": {
"node": ">=18"
"node": ">=20.9.0"
}
}

@@ -14,3 +14,3 @@ # @httpx/plain-object

[![bundles](https://img.shields.io/static/v1?label=&message=cjs|esm@treeshake&logo=webpack&style=for-the-badge&labelColor=444&color=informational)](https://github.com/belgattitude/httpx/blob/main/packages/plain-object/.size-limit.cjs)
[![node](https://img.shields.io/static/v1?label=Node&message=18%2b&logo=node.js&style=for-the-badge&labelColor=444&color=informational)](#compatibility)
[![node](https://img.shields.io/static/v1?label=Node&message=20%2b&logo=node.js&style=for-the-badge&labelColor=444&color=informational)](#compatibility)
[![browserslist](https://img.shields.io/static/v1?label=Browser&message=%3E96%25&logo=googlechrome&style=for-the-badge&labelColor=444&color=informational)](#compatibility)

@@ -35,3 +35,3 @@ [![size](https://img.shields.io/bundlephobia/minzip/@httpx/plain-object@latest?label=Max&style=for-the-badge&labelColor=444&color=informational)](https://bundlephobia.com/package/@httpx/plain-object@latest)

- πŸ“&nbsp; Lightweight (starts at [~80B](#bundle-size))
- πŸ›‘οΈ&nbsp; Tested on [node 18-22, browser, cloudflare workers and runtime/edge](#compatibility).
- πŸ›‘οΈ&nbsp; Tested on [node 20-24, browser, cloudflare workers and runtime/edge](#compatibility).
- πŸ™&nbsp; Works cross-realms (node:vm runInNewContext,...)

@@ -241,3 +241,3 @@ - πŸ—οΈ&nbsp; Available in ESM and CJS formats.

|------------|----|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Node | βœ… | CI for 18.x, 20.x & 22.x. |
| Node | βœ… | CI for 20.x, 22.x & 24.x. |
| Browser | βœ… | Tested with latest chrome (vitest/playwright) |

@@ -244,0 +244,0 @@ | Browserslist | βœ… | [> 95%](https://browserslist.dev/?q=ZGVmYXVsdHMsIGNocm9tZSA%2BPSA5NiwgZmlyZWZveCA%2BPSAxMDUsIGVkZ2UgPj0gMTEzLCBzYWZhcmkgPj0gMTUsIGlvcyA%2BPSAxNSwgb3BlcmEgPj0gMTAzLCBub3QgZGVhZA%3D%3D) on 01/2025. [defaults, chrome >= 96, firefox >= 105, edge >= 113, safari >= 15, ios >= 15, opera >= 103, not dead](https://github.com/belgattitude/httpx/blob/main/packages/plain-object/.browserslistrc) |