Registry / devops / mavis
library2.0.0jsnpmunverified

Mavis is a thorough JavaScript type-checking library that returns precise string labels for values, surpassing typeof. Current stable version is 2.0.0 (last released in 2016). It has minimal dependencies and works in both Node.js and browsers. Unlike constructor-based checkers, Mavis uses strings for forward/backward compatibility. It distinguishes between arrays, objects, functions, generators, numbers, strings, errors, HTML elements, and more. Includes a type.is() method for comparisons and array-of-types matching. The library is very lightweight but no longer actively maintained.

npm install mavis
INSTALL
IMPORT
SIG · MAVIS
M
mavis
devopsjavascriptv2.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

type
import mavis from 'mavis'
const { type } = require('mavis');
The default export is the type function. Named import does not work.
type.is
import mavis from 'mavis'; mavis.is('str', 'string');
const mavis = require('mavis'); mavis.is('str', 'string');
Okay for CJS, but no named export; use default import.
mavis (type function)
import m from 'mavis'
import { mavis } from 'mavis'
No named exports exist; import default and rename as you like.

Demonstrates basic type detection for common values and the type.is comparison method.

import mavis from 'mavis'; console.log(mavis({})); // 'object' console.log(mavis([])); // 'array' console.log(mavis(42)); // 'number' console.log(mavis('hello')); // 'string' console.log(mavis(null)); // 'null' console.log(mavis(undefined)); // 'undefined' console.log(mavis(NaN)); // 'NaN' console.log(mavis(Infinity)); // 'infinity' console.log(mavis(new Date())); // 'date' console.log(mavis(/regex/)); // 'RegExp' console.log(mavis(new Error())); // 'error' console.log(mavis(function*(){})); // 'generator' console.log(mavis(Promise.resolve())); // 'promise' console.log(mavis(new Map())); // 'map' console.log(mavis(new Set())); // 'set' console.log(mavis(document)); // 'html' console.log(mavis(window)); // 'global' // type.is() usage console.log(mavis.is('hello', 'string')); // true console.log(mavis.is(5, ['number', 'array'])); // 'number'
Debug
Known issues
deprecatedMavis is no longer actively maintained. Last release was v2.0.0 in 2016.
fix
Consider using alternatives like 'kind-of' or 'which-typed-array' for continued support.
affects: >=0.0.0
gotchaCustom class instances are always returned as 'object', not the constructor name.
fix
Use instanceof or constructor.name if you need the specific type.
affects: >=0.0.0
gotchaThe library uses internal [[Class]] via Object.prototype.toString, which may not work across different realms (e.g., iframes).
fix
For cross-realm type checking, consider using 'kind-of' or similar.
affects: >=0.0.0
gotchaSymbol type returns 'symbol' only in environments supporting ES6; older browsers may return 'object'.
fix
Check Symbol support before relying on symbol detection.
affects: >=0.0.0
Errors
Common errors & fixes
Uncaught TypeError: mavis is not a function
Importing named export instead of default.
fix
Use import mavis from 'mavis' or const mavis = require('mavis').
mavis.is is not a function
Trying to call .is on a different object due to wrong import.
fix
Ensure you have the default export: import m from 'mavis'; then use m.is().
TypeError: Cannot read property 'toString' of undefined
Calling mavis() with no argument or undefined in very old versions.
fix
Make sure your argument is not undefined; mavis() expects a value.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
packagemavis
mavis — npm install mavis · libregistry