Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/rimbu/typical/index.ts>StrNum.Add

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
type alias StrNum.Add
import { type StrNum } from "https://deno.land/x/rimbu@1.1.0/typical/index.ts";
const { Add } = StrNum;

Returns the result of adding the two given string-numbers.

Examples

Example 1

SAdd<'13', '8'> => '21'
SAdd<'139', '5232'> => '5371'

Type Parameters

N1 extends string
N2 extends string
definition: N1 extends Str.Append<infer N1Start, Digit> ? N2 extends Str.Append<infer N2Start, Digit> ? N1 extends Str.Append<N1Start, infer N1LastDigit> ? N2 extends Str.Append<N2Start, infer N2LastDigit> ? AddDigit<N1LastDigit & Digit, N2LastDigit & Digit> extends [infer NewDigit, infer Overflow] ? Overflow extends true ? [N1Start, N2Start] extends ["", ""] ? Str.Append<"1", string & NewDigit> : Str.Append<Add<Add<N1Start, N2Start>, "1">, NewDigit & string> : Str.Append<Add<N1Start, N2Start>, NewDigit & string> : never : never : never : N1 : N2