{"id":13063,"library":"default-resolution","title":"Default Resolution Time Utility","description":"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.","status":"active","version":"3.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/gulpjs/default-resolution","tags":["javascript","resolution","timing"],"install":[{"cmd":"npm install default-resolution","lang":"bash","label":"npm"},{"cmd":"yarn add default-resolution","lang":"bash","label":"yarn"},{"cmd":"pnpm add default-resolution","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Internal dependency added in v3.0.0 for node version parsing.","package":"parse-node-version","optional":false}],"imports":[{"note":"The package primarily uses CommonJS. While modern Node.js supports ESM, the package's primary export pattern is CommonJS default.","wrong":"import defaultResolution from 'default-resolution';","symbol":"defaultResolution","correct":"const defaultResolution = require('default-resolution');"},{"note":"When using ES Modules, it's exported as a default. Attempting a named import will fail.","wrong":"import { defaultResolution } from 'default-resolution';","symbol":"defaultResolution","correct":"import defaultResolution from 'default-resolution';"},{"note":"The CommonJS export is a direct module.exports, not an object with named properties.","wrong":"const { defaultResolution } = require('default-resolution');","symbol":"defaultResolution","correct":"const defaultResolution = require('default-resolution');"}],"quickstart":{"code":"import defaultResolution from 'default-resolution'; // For CommonJS: const defaultResolution = require('default-resolution');\n\nconsole.log('--- Demonstrating default-resolution utility ---');\n\n// Get the default resolution based on the current Node.js version.\n// For Node.js v0.10, this would return 1000ms (1 second).\n// For Node.js v0.11 and newer, it returns 1ms (millisecond).\nconst platformResolution = defaultResolution();\nconsole.log(`\\nDetected default resolution for current Node.js version: ${platformResolution}ms`);\n\n// You can optionally override the detected resolution with a custom value.\nconst customResolution = defaultResolution(500);\nconsole.log(`Overridden resolution with custom value (500): ${customResolution}ms`);\n\nconst anotherCustomResolution = defaultResolution(10);\nconsole.log(`Overridden resolution with custom value (10): ${anotherCustomResolution}ms`);\n\nconsole.log('\\nThis utility is useful for tasks that need to adapt their timing behavior');\nconsole.log('based on the underlying Node.js event loop resolution capabilities,');\nconsole.log('or to enforce a specific timing quantum.');","lang":"javascript","description":"Demonstrates how to get the default Node.js event loop resolution and how to override it with a custom value."},"warnings":[{"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`.","message":"Version 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.","severity":"breaking","affected_versions":">=3.0.0"},{"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.","message":"In 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.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Update logic to check for `1` (millisecond) instead of `0`. This change ensures a non-zero, positive resolution value consistently.","message":"Version 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`.","severity":"breaking","affected_versions":">=2.0.0 <3.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"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\"`.","cause":"Attempting to use `require()` in an ES Module context without proper configuration or transpilation.","error":"ReferenceError: require is not defined"},{"fix":"For ESM, use `import defaultResolution from 'default-resolution';`. For CommonJS, use `const defaultResolution = require('default-resolution');`.","cause":"Trying to use `import { defaultResolution } from 'default-resolution';` when the package exports only a default value, or trying to destructure a CommonJS default export.","error":"TypeError: defaultResolution is not a function (or similar for named import)"},{"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`).","cause":"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.","error":"Error: Node.js version 8.x.x is not supported by default-resolution"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":""}