Skip to content

⬅️ Back to Table of Contents

📄 useSpeechRecognition/demo

📊 Analysis Summary

Metric Count
🔧 Functions 2
📦 Imports 3
📊 Variables & Constants 3
🟢 Vue Composition API 3

📚 Table of Contents

🛠️ File Location:

📂 packages/core/useSpeechRecognition/demo.vue

📦 Imports

Name Source
useSpeechRecognition @vueuse/core
shallowRef vue
watch vue

Variables & Constants

Name Type Kind Value Exported
colors string[] let/var ['aqua', 'azure', 'beige', 'bisque', 'black', 'blue', 'brown', 'chocolate', '...
grammar string let/var #JSGF V1.0; grammar colors; public <color> = ${colors.join(' \| ')} ;
sampled boolean let/var shallowRef<string[]>([])

Vue Composition API

Name Type Reactive Variables Composables
watch watch none none
watch watch none none
watch watch none none

Functions

sample(arr: T[], size: number): T[]

Parameters:

  • arr T[]
  • size number

Returns: T[]

Calls:

  • arr.slice
  • Math.floor
  • Math.random
  • shuffled.slice
Code
function sample<T>(arr: T[], size: number) {
  const shuffled = arr.slice(0)
  let i = arr.length
  let temp: T
  let index: number
  while (i--) {
    index = Math.floor((i + 1) * Math.random())
    temp = shuffled[index]
    shuffled[index] = shuffled[i]
    shuffled[i] = temp
  }
  return shuffled.slice(0, size)
}

start(): void

Returns: void

Calls:

  • sample
  • speech.start
Code
function start() {
  color.value = 'transparent'
  sampled.value = sample(colors, 5)
  speech.start()
}

Generated by Syntax Scribe