Registry / productivity / extant

extant

JSON →
library1.0.21jsnpmunverified

A JavaScript utility that returns the first argument that is not null, functioning similarly to SQL's COALESCE. It works for strings, numbers, booleans, and objects, but treats undefined as null by default. The current stable version is 1.0.21, and the package is in maintenance mode with no active development. It is lightweight and has no dependencies, but lacks TypeScript definitions and does not handle nested null values or functions.

npm install extant
INSTALL
IMPORT
SIG · EXTANT
E
extant
productivityjavascriptv1.0.21
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.

default
import extant from 'extant'
const extant = require('extant')
ESM-only package since v1.0.0; CommonJS require will fail.
extant
import extant from 'extant'
import { extant } from 'extant'
Package exports a single default function, not a named export.
type imports
import type { ExtantOptions } from 'extant'
TypeScript types are not shipped; this import will not work. There is no ExtantOptions type.

Demonstrates basic usage of extant to get the first non-null value, showing that falsy non-null values are preserved.

import extant from 'extant'; const value = extant(null, undefined, 'hello', 'world'); console.log(value); // 'hello' const value2 = extant(0, false, ''); console.log(value2); // 0 (because these are not null) const value3 = extant(null, null, null); console.log(value3); // null
Debug
Known issues
gotchaextant only checks for null, not undefined by default? Actually it treats undefined as null.
fix
Pass undefined as a value; it will be treated as null and ignored.
affects: <=1.0.21
gotchaextant does not handle nested null values inside objects or arrays.
fix
Use a recursive function if you need deep coalescing.
affects: <=1.0.21
gotchaNo TypeScript definitions provided.
fix
Create your own .d.ts file or use @types/extant if available.
affects: <=1.0.21
Errors
Common errors & fixes
Error: Cannot find module 'extant'
Using CommonJS require() on an ESM-only package.
fix
Use import extant from 'extant' or set type: module in package.json.
TypeError: extant is not a function
Using named import { extant } instead of default import.
fix
Use import extant from 'extant' (default import).
Upgrade
Version history
1.0.21latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
35 hits · last 30 days
node
30
OpenAI (training)
1
Resources
packageextant
extant — npm install extant · libregistry