{"library":"present","title":"High-Resolution Timestamps (present)","description":"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.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install present"],"cli":null},"imports":["const present = require('present');","// Accessible globally after <script src=\"path/to/present.min.js\"></script>","present.noConflict(); // After importing 'present' (Node) or loading script (Browser)"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const present = require('present');\n\n// Get a high-resolution timestamp in milliseconds\nconst timestamp1 = present();\nconsole.log('First timestamp:', timestamp1);\n\n// Simulate some work\nfor (let i = 0; i < 1e6; i++) { /* busy-wait */ }\n\nconst timestamp2 = present();\nconsole.log('Second timestamp:', timestamp2);\nconsole.log('Elapsed time:', timestamp2 - timestamp1, 'ms');\n\n// Browser-specific functionality (conceptual)\n// If loaded in a browser via a <script> tag:\n// console.log('Performance.now before polyfill:', typeof performance.now);\n// present.noConflict(); // Reverts the polyfill\n// console.log('Performance.now after noConflict:', typeof performance.now);\n// present.conflict(); // Re-applies the polyfill\n// console.log('Performance.now after conflict:', typeof performance.now);\n","lang":"javascript","description":"Demonstrates how to obtain high-resolution timestamps in Node.js and conceptually shows browser-specific functions like `noConflict` to manage polyfilling.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}