Skip to content

⬅️ Back to Table of Contents

📄 createUnrefFn

📊 Analysis Summary

Metric Count
🔧 Functions 1
📦 Imports 2
📑 Type Aliases 1

📚 Table of Contents

🛠️ File Location:

📂 packages/core/createUnrefFn/index.ts

📦 Imports

Name Source
MaybeRef vue
toValue vue

Functions

createUnrefFn(fn: T): UnrefFn<T>

Make a plain function accepting ref and raw values as arguments. Returns the same value the unconverted function returns, with proper typing.

Tags: @__NO_SIDE_EFFECTS__

Raw JSDoc
/**
 * Make a plain function accepting ref and raw values as arguments.
 * Returns the same value the unconverted function returns, with proper typing.
 *
 * @__NO_SIDE_EFFECTS__
 */

Calls:

  • fn.apply
  • args.map
  • toValue (from vue)
Code
export function createUnrefFn<T extends Function>(fn: T): UnrefFn<T> {
  return function (this: any, ...args: any[]) {
    return fn.apply(this, args.map(i => toValue(i)))
  } as UnrefFn<T>
}

Type Aliases

UnrefFn<T>

type UnrefFn<T> = T extends (...args: infer A) => infer R
  ? (...args: { [K in keyof A]: MaybeRef<A[K]> }) => R
  : never;

Generated by Syntax Scribe