UNPKG

@oazmi/build-tools

Version:

general deno build tool scripts which I practically use in all of my typescript repos

28 lines (27 loc) 862 B
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // This module is browser compatible. import { CHAR_COLON } from "../_common/constants.js"; import { assertPath } from "../_common/assert_path.js"; import { isPathSeparator, isWindowsDeviceRoot } from "./_util.js"; /** * Verifies whether provided path is absolute * @param path to be verified as absolute */ export function isAbsolute(path) { assertPath(path); const len = path.length; if (len === 0) return false; const code = path.charCodeAt(0); if (isPathSeparator(code)) { return true; } else if (isWindowsDeviceRoot(code)) { // Possible device root if (len > 2 && path.charCodeAt(1) === CHAR_COLON) { if (isPathSeparator(path.charCodeAt(2))) return true; } } return false; }