# @denniskrol/device-profiles 中文文档

规范地址：https://npmcn.com/package/%40denniskrol/device-profiles/

版本：1\.20261111\.0
npm 元数据更新时间：2026-11-11T05:48:54.623Z
中文译文更新时间：2026-11-11T22:47:47.785Z
软件包许可：Unlicense

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40denniskrol/device-profiles
原文对照：https://npmcn.com/package/%40denniskrol/device-profiles/?lang=original
项目主页：https://github.com/denniskrol/device-profiles#readme
源码仓库：https://github.com/denniskrol/device-profiles

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：1.6 MB，7 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- Node.js 要求：\>=18
- 运行依赖：0 个
- 首次发布：2025-11-12T12:29:57.233Z
- 最新版本发布：2026-11-11T05:48:54.300Z
- 近 30 天下载量：5018（2026-10-12 至 2026-11-10，npm 官方下载统计）
- 已发布版本数：353（近 12 个月 353 个）

## 中文简介

每日更新浏览器设备配置

## 安装

```sh
npm install @denniskrol/device-profiles
```

也可以使用：`pnpm add @denniskrol/device-profiles`、`yarn add @denniskrol/device-profiles`、`bun add @denniskrol/device-profiles`

## README

# 设备配置文件

[![npm](https://img.shields.io/npm/v/@denniskrol/device-profiles.svg)](https://www.npmjs.com/package/@denniskrol/device-profiles) [![downloads](https://img.shields.io/npm/dm/@denniskrol/device-profiles.svg)](https://www.npmjs.com/package/@denniskrol/device-profiles) [![license](https://img.shields.io/npm/l/@denniskrol/device-profiles.svg)](https://npmcn.com/package/%40denniskrol/device-profiles/LICENSE) [![node](https://img.shields.io/node/v/@denniskrol/device-profiles.svg)](https://npmcn.com/package/%40denniskrol/device-profiles/package.json)

每日更新有加权随机选择的浏览器/设备配置 。 可用于现实的客户端指纹洗刷,测试,负载生成.

数据来自一个网站, 大约65%的移动流量和35%的桌面流量 [浏览器配置器](https://github.com/denniskrol/browser-profiler) 获取数据.

灵感来自 [用户代理](https://github.com/intoli/user-agents) 这似乎不再更新 缺乏一些我需要的数据.

## 安装

```bash
npm install @denniskrol/device-profiles
```

## 基本用途

```ts
import { DeviceProfiles } from '@denniskrol/device-profiles';

// Get a weighted random profile
const profile = new DeviceProfiles();
console.log(profile.userAgent, profile.deviceType);
```

## 已过滤随机

```ts
// Only mobile devices
const mobile = new DeviceProfiles({ deviceType: 'mobile' });

// Regex match browser name
const safari = new DeviceProfiles({ browser: /Safari/ });

// Inclusion list (e.g. mobile OR tablet)
const touch = new DeviceProfiles({ deviceType: ['mobile', 'tablet'] });

// Function predicate (custom logic)
const chromeWithUAData = new DeviceProfiles(profile =>
  profile.userAgent.includes('Chrome') && !!profile.userAgentData
);

// Using static random with predicate
const randomChrome = DeviceProfiles.random(profile =>
  /Chrome/.test(profile.userAgent) && profile.deviceType === 'desktop'
);
```

## 静态助手

```ts
import { DeviceProfiles } from '@denniskrol/device-profiles';

// Get array of all profiles
const all = DeviceProfiles.all();

// Get random with filter without instantiating
const randomDesktop = DeviceProfiles.random({ deviceType: 'desktop' });
```

## 配置示例

```json
{
  "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36",
  "platform": "Win32",
  "deviceMemory": 8,
  "hardwareConcurrency": 8,
  "vendor": "Google Inc.",
  "screenHeight": 720,
  "screenWidth": 1280,
  "viewportHeight": 568,
  "viewportWidth": 1251,
  "devicePixelRatio": 1.5,
  "webglRenderer": "ANGLE (Intel, Intel(R) UHD Graphics (0x00009B41) Direct3D11 vs_5_0 ps_5_0, D3D11)",
  "webglVendor": "Google Inc. (Intel)",
  "webGpuArchitecture": "gen-9",
  "webGpuVendor": "intel",
  "storageQuota": {
    "quota": 113282066841,
    "usage": 0,
    "available": 113282066841
  },
  "jsHeapSizeLimit": 2248146944,
  "fonts": [
    "Aldhabi",
    "Bahnschrift",
    "Cambria Math",
    "Gadugi",
    "HoloLens MDL2 Assets",
    "Ink Free",
    "Javanese Text",
    "Leelawadee UI",
    "Lucida Console",
    "MS Outlook",
    "Myanmar Text",
    "Nirmala UI",
    "Segoe MDL2 Assets",
    "Segoe UI Emoji"
  ],
  "userAgentData": {
    "architecture": "x86",
    "bitness": "64",
    "brands": [
      {
        "brand": "Chromium",
        "version": "142"
      },
      {
        "brand": "Google Chrome",
        "version": "142"
      },
      {
        "brand": "Not_A Brand",
        "version": "99"
      }
    ],
    "fullVersionList": [
      {
        "brand": "Chromium",
        "version": "142.0.7444.134"
      },
      {
        "brand": "Google Chrome",
        "version": "142.0.7444.134"
      },
      {
        "brand": "Not_A Brand",
        "version": "99.0.0.0"
      }
    ],
    "mobile": false,
    "model": null,
    "platform": "Windows",
    "platformVersion": "10.0.0",
    "uaFullVersion": "142.0.7444.134"
  },
  "weight":26,
  "deviceType":"desktop",
  "browser":"Chrome",
  "osName":"Windows"
}
```

## 过滤规则

-   初级平等(deviceType: `'mobile'`(中文(简体) )
-   包含列表( deviceType : `['mobile','tablet']`(中文(简体) )
-   RegExp 匹配( 浏览器 : `/Safari/`(中文(简体) )
-   完全自定义逻辑的函数上游( profile QX布尔)

## 加权选择

每个剖面图都有重量. 随机选择与重量成正比.

## JSON 访问

您也可以导入原始 JSON :

```ts
import profilesJson from '@denniskrol/device-profiles/deviceprofiles.json';
console.log(profilesJson.length);
```

## 许可证

取消许可证

## 常见问题

### @denniskrol/device-profiles 是什么？

每日更新浏览器设备配置

### 如何安装 @denniskrol/device-profiles？

在项目目录运行 npm install @denniskrol/device-profiles，或使用 pnpm add / yarn add / bun add。

### @denniskrol/device-profiles 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @denniskrol/device-profiles 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @denniskrol/device-profiles 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=18。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @denniskrol/device-profiles 可以商用吗？

@denniskrol/device-profiles 使用 Unlicense 许可。作者将代码贡献到公共领域，可不受限制地使用。以上为概括，不构成法律意见，请以许可原文为准。

### @denniskrol/device-profiles 的下载量有多少？

根据 npm 官方下载统计，@denniskrol/device-profiles 在 2026/10/12 – 2026/11/10 这 30 天内被下载 5,018 次，日均约 167 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @denniskrol/device-profiles 还在维护吗？

最新版本 1\.20261111\.0 发布于 2026/11/11（今天）；至今共发布 353 个版本，其中过去 12 个月发布了 353 个；首次发布于 2025/11/12。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

