Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

feat: Rune.str #587

Merged
merged 3 commits into from
Feb 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions rune/Rune.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,19 @@ export class Rune<out T, out U = never> {
return value instanceof Rune ? value.into(ValueRune) : Rune.constant(value)
}

static str<X>(strings: TemplateStringsArray, ..._values: RunicArgs<X, unknown[]>) {
const values = RunicArgs.resolve(_values)
return Rune
.tuple(values)
.map((values) =>
strings
.map((templateString, i) => {
return i < values.length ? `${templateString}${values[i]}` : templateString
})
.join("")
)
}

static tuple<R extends unknown[]>(
runes: [...R],
): ValueRune<{ [K in keyof R]: Rune.T<R[K]> }, Rune.U<R[number]>>
Expand Down