Registry / observability / present

present

JSON →
library0.6.0jsnpmunverified

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 present
INSTALL
IMPORT
SIG · PRESENT
P
present
observabilityjavascriptv0.6.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

present
✓ const present = require('present');
✗ import present from 'present';
This package is CommonJS only, thus standard ES module imports will not work directly in Node.js or modern browser module environments.
present
✓ // Accessible globally after <script src="path/to/present.min.js"></script>
✗ import { present } from 'present';
In browser environments, 'present' is exposed as a global variable. Attempting ES module imports will fail.
present.noConflict
✓ present.noConflict(); // After importing 'present' (Node) or loading script (Browser)
✗ import { noConflict } from 'present';
Utility methods like 'noConflict' are properties of the main 'present' function/object, not separate named exports.

Demonstrates how to obtain high-resolution timestamps in Node.js and conceptually shows browser-specific functions like `noConflict` to manage polyfilling.

const present = require('present'); // Get a high-resolution timestamp in milliseconds const timestamp1 = present(); console.log('First timestamp:', timestamp1); // Simulate some work for (let i = 0; i < 1e6; i++) { /* busy-wait */ } const timestamp2 = present(); console.log('Second timestamp:', timestamp2); console.log('Elapsed time:', timestamp2 - timestamp1, 'ms'); // Browser-specific functionality (conceptual) // If loaded in a browser via a <script> tag: // console.log('Performance.now before polyfill:', typeof performance.now); // present.noConflict(); // Reverts the polyfill // console.log('Performance.now after noConflict:', typeof performance.now); // present.conflict(); // Re-applies the polyfill // console.log('Performance.now after conflict:', typeof performance.now);
Debug
Known issues
gotchaThis package is CommonJS (CJS) only and does not provide ES module (ESM) exports. Direct `import` statements for `present` will fail in modern Node.js environments configured for ESM or in browser module contexts.
fix
For Node.js, use `const present = require('present');`. For browsers, load via a `<script>` tag and access the global `present` variable.
affects: >=1.0.0
gotchaIn browser environments, `present.js` automatically polyfills `performance.now` upon script inclusion. This default behavior might conflict with other polyfills or if you intend to use the native `performance.now` directly without `present`'s intervention.
fix
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.
affects: >=1.0.0
gotchaThe package falls back to `Date.now()` if `performance.now()` (or its vendor-prefixed variants) are unavailable. This can lead to silently lower precision (millisecond instead of microsecond/nanosecond resolution) on older or less capable platforms, potentially impacting the accuracy of performance measurements.
fix
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.
affects: >=1.0.0
gotchaThe package attempts to use various deprecated `performance.vendorPrefixNow()` methods (e.g., `webkitNow`, `msNow`). While these fallbacks are harmless in modern browsers, relying on them for future compatibility is not recommended, as `performance.now()` is widely standardized.
fix
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.
affects: >=1.0.0
Errors
Common errors & fixes
ReferenceError: require is not defined
Attempting to use `require()` in a browser environment or in a Node.js ESM module.
fix
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.
TypeError: present is not a function
Incorrectly importing or accessing the `present` module/global, often by attempting a named or default ES module import.
fix
In Node.js, ensure you use `const present = require('present');`. In browsers, verify the script tag loaded correctly and `present` is a global function.
Upgrade
Version history
0.6.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
22 hits · last 30 days
node
18
OpenAI (training)
2
Resources