Example: cmd: -r:off
import src/nodejs/jspath requirePath() echo delimiter doAssert basename("/foo/bar/baz".cstring) == "baz".cstring doAssert dirname("/foo/bar/baz/file.ext".cstring) == "/foo/bar/baz".cstring doAssert extname("/foo/bar/baz/file.ext".cstring) == ".ext".cstring doAssert isAbsolute("/foo/bar/baz/file.ext".cstring) doAssert normalize("/foo/bar/baz/file.ext".cstring) == "/foo/bar/baz/file.ext".cstring doAssert normalize("/foo/bar/baz/file.ext".cstring) == "/foo/bar/baz/file.ext".cstring doAssert relative("/foo/bar/baz/file.ext".cstring, "/x/".cstring) == "../../../../x".cstring doAssert resolve("/foo/bar/baz/file.ext".cstring) == "/foo/bar/baz/file.ext".cstring doAssert toNamespacedPath("/foo/bar/baz/file.ext".cstring) == "/foo/bar/baz/file.ext".cstring doAssert join("foo".cstring, "bar".cstring, "file.ext".cstring) == "foo/bar/file.ext".cstring doAssert "folder".cstring / "file.ext".cstring == "folder/file.ext".cstring
Procs
func `/`(path0: cstring; path1: cstring): cstring {.importjs: "path.join(#, #)", ...raises: [], tags: [].}
- Syntax sugar for path.join() that mimics Nim path0 / path1.
func basename(path, ext: cstring): cstring {.importjs: "path.$1(#, #)", ...raises: [], tags: [].}
- https://nodejs.org/api/path.html#path_path_basename_path_ext
func basename(path: cstring): cstring {.importjs: "path.$1(#)", ...raises: [], tags: [].}
- https://nodejs.org/api/path.html#path_path_basename_path_ext
func dirname(path: cstring): cstring {.importjs: "path.$1(#)", ...raises: [], tags: [].}
- https://nodejs.org/api/path.html#path_path_dirname_path
func extname(path: cstring): cstring {.importjs: "path.$1(#)", ...raises: [], tags: [].}
- https://nodejs.org/api/path.html#path_path_extname_path
func importPath() {.importjs: "import * as path from \'path\'@", ...raises: [], tags: [].}
- Alias for import * as module_name from 'module_name';. Must be called once before using the module
func isAbsolute(path: cstring): bool {.importjs: "path.$1(#)", ...raises: [], tags: [].}
- https://nodejs.org/api/path.html#path_path_isabsolute_path
func join(paths: cstring): cstring {.importjs: "path.$1(@)", varargs, ...raises: [], tags: [].}
- https://nodejs.org/api/path.html#path_path_join_paths
func normalize(path: cstring): cstring {.importjs: "path.$1(#)", ...raises: [], tags: [].}
- https://nodejs.org/api/path.html#path_path_normalize_path
func parse(path: cstring): JsObject {.importjs: "path.$1(#)", ...raises: [], tags: [].}
- https://nodejs.org/api/path.html#path_path_parse_path
func relative(to, froom: cstring): cstring {.importjs: "path.$1(#, #)", ...raises: [], tags: [].}
- https://nodejs.org/api/path.html#path_path_relative_from_to
func requirePath() {.importjs: "const path = require(\'path\')@", ...raises: [], tags: [].}
- Alias for const module_name = require('module_name');. Must be called once before using the module
func requirePathPosix() {.importjs: "const path = require(\'path\').posix@", ...raises: [], tags: [].}
- https://nodejs.org/api/path.html#path_windows_vs_posix
func resolve(paths: cstring): cstring {.importjs: "path.$1(@)", varargs, ...raises: [], tags: [].}
- https://nodejs.org/api/path.html#path_path_resolve_paths
func toNamespacedPath(path: cstring): cstring {.importjs: "path.$1(#)", ...raises: [], tags: [].}
- https://nodejs.org/api/path.html#path_path_tonamespacedpath_path