sc4
Version:
A command line utility for automating SimCity 4 modding tasks & modifying savegames
21 lines (20 loc) • 643 B
JavaScript
import FileClasses from './file-classes.js';
import { FileType } from './enums.js';
// Invert the file types so that we can easily access a constructor by its
// numeric id.
const map = new Map(Object.keys(FileClasses).map((key) => {
let id = FileType[key];
let constructor = FileClasses[key];
return [id, constructor];
}));
export function getConstructorByType(type) {
return map.get(type);
}
export function hasConstructorByType(type) {
return map.has(type);
}
// # isType(object, type)
export function isType(object, type) {
let constructor = getConstructorByType(type);
return object instanceof constructor;
}