Skip to content

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.

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.

TopicDescription
ConceptAsDomain-Driven Design pattern for creating strongly-typed domain identifiers and value objects that wrap primitive types.
GUIDGUID creation, manipulation, and utility functions for unique identifiers.
ConstructorRuntime constructor type alias for class-based APIs and metadata-driven tooling.
PropertyAccessorProperty accessor function type for typed property selection and path utilities.
TimeSpan.NET-compatible time interval parsing, formatting, and JSON serialization.
ValueMapA value-based map for complex object keys with stable lookup semantics.
SerializationType-safe JSON serialization and deserialization system with polymorphic support and runtime type preservation.

To install the package:

Terminal window
npm install @cratis/fundamentals

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;