TypeScript (JavaScript/TypeScript)
@cratis/fundamentals is the npm package of common utilities, formalizations and abstractions for JavaScript and TypeScript applications, mirroring the .NET Cratis.Fundamentals package.
Overview
Section titled “Overview”The Fundamentals frontend package provides JavaScript/TypeScript equivalents and enhancements to common development patterns and utilities. It includes tools for type management, serialization, field handling, and reactive programming that complement the backend .NET package.
Topics
Section titled “Topics”| Topic | Description |
|---|---|
| ConceptAs | Domain-Driven Design pattern for creating strongly-typed domain identifiers and value objects that wrap primitive types. |
| GUID | GUID creation, manipulation, and utility functions for unique identifiers. |
| Constructor | Runtime constructor type alias for class-based APIs and metadata-driven tooling. |
| PropertyAccessor | Property accessor function type for typed property selection and path utilities. |
| TimeSpan | .NET-compatible time interval parsing, formatting, and JSON serialization. |
| ValueMap | A value-based map for complex object keys with stable lookup semantics. |
| Serialization | Type-safe JSON serialization and deserialization system with polymorphic support and runtime type preservation. |
Installation
Section titled “Installation”To install the package:
npm install @cratis/fundamentalsModule imports
Section titled “Module imports”Use the package root for shared types, or import from @cratis/fundamentals/geospatial,
@cratis/fundamentals/json, and @cratis/fundamentals/reflection. These entry points
work in Node.js ESM, CommonJS, and TypeScript projects using NodeNext or Bundler
module resolution.
import { Guid } from '@cratis/fundamentals';import { Point } from '@cratis/fundamentals/geospatial';
const origin = new Point(0, 0);const id = Guid.empty;