Registry / serialization / ext
library0.1.0jsnpmunverified

The `ext` package, formerly known as `es5-ext`, is a comprehensive JavaScript utility library that provides a collection of non-standard or soon-to-be-standard language extensions and polyfills. It differentiates itself by offering these utilities in a future-proof and non-invasive manner, meaning it generally avoids polluting global prototypes without explicit action, and is designed to be compatible with ES3+ environments without requiring a transpilation step. The library is highly modular, allowing developers to import only the specific functions or objects they need, such as `globalThis`, `Object.clear`, or `String.prototype.camelToHyphen` functionality. While the package has seen recent maintenance releases (e.g., `v0.10.64` in February 2024) addressing stability issues, the latest feature-rich version is `v1.7.0`, released in August 2022. Its release cadence combines frequent bug fixes with less frequent, but impactful, feature additions, ensuring both stability and progressive enhancement capabilities.

npm install ext
INSTALL
IMPORT
SIG · EXT
E
ext
serializationjavascriptv0.1.0
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.

globalThis
import globalThis from 'ext/global-this';
const globalThis = require('ext/global-this');
The `ext` package encourages granular ESM imports for specific utilities. CommonJS `require()` is generally discouraged in modern contexts.
objectClear
import objectClear from 'ext/object/clear';
import { clear } from 'ext/object'; // Incorrect path/named import import objectClear from 'ext/object/clear.js'; // .js extension is usually not needed
Each utility is typically imported from its specific subpath. There is no single top-level 'object' module export for all its methods.
camelToHyphen
import camelToHyphen from 'ext/string/camel-to-hyphen';
import { camelToHyphen } from 'ext/string'; // Incorrect, it's a subpath module import 'ext/string/#/camel-to-hyphen'; // Old `es5-ext` path or direct prototype extension side-effect
For methods that extend prototypes (like String.prototype.camelToHyphen), the library exports the function directly. You can call it with `.call()` or manually extend the prototype if desired, adhering to the 'non-invasive' principle.

Demonstrates importing and using `globalThis`, `objectClear`, `camelToHyphen`, and `identity` utilities. It shows cross-environment `globalThis` access, clearing an object, string case conversion, and a basic identity function.

import globalThis from 'ext/global-this'; import objectClear from 'ext/object/clear'; import camelToHyphen from 'ext/string/camel-to-hyphen'; import identity from 'ext/function/identity'; // Access globalThis reliably across environments console.log('Is this browser globalThis?', typeof window !== 'undefined' && globalThis === window); console.log('Is this Node globalThis?', typeof global !== 'undefined' && globalThis === global); // Clear an object's properties const data = { a: 1, b: 'two', c: true }; console.log('Original object:', data); // { a: 1, b: 'two', c: true } objectClear(data); console.log('Object after clear:', data); // {} // Convert camelCase to hyphen-case const camelCaseString = 'myCamelCaseString'; const hyphenatedString = camelToHyphen.call(camelCaseString); console.log(`'${camelCaseString}' hyphenated: '${hyphenatedString}'`); // 'my-camel-case-string' // Use a simple identity function const value = 42; const transformedValue = identity(value); console.log(`Identity of ${value} is ${transformedValue}`); // 'Identity of 42 is 42'
Debug
Known issues
breakingThe package was renamed from `es5-ext` to `ext`. Users migrating from `es5-ext` will need to update all import paths (e.g., `require('es5-ext/object/clear')` becomes `import objectClear from 'ext/object/clear';`). While `es5-ext` still receives maintenance, `ext` is the officially supported name.
fix
Update all package references and import/require paths in your codebase to use `ext` instead of `es5-ext`. For example, change `import 'es5-ext/array/#/clear'` to `import arrayClear from 'ext/array/clear'` and then use `arrayClear.call(myArray)`.
affects: >=1.0.0 (for `ext` package)
gotchaThe package's `postinstall` script has historically caused issues on various operating systems (Windows, specific Linux terminals, Powershell), potentially leading to installation failures or errors. While recent `0.10.x` releases have focused on patching these, environmental-specific problems may still arise.
fix
Ensure your Node.js and npm installations are up-to-date. If issues persist, try `npm install ext --ignore-scripts`. If a critical setup is missed, consult the official GitHub issues for specific workarounds or report the problem with detailed environment information.
affects: All versions, particularly problematic in `0.10.x` prior to `0.10.64`.
gotchaThe library primarily promotes granular ESM imports (e.g., `import util from 'ext/path/to/util';`). Attempting to use CommonJS `require()` syntax with modern `ext` versions in an ESM-configured project, or assuming a single top-level default export for multiple utilities, will lead to module resolution errors.
fix
Adopt explicit ESM `import` statements for specific utilities from their respective subpaths. Ensure your project is configured to handle ESM imports correctly (e.g., `"type": "module"` in `package.json`).
affects: >=1.0.0
Errors
Common errors & fixes
Command failed with exit code 1
The `postinstall` script, which runs after `npm install`, encountered an error due to environmental factors, shell compatibility, or permissions issues on Windows, Powershell, or certain Linux terminals.
fix
Update Node.js/npm. If the error persists, install with `npm install ext --ignore-scripts`. This bypasses the script but might require manual setup if it performs critical configuration. Consult package GitHub issues for specific workarounds.
TypeError: Cannot read property 'match' of null (or similar regex errors) when using function#toStringTokens()
Older versions of the library relied on problematic regex patterns, particularly affecting methods that parse function definitions, leading to failures with ES2015+ syntax.
fix
Update the `ext` package to at least `v0.10.63` (or the latest `1.x` series) which includes bug fixes for improved regex robustness and better support for modern JavaScript function definitions.
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'ext' imported from ...
This error typically occurs when trying to `import` the package using an incorrect path or if the environment is configured for CommonJS while `ext` is being treated as an ESM module, or vice-versa, specifically for subpath imports.
fix
Verify the exact import path for the specific utility you are trying to use (e.g., `import clear from 'ext/object/clear';`). Ensure your project's module resolution (`package.json#type`) aligns with how you are importing modules.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

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