Home

tailwind-ctp-intellisense @86497bb3802ce7f918ff01a474ad78e05e3a2567 - refs - log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
tailwind-ctp-intellisense / packages / tailwindcss-language-service / src / util / array.ts
- raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
export function dedupe<T>(arr: Array<T>): Array<T> {
  return arr.filter((value, index, self) => self.indexOf(value) === index)
}

export function dedupeBy<T>(arr: Array<T>, transform: (item: T) => any): Array<T> {
  return arr.filter((value, index, self) => self.map(transform).indexOf(transform(value)) === index)
}

export function ensureArray<T>(value: T | T[]): T[] {
  return Array.isArray(value) ? value : [value]
}

export function flatten<T>(arrays: T[][]): T[] {
  return [].concat.apply([], arrays)
}

export function equal(a: any[], b: any[]): boolean {
  if (a === b) return true
  if (a.length !== b.length) return false

  let aSorted = a.concat().sort()
  let bSorted = b.concat().sort()

  for (let i = 0; i < aSorted.length; ++i) {
    if (aSorted[i] !== bSorted[i]) return false
  }

  return true
}

export function equalExact(a: any[], b: any[]): boolean {
  if (a === b) return true
  if (a.length !== b.length) return false

  for (let i = 0; i < a.length; ++i) {
    if (a[i] !== b[i]) return false
  }

  return true
}