@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
25 lines (20 loc) • 585 B
JavaScript
import { computePathBase } from "./computePathBase.js";
/**
*
* @param {string} path
* @returns {String|null}
*/
export function computeFileExtension(path) {
const type_of_path = typeof path;
if (type_of_path !== "string") {
throw new Error(`path must be a string, instead was '${type_of_path}'`);
}
const base = computePathBase(path);
const lastDotIndex = base.lastIndexOf('.');
if (lastDotIndex !== -1) {
return base.substring(lastDotIndex + 1);
} else {
//no extension
return null;
}
}