mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-28 17:53:15 +00:00
34 lines
802 B
TypeScript
34 lines
802 B
TypeScript
import { hash } from 'ohash'
|
|
|
|
export { isVue } from '../../../nuxt/src/core/utils/plugins'
|
|
|
|
export function uniq<T> (arr: T[]): T[] {
|
|
return Array.from(new Set(arr))
|
|
}
|
|
|
|
// Copied from vue-bundle-renderer utils
|
|
const IS_CSS_RE = /\.(?:css|scss|sass|postcss|pcss|less|stylus|styl)(?:\?[^.]+)?$/
|
|
|
|
export function isCSS (file: string) {
|
|
return IS_CSS_RE.test(file)
|
|
}
|
|
|
|
export function hashId (id: string) {
|
|
return '$id_' + hash(id)
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
/** @since 3.9.0 */
|
|
export function toArray<T> (value: T | T[]): T[] {
|
|
return Array.isArray(value) ? value : [value]
|
|
}
|