mirror of
https://github.com/hanzoai/babel.git
synced 2026-09-24 16:56:45 +00:00
16 lines
490 B
JavaScript
16 lines
490 B
JavaScript
import path from "node:path";
|
|
import globals from "globals";
|
|
|
|
export default function generate(filename) {
|
|
const [category, letterCase] = path.basename(filename, ".json").split("-");
|
|
return generateData(category, letterCase);
|
|
}
|
|
|
|
function generateData(category, letterCase) {
|
|
const globalsData = globals[category];
|
|
const filterCondition = letterCase === "upper" ? /^[A-Z]/ : /^[a-z]/;
|
|
return JSON.stringify(
|
|
Object.keys(globalsData).filter(v => filterCondition.test(v))
|
|
);
|
|
}
|