UNPKG

@stryke/helpers

Version:

A package containing miscellaneous helper functions that are used across many different Storm Software projects.

2 lines (1 loc) 452 B
const a=/^[\w.]+$/g,E=/\\(?<temp1>\\)?/g,e=new RegExp(`${String.raw`[^.[\]]+`}|${String.raw`\[(?:`}([^"'][^[]*)|${String.raw`(["'])((?:(?!\2)[^\\]|\\.)*?)\2`}${String.raw`)\]`}|${String.raw`(?=(?:\.|\[\])(?:\.|\[\]|$))`}`,"g");export function toPath(t){if(a.test(t))return t.split(".");const n=[];t[0]==="."&&n.push("");const i=t.matchAll(e);for(const r of i){let s=r[0];const o=r[1],g=r[2],c=r[3];g&&c?s=c.replace(E,"$1"):o&&(s=o),n.push(s)}return n}