UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

22 lines (18 loc) 517 B
import { PATH_SEPARATOR } from "./PATH_SEPARATOR.js"; /** * Strips all directories from the path. * @example 'a/b/c' -> 'c' * @param {string} path * @returns {string} */ export function computePathBase(path) { if (typeof path !== "string") { throw new Error('path is not a string'); } const lastSlashIndex = path.lastIndexOf(PATH_SEPARATOR); if (lastSlashIndex !== -1) { return path.substring(lastSlashIndex + 1); } else { return path; } }