Skip to content

Releases: metreeca/core

v0.9.18

09 Feb 20:45

Choose a tag to compare

Patch release adding type guard combinators, validating casts, and runtime validation utilities.

Added

  • Guard<T> type alias for type guard functions
  • Guarded<G> type alias for extracting guarded types from guard arrays
  • isAny wildcard type guard (always succeeds)
  • isUnion type guard for validating values against multiple guards (union types)
  • isOptional type guard for validating optional values (undefined | T)
  • isLiteral type guard for validating literal values (single or array of literals)
  • isSome type guard for validating Some<T> values (single value or array of values)
  • isLazy type guard for validating Lazy<T> values (plain value or no-arg function)
  • "hierarchical" variant for URI/IRI validation (absolute with /-rooted path, usable as resolution base)
  • Optional is parameter to isArray/asArray for element validation; receives (value, index)
  • Tuple template validation for isArray with exact length matching
  • Optional is parameter to isObject/asObject supporting predicate (value, key) or template validation
  • key symbol for open template validation in isObject
  • assert validation function in error module
  • asIdentifier, asBoolean, asNumber, asString, asArray, asObject validating cast functions
  • immutable(value, guard) overload for type guard validation with memoization
  • IdentifierPattern regex constant for ECMAScript identifier validation
  • TagPattern regex constant for BCP 47 language tag validation
  • TagRangePattern regex constant for BCP 47 extended language range validation

Changed

  • Change isDefined to only check for undefined (no longer excludes null)
  • Rename report module to error
  • Consolidate json module into main index module; import from @metreeca/core instead of @metreeca/core/json
  • Change default variant parameter from "absolute" to "relative" for isURI, isIRI, asURI, asIRI
  • Change isObject type parameter from <K, V> to <T extends Record<PropertyKey, unknown>>
  • Change asTag, asTagRange, asURI, asIRI to accept unknown values (throws TypeError for non-strings)
  • Change immutable to remove setters from accessor properties for true immutability

Removed

  • isScalar type guard (use isBoolean(v) || isNumber(v) || isString(v) instead)

Full Changelog: v0.9.17...v0.9.18

v0.9.17

17 Dec 14:49

Choose a tag to compare

Patch release expanding type utility toolkit with lazy evaluation, unified collection handling,
and enhanced type guards.

Added

  • Some<T> utility type for handling single values or arrays uniformly
  • Lazy<T> utility type enabling deferred value evaluation
  • isRegExp and isDate type guard functions
  • Optional equal parameter in equals() function for custom equality logic

Changed

  • Made name parameter optional within the Namespace type
  • Replaced branded types with plain type aliases to improve runtime validation compatibility

Full Changelog: v0.9.16...v0.9.17