Skip to content

⬅️ Back to Table of Contents

📄 guess

📊 Analysis Summary

Metric Count
🔧 Functions 1

📚 Table of Contents

🛠️ File Location:

📂 packages/core/useStorage/guess.ts

Functions

guessSerializerType(rawInit: T): "number" | "string" | "any" | "set" | "map" | "date" | "boo…

Parameters:

  • rawInit T

Returns: "number" | "string" | "any" | "set" | "map" | "date" | "boolean" | "object"

Calls:

  • Number.isNaN
Code
export function guessSerializerType<T extends(string | number | boolean | object | null)>(rawInit: T) {
  return rawInit == null
    ? 'any'
    : rawInit instanceof Set
      ? 'set'
      : rawInit instanceof Map
        ? 'map'
        : rawInit instanceof Date
          ? 'date'
          : typeof rawInit === 'boolean'
            ? 'boolean'
            : typeof rawInit === 'string'
              ? 'string'
              : typeof rawInit === 'object'
                ? 'object'
                : !Number.isNaN(rawInit)
                    ? 'number'
                    : 'any'
}

Generated by Syntax Scribe