@yantra-core/sutra
Version:
A JavaScript behavior tree library for easily creating and managing complex behavior patterns in game development.
12 lines • 335 B
JavaScript
export default function parsePath(path) {
return path.split('.').reduce((acc, part) => {
const arrayMatch = part.match(/([^\[]+)(\[\d+\])?/);
if (arrayMatch) {
acc.push(arrayMatch[1]);
if (arrayMatch[2]) {
acc.push(parseInt(arrayMatch[2].replace(/[\[\]]/g, '')));
}
}
return acc;
}, []);
}