RAS Playground 日本語 GitHub

RAS standard library

Paths (path)

The RAS standard library module that deals only with path strings. It never touches files (it does not check whether they exist). Both \ and / are accepted as separators, and \ is used when joining. It is emitted into the VBA module RAS_Path.

import * as path from "path";

export function outputPath(src: string): string {
    const dir = path.dirname(src);                         // C:\data
    const name = path.basename(src, path.extname(src));    // sales
    return path.join(dir, "out", name + ".csv");           // C:\data\out\sales.csv
}

Reference

Constant path.sep

const sep = "\\"

The path separator (Windows' \).

path.ras

Function path.join

function join(...parts: any[]): string

Joins paths (with one separator between parts; empty parts are skipped). Numbers and other values are converted to strings.

Example: path.join("C:\\data", "2026", "sales.xlsx") → "C:\\data\\2026\\sales.xlsx"

path.ras

Function path.basename

function basename(p: string, ext: string = ""): string

The last part of the path (a file or folder name; a trailing separator is ignored). With ext, it is removed when the name ends with it.

Example: path.basename("C:\\data\\sales.xlsx") → "sales.xlsx", path.basename("C:\\data\\sales.xlsx", ".xlsx") → "sales"

path.ras

Function path.dirname

function dirname(p: string): string

The folder path without the last part ("." when there is no separator).

Example: path.dirname("C:\\data\\sales.xlsx") → "C:\\data", path.dirname("C:\\sales.xlsx") → "C:\\"

path.ras

Function path.extname

function extname(p: string): string

The extension of the last part (from the .; "" if none).

Example: path.extname("sales.2026.xlsx") → ".xlsx", path.extname(".gitignore") → ""

path.ras

Function path.root

function root(p: string): string

The root of the path ("C:\\" for a drive, "\\\\server\\share\\" for a network path, "\\" when it starts with \, "" for a relative path).

Example: path.root("C:\\data\\sales.xlsx") → "C:\\"

path.ras