The `present` package, currently at version 1.0.0, provides a unified, cross-environment API for obtaining high-resolution timestamps. It is designed to work in both Node.js, where it leverages `process.hrtime`, and various browser environments, where it attempts to use `performance.now()` and its vendor-prefixed equivalents (`webkitNow`, `msNow`, `mozNow`, `oNow`). If no high-resolution API is available, it gracefully falls back to `Date.now()`. A key differentiator is its automatic polyfilling of `performance.now` in browsers upon script inclusion, though this behavior can be reverted using `present.noConflict()`. The package aims to offer consistent, precise timing for performance measurement or other time-sensitive operations across different JavaScript runtimes. Given its version and the nature of its dependencies (native APIs), it appears to be a stable, low-maintenance utility rather than one with frequent releases, typically publishing updates only when underlying platform APIs change significantly or critical bugs are identified.
npm install presentVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to obtain high-resolution timestamps in Node.js and conceptually shows browser-specific functions like `noConflict` to manage polyfilling.
For Node.js, use `const present = require('present');`. For browsers, load via a `<script>` tag and access the global `present` variable.Call `present.noConflict()` immediately after the script loads if you wish to revert `performance.now` to its original state and manage polyfilling manually or via another library.
Ensure the target environment supports `performance.now()` for critical high-resolution timing. Add checks to verify the precision if absolute accuracy is paramount, e.g., by comparing `present()` output to expected resolution.
No direct fix required for existing code, but be aware that the internal mechanisms might rely on outdated browser APIs. For new projects, consider using `performance.now()` directly if broad polyfill support is not strictly needed for extremely old browsers.
For browsers, load `present.min.js` via a `<script>` tag and access the global `present` variable. For Node.js ESM, consider using a CJS wrapper or an alternative library with ESM support.
In Node.js, ensure you use `const present = require('present');`. In browsers, verify the script tag loaded correctly and `present` is a global function.No dependency data recorded yet.