Registry / testing / x-is-function

x-is-function

JSON →
library1.0.4jsnpmunverified

x-is-function is a minimalist JavaScript utility designed to accurately determine if a given value is of the type 'function'. As of its latest version 1.0.4, published in 2015, the package is considered abandoned, with no active maintenance or release cadence. It provides a single, dependency-free export, `isFunction`, which performs a basic `typeof value === 'function'` check. Its primary differentiation from more comprehensive utility libraries or direct `typeof` checks in modern JavaScript environments is its historical position as part of a family of single-purpose `x-is-...` modules, emphasizing a focused, tiny API surface for specific type checks. Due to its age, it is primarily a CommonJS module.

npm install x-is-function
INSTALL
IMPORT
SIG · X-IS-FUNCTION
X
x-is-function
testingjavascriptv1.0.4
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

isFunction
const isFunction = require('x-is-function');
const { isFunction } = require('x-is-function');
This package is a CommonJS module and exports `isFunction` as its default. Direct named destructuring will not work.
isFunction
import isFunction from 'x-is-function';
import { isFunction } from 'x-is-function';
While usable with ES Modules via bundlers that handle CommonJS interop, the package itself is CJS-only. Named imports will generally fail.
isFunction (browser global)
// Include via <script src="node_modules/x-is-function/index.js"></script> // Then access as `window.isFunction` or `isFunction` if not in strict mode.
For direct browser use without a bundler, the CJS module might attach to `window` or be available in a global scope depending on the build/environment, but it's not explicitly designed for this and may require manual wrapping.

This quickstart demonstrates how to import and use `x-is-function` to check various JavaScript values, including functions, primitives, and objects, confirming its boolean return type.

const isFunction = require('x-is-function'); console.log('--- Testing x-is-function ---'); // Test with a regular function declaration function myDeclaredFunc() {} console.log('Is myDeclaredFunc a function?', isFunction(myDeclaredFunc)); // -> true // Test with an arrow function expression const arrowFunc = () => {}; console.log('Is arrowFunc a function?', isFunction(arrowFunc)); // -> true // Test with a class constructor (which is a function) class MyClass {} console.log('Is MyClass constructor a function?', isFunction(MyClass)); // -> true // Test with non-function types console.log('Is "hello" a function?', isFunction("hello")); // -> false console.log('Is 9 a function?', isFunction(9)); // -> false console.log('Is true a function?', isFunction(true)); // -> false console.log('Is {} a function?', isFunction({})); // -> false console.log('Is null a function?', isFunction(null)); // -> false console.log('Is undefined a function?', isFunction(undefined)); // -> false console.log('Is new Date() a function?', isFunction(new Date())); // -> false // Test with built-in functions console.log('Is Math.random a function?', isFunction(Math.random)); // -> true console.log('Is Array.isArray a function?', isFunction(Array.isArray)); // -> true
Debug
Known issues
deprecatedThe `x-is-function` package has not been updated since 2015 and should be considered abandoned. While its core functionality remains valid, it is unmaintained and may not receive security updates or modern feature compatibility. Consider using native JavaScript `typeof value === 'function'` directly or a more actively maintained utility library.
fix
Prefer `typeof value === 'function'` or use a modern, actively maintained utility library.
affects: >=1.0.0
gotcha`x-is-function` performs a basic `typeof value === 'function'` check. It does not differentiate between different types of functions (e.g., arrow functions, async functions, generator functions, class constructors) nor does it perform more advanced callable object checks. For nuanced type checking, this utility is insufficient.
fix
For specific function types, use more detailed checks like `value instanceof Function` combined with `Object.prototype.toString.call(value)` or specific `instanceof` checks for async/generator functions if available in your environment.
affects: >=1.0.0
gotchaThis package is solely a CommonJS module. While bundlers can typically handle interoperability with ES Modules, directly `import`ing it in a pure ESM Node.js environment without a bundler might lead to issues or require specific loader configurations.
fix
When using in a pure ESM Node.js environment, consider using `await import('x-is-function')` (which dynamically imports CJS) or stick to `typeof` directly. For browser applications, ensure your bundler properly transpiles and resolves CJS modules.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: isFunction is not a function
Attempting to destructure `isFunction` from the `require` call, or incorrect ESM import syntax.
fix
Use `const isFunction = require('x-is-function');` for CommonJS or `import isFunction from 'x-is-function';` for ES Modules (via bundler).
ReferenceError: require is not defined
Attempting to use `require` in a browser environment without a bundler, or in a pure ES Module Node.js script.
fix
For browser usage, use a bundler (like Webpack, Rollup, Parcel) to process the CommonJS module. For pure ESM Node.js, consider `await import('x-is-function')` or rewrite to use `typeof` directly.
Upgrade
Version history
1.0.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
15 hits · last 30 days
node
12
Amazon
1
Resources
x-is-function — npm install x-is-function · libregistry