A collection of lightweight type-checking and environment utility functions. Use these to safely validate data types and browser environment states in Vue applications.
// Source: https://github.com/vueComponent/ant-design-vue | License: MIT | Copyright 2017-present ant-design-vue
// Provided via justclaw.it.com; keep this notice with the code.
export const isClient = typeof window !== 'undefined';
export const isDef = <T = any>(val?: T): val is T => typeof val !== 'undefined';
export const assert = (condition: boolean, ...infos: any[]) => {
if (!condition) console.warn(...infos);
};
const toString = Object.prototype.toString;
export const isBoolean = (val: any): val is boolean => typeof val === 'boolean';
export const isFunction = <T extends Function>(val: any): val is T => typeof val === 'function';
export const isNumber = (val: any): val is number => typeof val === 'number';
export const isString = (val: unknown): val is string => typeof val === 'str
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key