sd-is
Version:
Tiny JavaScript type check utility functions with smart developer-friendly feedback.
10 lines (9 loc) • 344 B
JavaScript
export default function isRegExp(value) {
const ok = Object.prototype.toString.call(value) === '[object RegExp]';
return {
ok,
verdict: ok ? "✅ Value is a RegExp." : "❌ Not a RegExp.",
reason: ok ? null : `Expected a RegExp object, got "${Object.prototype.toString.call(value)}".`,
fix: () => /default/,
};
}