- #1546
bdf9e19
Thanks @belgattitude! - Ensure CI tests on Clouflare workers and latest chrome (playwright)
-
#1537
dfb209f
Thanks @belgattitude! - isPlainObject inline behaviour with @httpx/plain-object v2.-
#1530
4e1ecf4
Thanks @belgattitude! - Not 100% compatible with sindreshorsus/is-plain-obj anymoreThe changes shouldn't affect most users, but it's worth noting that the
isPlainObject
function no longer consider static built-in objects as plain objects (Math, JSON, Atomics).This fix an issue with
{ [Symbol.toStringTag]: 'tag' }
that wasn't considered as a plain object.If the behaviour is needed there's a new
isStaticBuiltInClass
function that can be used to check if a value is a static built-in class (Math, JSON, Atomics).Another change to mention is that
isPlainObject
now accepts[Symbol.iterator]
as a valid property for plain objects.const v = { [Symbol.iterator]: function* () { yield 1; }, }; // Since v2 considered as a plain object
Which allows to add iterators to plain objects.
-
#1530
4e1ecf4
Thanks @belgattitude! - Fix issue with plain objects that contains a [Symbol.iterator]isPlainObject
now accepts[Symbol.iterator]
as a valid property for plain objects.const v = { [Symbol.iterator]: function* () { yield 1; }, }; // Since v2 considered as a plain object
Which allows to add iterators to plain objects.
-
#1530
4e1ecf4
Thanks @belgattitude! - Small performance increase@httpx/plain-object: `isPlainObject(v)` - bench/comparative.bench.ts > Compare calling isPlainObject with 110x mixed types values 1.11x faster than (sindresorhus/)is-plain-obj: `isPlainObj(v)` 1.79x faster than @sindresorhus/is: `is.plainObject(v)` 2.29x faster than (jonschlinkert/)is-plain-object: `isPlainObject(v)` 14.66x faster than estoolkit: `isPlainObject(v)` 73.82x faster than lodash-es: `_.isPlainObject(v)`
-
#1530
4e1ecf4
Thanks @belgattitude! - This fix an issue with{ [Symbol.toStringTag]: 'tag' }
that wasn't considered as a plain object. -
#1530
4e1ecf4
Thanks @belgattitude! - Bundle size reduction from 101B to 75B when importing isPlainObject from @httpx/plain-objectOnly { isPlainObject } (ESM) Package size is 1 B less than limit Size limit: 76 B Size: 75 B with all dependencies, minified and brotlied Only { assertPlainObject } (ESM) Package size is 1 B less than limit Size limit: 133 B Size: 132 B with all dependencies, minified and brotlied Import { assertPlainObject, isPlainObject } (ESM) Size: 139 B with all dependencies, minified and brotlied
-
#1530
4e1ecf4
Thanks @belgattitude! - isPlainObject allows static built-in classes: for Atomic, Math, Json.The changes shouldn't affect most users, but it's worth noting that the
isPlainObject
function no longer consider static build-in objects as plain objects (Math, JSON, Atomics).This fix an issue with
{ [Symbol.toStringTag]: 'tag' }
that wasn't considered as a plain object.If the behaviour is needed there's a new
isStaticBuiltInClass
function that can be used to check if a value is a static built-in class (Math, JSON, Atomics).import { isPlainObject, isStaticBuiltInClass } from "@httpx/plain-object"; const v = Math; // or Atomics or JSON if (isPlainObject(v) && !isStaticBuiltInClass(v)) { console.log("v is a plain object but not a static built-in class"); }
-
#1530
4e1ecf4
Thanks @belgattitude! - Change assertPlainObject default message to 'Not a PlainObject'This change the default error message of
assertPlainObject
to 'Not a PlainObject' instead of 'Not a plain object'.
-
- #1523
003cdb3
Thanks @belgattitude! - Align isPlainObject implementation with @httpx/plain-object (speed+, no bc)
- #1434
6bd5105
Thanks @belgattitude! - [internal cleanup] refactor some unions with undefined for optional parameters
-
#1418
366520a
Thanks @belgattitude! - Add INVALID_ARGUMENT reason to assertParsableStrictIsoDateZ -
#1418
366520a
Thanks @belgattitude! - BC getUuidVersion returns null instead of false when the uuid isn't correct
- #1418
366520a
Thanks @belgattitude! - Internal refactor based on linter updates
-
#1369
b39a71c
Thanks @belgattitude! - Add git url prefix in package.json -
#1369
b39a71c
Thanks @belgattitude! - Remove unecessary default condition from exports -
#1369
b39a71c
Thanks @belgattitude! - Add publint after arethetypeswrong checks
- #1275
bd35900
Thanks @belgattitude! - Fix and improve assert documentation README
- #1236
08e61f7
Thanks @belgattitude! - make assertParsableStrictIsoDateZ case insensitive
- #1234
19a5292
Thanks @belgattitude! - isPlainObject properly support node:vm.runInNewContex('({})')
-
#1231
fd2ecd3
Thanks @belgattitude! - Improve PlainObject convenience typings when passing a generic.import { isPlainObject, assertPlainObject } from "@httpx/assert"; type TValue = { key: string; deep: { connected: boolean; }; }; const value = { key: "hello", deep: { connected: true, }, } as unknown; // Without generic assertPlainObject(value); // value is Record<string, unknown> // -> no typing value.key; // unknown, no runtime error value.anything; // unknown, no runtime error // value.deep.connected // not possible without explicit typing // With generic assertPlainObject<TValue>(value); value.key; // unknown, no runtime error value.anything; // unknown, no runtime error value.deep?.connected; // connected is 'unknown', typescript suggest the type
-
#1217
da8474c
Thanks @belgattitude! - @httpx/assert - drop node 16 -
#1217
da8474c
Thanks @belgattitude! - Small perf for isPlainObject and add benchmark -
ad7345f
Thanks @belgattitude! - Drop "official" support for node 16 and typesript < 5
- #1214
226a4b1
Thanks @belgattitude! - isPlainObject allows Object.create(null) and disallow stringTagName and iterators symbols
fd1d0c5
Thanks @belgattitude! - isPlainObject works with partial types
943adcd
Thanks @belgattitude! - Fix type exports for object types
-
#1171
7fdbf08
Thanks @belgattitude! - Add generic convenience typing in isPlainObjectYou can now pass a generic type in isPlainObject and assertPlainObject.
It allows to get typescript autocompletion after running isPlainObject(v). But notice all keys becomes optional and values are set to unknown in this case to reflect that no runtime check was done.
Name Type Comment isPlainObject<T?> PlainObject<T extends Record<string, unknown> = Record<string, unknown>
assertPlainObject<T?> PlainObject<T extends Record<string, unknown> = Record<string, unknown>
import { isPlainObject, assertPlainObject } from "@httpx/assert"; // Simple case: without generic value isPlainObject({ cwol: true }); // 👈 true isPlainObject(new Promise()); // 👈 false assertPlainObject({}); // With generic value (unchecked at runtime!) type CustomType = { name: string; deep: { yes: boolean | null; }; }; const value = { name: "hello", deep: { yes: true, }, } as unknown; if (isPlainObject<CustomType>(value)) { // Notice it's a deep partial to allow autocompletion const test = value?.deep?.yes; // 👈 yes will be unknown (no runtime check) }
- #1167
bfd78a3
Thanks @belgattitude! - Add missing documentation in TOC
- #1157
0d3b113
Thanks @belgattitude! - Add network port and http methods typeguard and assertions
-
#1157
0d3b113
Thanks @belgattitude! - Fix isPlainObject when testing Object.create(null) -
#1157
0d3b113
Thanks @belgattitude! - Fix isNumberSafeInt return
- #1154
6a52be7
Thanks @belgattitude! - Rebuild using esbuild 0.20.2
- #1098
1958776
Thanks @belgattitude! - Add UUID v7 support
-
#885
bfe4861
Thanks @belgattitude! - Return weak opaque type StringNonEmpty from assertStringNonEmpty -
#885
bfe4861
Thanks @belgattitude! - BC: rename assertStrNotEmpty to assertStringNonEmpty
- #885
bfe4861
Thanks @belgattitude! - Fix weak opaque type signature for StringNonEmpty
28687e1
Thanks @belgattitude! - Release with npm provenance
- #877
e329bcd
Thanks @belgattitude! - Add npm provenance to releases
- #875
b6e2941
Thanks @belgattitude! - Update to rollup 4.9.4
- #858
76fd8dc
Thanks @belgattitude! - Release with no changes
- #856
ef4e8c7
Thanks @belgattitude! - Improve documentation
b418b0b
Thanks @belgattitude! - Release unreleased patches
- #852
4dad928
Thanks @belgattitude! - Fix export of empty chunks for type only exports
-
7d399ec
Thanks @belgattitude! - Rename isStrNotEmpty into isStringNonEmpty -
#847
6b3f2d6
Thanks @belgattitude! - Ass weak opaque type support for primitive types -
#837
ff994ff
Thanks @belgattitude! - add assertStrParsableStrictIsoDateZ and isStrParsableStrictIsoDateZ -
7d399ec
Thanks @belgattitude! - Rename isStrParsableSafeInt into isParsableSafeInt -
7d399ec
Thanks @belgattitude! - Rename isArrayNotEmpty into isArrayNonEmpty -
#844
4ccebfe
Thanks @belgattitude! - remove trim parameter from isStrNotEmpty
- #835
b14449f
Thanks @belgattitude! - Improve documentation
- #832
321957a
Thanks @belgattitude! - esbuild updated to 0.19.11 to fix a potential typeScript-specific class transform edge case
-
#829
b3ff1b9
Thanks @belgattitude! - Add assertNumberSafeInt, isNumberSafeInt and NumberSafeInt type -
#829
b3ff1b9
Thanks @belgattitude! - Add isArrayNotEmpty, assertArrayNotEmpty and ArrayNotEmpty type -
#829
b3ff1b9
Thanks @belgattitude! - Add isStrParsableSafeInt, assertStrParsableSafeInt and type StrParsableSafeInt
18aad8b
Thanks @belgattitude! - Add assertNever and assertNeverNoThrow
-
#826
a2f8352
Thanks @belgattitude! - Improve assertion error messages (now typed as TypeError)Assertions errors includes information about received value. They're now typed as native TypeError.
expect(() => assertUuid("123")).toThrow( new TypeError("Value is expected to be an uuid, got: string(3)") ); expect(() => assertUuid(false, undefined, { version: 1 })).toThrow( new TypeError("Value is expected to be an uuid v1, got: boolean(false)") ); expect(() => assertUuidV1(Number.NaN)).toThrow( new TypeError("Value is expected to be an uuid v1, got: NaN") ); expect(() => assertUuidV3(new Error())).toThrow( new TypeError("Value is expected to be an uuid v3, got: Error") ); expect(() => assertUuidV4(new Date())).toThrow( new TypeError("Value is expected to be an uuid v4, got: Date") ); expect(() => assertUuidV5(() => {})).toThrow( new TypeError("Value is expected to be an uuid v5, got: function") );
- #822
24ccdee
Thanks @belgattitude! - Reduce bundle size for esm
- #820
b32e907
Thanks @belgattitude! - Initial @httpx/assert package