mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 07:05:11 +00:00
docs: add @since
annotations to exported functions (#25365)
This commit is contained in:
parent
a60de743aa
commit
306174c4d8
@ -1,3 +1,4 @@
|
||||
/** @since 3.9.0 */
|
||||
export function toArray<T> (value: T | T[]): T[] {
|
||||
return Array.isArray(value) ? value : [value]
|
||||
}
|
||||
|
@ -233,6 +233,7 @@ export interface CreateOptions {
|
||||
globalName?: NuxtApp['globalName']
|
||||
}
|
||||
|
||||
/** @since 3.0.0 */
|
||||
export function createNuxtApp (options: CreateOptions) {
|
||||
let hydratingCount = 0
|
||||
const nuxtApp: NuxtApp = {
|
||||
@ -349,6 +350,7 @@ export function createNuxtApp (options: CreateOptions) {
|
||||
return nuxtApp
|
||||
}
|
||||
|
||||
/** @since 3.0.0 */
|
||||
export async function applyPlugin (nuxtApp: NuxtApp, plugin: Plugin & ObjectPlugin<any>) {
|
||||
if (plugin.hooks) {
|
||||
nuxtApp.hooks.addHooks(plugin.hooks)
|
||||
@ -363,6 +365,7 @@ export async function applyPlugin (nuxtApp: NuxtApp, plugin: Plugin & ObjectPlug
|
||||
}
|
||||
}
|
||||
|
||||
/** @since 3.0.0 */
|
||||
export async function applyPlugins (nuxtApp: NuxtApp, plugins: Array<Plugin & ObjectPlugin<any>>) {
|
||||
const resolvedPlugins: string[] = []
|
||||
const unresolvedPlugins: [Set<string>, Plugin & ObjectPlugin<any>][] = []
|
||||
@ -413,6 +416,7 @@ export async function applyPlugins (nuxtApp: NuxtApp, plugins: Array<Plugin & Ob
|
||||
if (errors.length) { throw errors[0] }
|
||||
}
|
||||
|
||||
/** @since 3.0.0 */
|
||||
/* @__NO_SIDE_EFFECTS__ */
|
||||
export function defineNuxtPlugin<T extends Record<string, unknown>> (plugin: Plugin<T> | ObjectPlugin<T>): Plugin<T> & ObjectPlugin<T> {
|
||||
if (typeof plugin === 'function') { return plugin }
|
||||
@ -425,6 +429,7 @@ export function defineNuxtPlugin<T extends Record<string, unknown>> (plugin: Plu
|
||||
/* @__NO_SIDE_EFFECTS__ */
|
||||
export const definePayloadPlugin = defineNuxtPlugin
|
||||
|
||||
/** @since 3.0.0 */
|
||||
export function isNuxtPlugin (plugin: unknown) {
|
||||
return typeof plugin === 'function' && NuxtPluginIndicator in plugin
|
||||
}
|
||||
@ -433,6 +438,7 @@ export function isNuxtPlugin (plugin: unknown) {
|
||||
* Ensures that the setup function passed in has access to the Nuxt instance via `useNuxtApp`.
|
||||
* @param nuxt A Nuxt instance
|
||||
* @param setup The function to call
|
||||
* @since 3.0.0
|
||||
*/
|
||||
export function callWithNuxt<T extends (...args: any[]) => any> (nuxt: NuxtApp | _NuxtApp, setup: T, args?: Parameters<T>) {
|
||||
const fn: () => ReturnType<T> = () => args ? setup(...args as Parameters<T>) : setup()
|
||||
@ -450,6 +456,7 @@ export function callWithNuxt<T extends (...args: any[]) => any> (nuxt: NuxtApp |
|
||||
* Returns the current Nuxt instance.
|
||||
*
|
||||
* Returns `null` if Nuxt instance is unavailable.
|
||||
* @since 3.10.0
|
||||
*/
|
||||
export function tryUseNuxtApp (): NuxtApp | null {
|
||||
let nuxtAppInstance
|
||||
@ -467,6 +474,7 @@ export function tryUseNuxtApp (): NuxtApp | null {
|
||||
* Returns the current Nuxt instance.
|
||||
*
|
||||
* Throws an error if Nuxt instance is unavailable.
|
||||
* @since 3.0.0
|
||||
*/
|
||||
export function useNuxtApp (): NuxtApp {
|
||||
const nuxtAppInstance = tryUseNuxtApp()
|
||||
@ -482,6 +490,7 @@ export function useNuxtApp (): NuxtApp {
|
||||
return nuxtAppInstance
|
||||
}
|
||||
|
||||
/** @since 3.0.0 */
|
||||
/* @__NO_SIDE_EFFECTS__ */
|
||||
export function useRuntimeConfig (_event?: H3Event<EventHandlerRequest>): RuntimeConfig {
|
||||
return useNuxtApp().$config
|
||||
@ -491,6 +500,7 @@ function defineGetter<K extends string | number | symbol, V> (obj: Record<K, V>,
|
||||
Object.defineProperty(obj, key, { get: () => val })
|
||||
}
|
||||
|
||||
/** @since 3.0.0 */
|
||||
export function defineAppConfig<C extends AppConfigInput> (config: C): C {
|
||||
return config
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
/** @since 3.9.0 */
|
||||
export function toArray<T> (value: T | T[]): T[] {
|
||||
return Array.isArray(value) ? value : [value]
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ export const wrapInKeepAlive = (props: any, children: any) => {
|
||||
return { default: () => import.meta.client && props ? h(KeepAlive, props === true ? {} : props, children) : children }
|
||||
}
|
||||
|
||||
/** @since 3.9.0 */
|
||||
export function toArray<T> (value: T | T[]): T[] {
|
||||
return Array.isArray(value) ? value : [value]
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { promises as fsp } from 'node:fs'
|
||||
|
||||
/** @since 3.9.0 */
|
||||
export function toArray<T> (value: T | T[]): T[] {
|
||||
return Array.isArray(value) ? value : [value]
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ export function matchWithStringOrRegex (value: string, matcher: string | RegExp)
|
||||
return false
|
||||
}
|
||||
|
||||
/** @since 3.9.0 */
|
||||
export function toArray<T> (value: T | T[]): T[] {
|
||||
return Array.isArray(value) ? value : [value]
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
/** @since 3.9.0 */
|
||||
export function toArray<T> (value: T | T[]): T[] {
|
||||
return Array.isArray(value) ? value : [value]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user