Composables

useFilter

Source
Locale-aware startsWith/endsWith/contains string matching for search and filter behavior.
Advanced. Primitive-authoring utility from @vyui/core — most app code never calls this directly.

Overview

import { useFilter } from '@vyui/core'

const { startsWith, endsWith, contains } = useFilter()

startsWith('hello', 'he') // true
endsWith('hello', 'lo') // true
contains('hello', 'ell') // true

Prefers Intl.Collator for Unicode-aware comparison, falling back to plain case-insensitive comparison when Intl.Collator throws or isn't usable — the same PrimJS-safety pattern as the i18n composables.

Signature

useFilter(options?: MaybeRef<Intl.CollatorOptions>): { startsWith, endsWith, contains }

Each function normalizes both strings to Unicode NFC first (falling back to the raw string when String.prototype.normalize is unavailable), then compares using the shared collator.