Skip to content

Commit d6d123f

Browse files
committed
stdlib update
Signed-off-by: George Lemon <[email protected]>
1 parent 580c5ca commit d6d123f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/timpkg/engine/stdlib.nim

+14
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,24 @@ macro initStandardLibrary() =
257257
boolNode.bVal = re.match(args[0].value.sVal, re(args[1].value.sVal))
258258
boolNode
259259

260+
template strStartsWithStream =
261+
let boolNode = ast.newNode(ntLitBool)
262+
if args[1].value.streamContent.kind == JString:
263+
boolNode.bVal = strutils.startsWith(args[0].value.sVal, args[1].value.streamContent.str)
264+
boolNode
265+
266+
template strStreamStartsWith =
267+
let boolNode = ast.newNode(ntLitBool)
268+
if args[0].value.streamContent.kind == JString:
269+
boolNode.bVal = strutils.startsWith(args[0].value.streamContent.str, args[1].value.sVal)
270+
boolNode
271+
260272
let
261273
fnStrings = @[
262274
fwd("endsWith", ntLitBool, [(ntLitString, "s"), (ntLitString, "suffix")]),
263275
fwd("startsWith", ntLitBool, [(ntLitString, "s"), (ntLitString, "prefix")]),
276+
fwd("startsWith", ntLitBool, [(ntLitString, "s"), (ntStream, "prefix")], wrapper = getAst(strStartsWithStream())),
277+
fwd("startsWith", ntLitBool, [(ntStream, "s"), (ntLitString, "prefix")], wrapper = getAst(strStreamStartsWith())),
264278
fwd("capitalizeAscii", ntLitString, [(ntLitString, "s")], "capitalize"),
265279
fwd("replace", ntLitString, [(ntLitString, "s"), (ntLitString, "sub"), (ntLitString, "by")]),
266280
fwd("toLowerAscii", ntLitString, [(ntLitString, "s")], "toLower"),

0 commit comments

Comments
 (0)