npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@adaptive-bundle/core

v0.2.0

Published

Lightweight device detection engine — hardware scoring, tier resolution, and caching for adaptive loading. Zero dependencies, ~3KB gzipped.

Readme

@adaptive-bundle/core

Lightweight device detection engine for adaptive loading. Scores device hardware capability, resolves a tier (high | medium | low), and caches the result. Zero dependencies, ~3KB gzipped.

npm

Install

pnpm add @adaptive-bundle/core

Quick Start

import { getDeviceProfile } from '@adaptive-bundle/core';

const profile = getDeviceProfile();
console.log(profile.tier); // 'high' | 'medium' | 'low'
console.log(profile.score); // 0.0 - 1.0

How Scoring Works

Five hardware probes contribute to a composite score (0-1):

| Probe | Weight | Source | | ------------- | ------ | ------------------------------- | | CPU cores | 0.35 | navigator.hardwareConcurrency | | Device memory | 0.35 | navigator.deviceMemory | | GPU tier | 0.15 | WebGL renderer string heuristic | | Screen | 0.10 | Resolution x device pixel ratio | | Touch points | 0.05 | navigator.maxTouchPoints |

Score >= 0.5 is high, < 0.5 is low. Weights redistribute automatically when probes are unavailable.

Fast Path

~70% of devices are classified without full scoring:

  • Data Saver on → low
  • Cached tier (localStorage, 7-day TTL) → reuse
  • deviceMemory <= 2GB → low
  • deviceMemory >= 8GB + 8+ cores → high

Detection completes in < 50ms on any device.

Server-Side Detection

Resolve tier from Client Hints headers without any client-side cost:

import { resolveTierFromHeaders } from '@adaptive-bundle/core/server';

app.use((req, res, next) => {
  const tier = resolveTierFromHeaders(req.headers);
  // Uses Sec-CH-Device-Memory and Sec-CH-UA-Mobile
});

Works in any JS server environment including edge runtimes.

Testing Utilities

import { setForcedTier, clearForcedTier } from '@adaptive-bundle/core/testing';

beforeEach(() => setForcedTier('low'));
afterEach(() => clearForcedTier());

Or via URL parameter: ?adaptive_tier=low

Platform Capabilities

For STB/CTV apps, platformTierMap extends the device map with per-device capabilities:

import { configure, getCapabilities } from '@adaptive-bundle/core';

configure({
  platformTierMap: {
    'sky-q': { tier: 'low', capabilities: ['drm', 'dolby-vision'] },
    'foxtel-iq4': { tier: 'low', capabilities: ['drm', 'hdr10'] },
  },
  detectPlatform: () => detectCurrentPlatform(),
});

// After detection
getCapabilities(); // ['drm', 'dolby-vision'] on sky-q

platformTierMap takes priority over deviceMap. Capabilities are user-defined and used by the Vite plugin for build-time chunk pruning.

API

getDeviceProfile(): DeviceProfile

Returns the full device profile including tier, score, confidence, all probe values, and network info.

getCapabilities(): string[]

Returns the current platform's capabilities from platformTierMap. Empty array when using auto-detection.

resolveTierFromHeaders(headers): Tier

Server-side tier resolution from Client Hints headers.

setForcedTier(tier) / clearForcedTier()

Testing utilities to override detection.

Part of Adaptive Bundle

This is the runtime core of the Adaptive Bundle monorepo. For build-time analysis and chunk splitting, see @adaptive-bundle/vite-plugin. For framework integration, see the React, Vue, or Svelte adapters.

License

MIT