like hotscript, but at runtime.
typed utility functions for strings, numbers, tuples, and objects. return types are computed by hotscript under the hood, so you get the same precision you'd expect from type-level transforms, just at runtime.
coldscript is a runtime companion to hotscript. install both:
npm install coldscript hotscripteach module mirrors a hotscript namespace:
import { numbers, objects, strings, tuples } from 'coldscript'import { strings } from 'coldscript'
const parts = strings.split('hello-world', '-')
// ^? ['hello', 'world']
const trimmed = strings.trim(' hi ')
// ^? 'hi'
const joined = strings.prepend('world', 'hello ')
// ^? 'hello world'import { numbers } from 'coldscript'
const sum = numbers.add(1, 2)
// ^? 3
const diff = numbers.sub(10, 3)
// ^? 7import { tuples } from 'coldscript'
const first = tuples.head(['a', 'b', 'c'] as const)
// ^? 'a'
const item = tuples.at(['a', 'b', 'c'] as const, 1)
// ^? 'b'import { objects } from 'coldscript'
const obj = objects.fromEntries([
['a', 1],
['b', 2],
] as const)
// ^? { a: 1, b: 2 }
const merged = objects.assign({ a: 1 }, { b: 2 })
// ^? { a: 1, b: 2 }each function is a thin wrapper around the native js equivalent. the return types come from hotscript's type-level functions via Call, so typescript infers the same results you'd get from using hotscript directly.
// coldscript
export function split<S extends string, TSep extends string>(s: S, sep: TSep) {
return s.split(sep) as Call<Strings.Split<TSep>, S>
}hotscript is a peer dependency — coldscript only provides the runtime implementations, while hotscript supplies the types.