Home

tailwind-ctp-intellisense @master - refs - log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
tailwind-ctp-intellisense / packages / tailwindcss-language-service / src / util / stringToPath.ts
- raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
// https://github.com/lodash/lodash/blob/4.17.15/lodash.js#L6735-L6744
let rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g
let reEscapeChar = /\\(\\)?/g

export function stringToPath(string: string): string[] {
  let result: string[] = []
  if (string.charCodeAt(0) === 46 /* . */) {
    result.push('')
  }
  // @ts-ignore
  string.replace(rePropName, (match, number, quote, subString) => {
    result.push(quote ? subString.replace(reEscapeChar, '$1') : number || match)
  })
  return result
}