Registry / devops / default-resolution

default-resolution

JSON →
library3.0.0jsnpmunverified

default-resolution is a utility package from the Gulp.js ecosystem designed to determine the default time resolution (e.g., 1 second or 1 millisecond) based on the current Node.js runtime environment. It abstracts away the nuances of event loop timing changes across different Node.js versions, providing a consistent way to get a baseline resolution value. The current stable version is 3.0.0, which dropped support for Node.js versions older than 10.13.0 and refactored its internal `nodeVersion` export. The package provides a simple function that can also be overridden with a custom resolution value. Its release cadence appears to be infrequent, driven by core Node.js compatibility requirements or internal Gulp.js ecosystem needs, rather than a continuous feature stream. Its key differentiator is its singular focus on this specific Node.js timing heuristic, making it a minimal and specialized tool for platform-aware timing.

npm install default-resolution
INSTALL
IMPORT
SIG · DEFAULT-RESOLUTION
D
default-resolution
devopsjavascriptv3.0.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.

defaultResolution
const defaultResolution = require('default-resolution');
import defaultResolution from 'default-resolution';
The package primarily uses CommonJS. While modern Node.js supports ESM, the package's primary export pattern is CommonJS default.
defaultResolution
import defaultResolution from 'default-resolution';
import { defaultResolution } from 'default-resolution';
When using ES Modules, it's exported as a default. Attempting a named import will fail.
defaultResolution
const defaultResolution = require('default-resolution');
const { defaultResolution } = require('default-resolution');
The CommonJS export is a direct module.exports, not an object with named properties.

Demonstrates how to get the default Node.js event loop resolution and how to override it with a custom value.

import defaultResolution from 'default-resolution'; // For CommonJS: const defaultResolution = require('default-resolution'); console.log('--- Demonstrating default-resolution utility ---'); // Get the default resolution based on the current Node.js version. // For Node.js v0.10, this would return 1000ms (1 second). // For Node.js v0.11 and newer, it returns 1ms (millisecond). const platformResolution = defaultResolution(); console.log(`\nDetected default resolution for current Node.js version: ${platformResolution}ms`); // You can optionally override the detected resolution with a custom value. const customResolution = defaultResolution(500); console.log(`Overridden resolution with custom value (500): ${customResolution}ms`); const anotherCustomResolution = defaultResolution(10); console.log(`Overridden resolution with custom value (10): ${anotherCustomResolution}ms`); console.log('\nThis utility is useful for tasks that need to adapt their timing behavior'); console.log('based on the underlying Node.js event loop resolution capabilities,'); console.log('or to enforce a specific timing quantum.');
Debug
Known issues
breakingVersion 3.0.0 dropped support for Node.js versions older than 10.13.0. Running on unsupported versions may lead to errors or unexpected behavior.
fix
Ensure your project's Node.js environment is at least 10.13.0. Update your runtime or specify a compatible engine in your `package.json`.
affects: >=3.0.0
breakingIn v3.0.0, the internal `nodeVersion` export was removed as the package now depends on `parse-node-version`. If you were directly importing `nodeVersion` from `default-resolution`, your code will break.
fix
If `nodeVersion` functionality is needed, consider importing and using `parse-node-version` directly, or refactor your code to not rely on this internal detail.
affects: >=3.0.0
breakingVersion 2.0.0 changed the return value for millisecond resolution from `0` to `1`. If your code explicitly checked for `0` to denote millisecond resolution, it will now incorrectly interpret `1`.
fix
Update logic to check for `1` (millisecond) instead of `0`. This change ensures a non-zero, positive resolution value consistently.
affects: >=2.0.0 <3.0.0
Errors
Common errors & fixes
ReferenceError: require is not defined
Attempting to use `require()` in an ES Module context without proper configuration or transpilation.
fix
If your project is an ES Module, use `import defaultResolution from 'default-resolution';`. If you intend to use CommonJS, ensure your file is `.cjs` or `package.json` specifies `"type": "commonjs"`.
TypeError: defaultResolution is not a function (or similar for named import)
Trying to use `import { defaultResolution } from 'default-resolution';` when the package exports only a default value, or trying to destructure a CommonJS default export.
fix
For ESM, use `import defaultResolution from 'default-resolution';`. For CommonJS, use `const defaultResolution = require('default-resolution');`.
Error: Node.js version 8.x.x is not supported by default-resolution
Running `default-resolution` v3.0.0 or higher on a Node.js version older than 10.13.0, which is outside the supported engine range.
fix
Upgrade your Node.js runtime to version 10.13.0 or newer. Alternatively, if locked to an older Node.js, downgrade `default-resolution` to a compatible major version (e.g., `^2.0.0`).
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies
parse-node-versionrequiredInternal dependency added in v3.0.0 for node version parsing.
Agent activity
2 hits · last 30 days
node
2
Resources
default-resolution — npm install default-resolution · libregistry