2022-07-07 16:26:04 +00:00
|
|
|
import { hash } from 'ohash'
|
2021-10-26 12:59:05 +00:00
|
|
|
|
2024-01-28 21:25:42 +00:00
|
|
|
export { isVue } from '../../../nuxt/src/core/utils/plugins'
|
|
|
|
|
2021-10-26 12:59:05 +00:00
|
|
|
export function uniq<T> (arr: T[]): T[] {
|
|
|
|
return Array.from(new Set(arr))
|
|
|
|
}
|
|
|
|
|
|
|
|
// Copied from vue-bundle-renderer utils
|
2024-05-14 17:54:37 +00:00
|
|
|
const IS_CSS_RE = /\.(?:css|scss|sass|postcss|pcss|less|stylus|styl)(?:\?[^.]+)?$/
|
2021-10-26 12:59:05 +00:00
|
|
|
|
|
|
|
export function isCSS (file: string) {
|
|
|
|
return IS_CSS_RE.test(file)
|
|
|
|
}
|
|
|
|
|
|
|
|
export function hashId (id: string) {
|
|
|
|
return '$id_' + hash(id)
|
|
|
|
}
|
|
|
|
|
2023-06-05 19:15:12 +00:00
|
|
|
export function matchWithStringOrRegex (value: string, matcher: string | RegExp) {
|
|
|
|
if (typeof matcher === 'string') {
|
|
|
|
return value === matcher
|
|
|
|
} else if (matcher instanceof RegExp) {
|
|
|
|
return matcher.test(value)
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
2023-12-23 14:22:58 +00:00
|
|
|
|
2024-04-19 14:58:19 +00:00
|
|
|
/** @since 3.9.0 */
|
2023-12-23 14:22:58 +00:00
|
|
|
export function toArray<T> (value: T | T[]): T[] {
|
|
|
|
return Array.isArray(value) ? value : [value]
|
|
|
|
}
|