# @ardatan/fast-json-stringify 中文文档

规范地址：https://npmcn.com/package/%40ardatan/fast-json-stringify/

版本：0\.0\.6
npm 元数据更新时间：2023-03-13T16:28:20.659Z
中文译文更新时间：2026-11-06T18:06:16.931Z
软件包许可：MIT

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

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

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

- 包体积（解压后）：312 kB，90 个文件
- 模块格式：CommonJS
- TypeScript 类型：包内自带
- 运行依赖：3 个
- peer 依赖：ajv ^8\.10\.0，ajv-formats ^2\.1\.1
- 首次发布：2023-03-03T14:02:28.363Z
- 最新版本发布：2023-03-13T16:28:20.531Z
- 近 30 天下载量：7134（2026-10-07 至 2026-11-05，npm 官方下载统计）
- 已发布版本数：6（近 12 个月 0 个）

## 中文简介

将您的 JSON 以最大速度字符串

## 安装

```sh
npm install @ardatan/fast-json-stringify
```

也可以使用：`pnpm add @ardatan/fast-json-stringify`、`yarn add @ardatan/fast-json-stringify`、`bun add @ardatan/fast-json-stringify`

## README

# 快速字符串

![CI](https://github.com/fastify/fast-json-stringify/workflows/CI/badge.svg) [![NPM version](https://img.shields.io/npm/v/fast-json-stringify.svg?style=flat)](https://www.npmjs.com/package/fast-json-stringify) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/) [![NPM downloads](https://img.shields.io/npm/dm/fast-json-stringify.svg?style=flat)](https://www.npmjs.com/package/fast-json-stringify)

**快速字符串** 明显快于 `JSON.stringify()` 小有效载荷. 它的性能优势随着有效载荷的增长而收缩. 和他一对 [**平板电脑**](https://www.npmjs.com/package/flatstr),它触发一个 V8 优化,在最终将字符串转换成一个时提高性能 `Buffer`。 。 。 .

### 如何运作

快速 json- 字符串需要一个 [JSON Schema 草案7](https://json-schema.org/specification-links.html#draft-7) 输入生成快 `stringify` 函数.

##### 基准

-   机器 : `EX41S-SSD, Intel Core i7, 4Ghz, 64GB RAM, 4C/8T, SSD`。 。 。 .
-   节点.js `v18.12.1`

```
FJS creation x 4,129 ops/sec ±0.82% (92 runs sampled)
CJS creation x 184,196 ops/sec ±0.12% (97 runs sampled)
AJV Serialize creation x 61,130,591 ops/sec ±0.40% (92 runs sampled)
JSON.stringify array x 5,057 ops/sec ±0.10% (100 runs sampled)
fast-json-stringify array default x 6,243 ops/sec ±0.14% (98 runs sampled)
fast-json-stringify array json-stringify x 6,261 ops/sec ±0.30% (99 runs sampled)
compile-json-stringify array x 6,842 ops/sec ±0.18% (96 runs sampled)
AJV Serialize array x 6,964 ops/sec ±0.11% (95 runs sampled)
JSON.stringify large array x 248 ops/sec ±0.07% (90 runs sampled)
fast-json-stringify large array default x 99.96 ops/sec ±0.22% (74 runs sampled)
fast-json-stringify large array json-stringify x 248 ops/sec ±0.07% (90 runs sampled)
compile-json-stringify large array x 317 ops/sec ±0.09% (89 runs sampled)
AJV Serialize large array x 111 ops/sec ±0.07% (33 runs sampled)
JSON.stringify long string x 16,002 ops/sec ±0.09% (98 runs sampled)
fast-json-stringify long string x 15,979 ops/sec ±0.09% (96 runs sampled)
compile-json-stringify long string x 15,952 ops/sec ±0.31% (97 runs sampled)
AJV Serialize long string x 21,416 ops/sec ±0.08% (98 runs sampled)
JSON.stringify short string x 12,944,272 ops/sec ±0.09% (96 runs sampled)
fast-json-stringify short string x 30,585,790 ops/sec ±0.27% (97 runs sampled)
compile-json-stringify short string x 30,656,406 ops/sec ±0.12% (96 runs sampled)
AJV Serialize short string x 30,406,785 ops/sec ±0.37% (96 runs sampled)
JSON.stringify obj x 3,153,043 ops/sec ±0.33% (99 runs sampled)
fast-json-stringify obj x 6,866,434 ops/sec ±0.11% (100 runs sampled)
compile-json-stringify obj x 15,886,723 ops/sec ±0.15% (98 runs sampled)
AJV Serialize obj x 8,969,043 ops/sec ±0.36% (97 runs sampled)
JSON stringify date x 1,126,547 ops/sec ±0.09% (97 runs sampled)
fast-json-stringify date format x 1,836,188 ops/sec ±0.12% (99 runs sampled)
compile-json-stringify date format x 1,125,735 ops/sec ±0.19% (98 runs sampled)
```

#### 目录 :

-   [`Example`](https://npmcn.com/package/%40ardatan/fast-json-stringify/#readme-example)
-   [`Options`](https://npmcn.com/package/%40ardatan/fast-json-stringify/#readme-options)
-   [`API`](https://npmcn.com/package/%40ardatan/fast-json-stringify/#readme-api)
-   [`fastJsonStringify`](https://npmcn.com/package/%40ardatan/fast-json-stringify/#readme-fastJsonStringify)
-   [`Specific use cases`](https://npmcn.com/package/%40ardatan/fast-json-stringify/#readme-specific)
-   [`Required`](https://npmcn.com/package/%40ardatan/fast-json-stringify/#readme-required)
-   [`Missing fields`](https://npmcn.com/package/%40ardatan/fast-json-stringify/#readme-missingFields)
-   [`Pattern Properties`](https://npmcn.com/package/%40ardatan/fast-json-stringify/#readme-patternProperties)
-   [`Additional Properties`](https://npmcn.com/package/%40ardatan/fast-json-stringify/#readme-additionalProperties)
-   [`AnyOf` 财务报告和审定财务报表 `OneOf`](https://npmcn.com/package/%40ardatan/fast-json-stringify/#readme-AnyOf-and-OneOf)
-   [`Reuse - $ref`](https://npmcn.com/package/%40ardatan/fast-json-stringify/#readme-ref)
-   [`Long integers`](https://npmcn.com/package/%40ardatan/fast-json-stringify/#readme-long)
-   [`Integers`](https://npmcn.com/package/%40ardatan/fast-json-stringify/#readme-integer)
-   [`Nullable`](https://npmcn.com/package/%40ardatan/fast-json-stringify/#readme-nullable)
-   [`Large Arrays`](https://npmcn.com/package/%40ardatan/fast-json-stringify/#readme-largearrays)
-   [`Security Notice`](https://npmcn.com/package/%40ardatan/fast-json-stringify/#readme-security)
-   [`Debug Mode`](https://npmcn.com/package/%40ardatan/fast-json-stringify/#readme-debug)
-   [`Acknowledgements`](https://npmcn.com/package/%40ardatan/fast-json-stringify/#readme-acknowledgements)
-   [`License`](https://npmcn.com/package/%40ardatan/fast-json-stringify/#readme-license)

在 RunKit 上试试: [https://runkit.com/npm/快活-json-stringify (中文(简体) )](https://runkit.com/npm/fast-json-stringify)

## 示例

```js
const fastJson = require('fast-json-stringify')
const stringify = fastJson({
  title: 'Example Schema',
  type: 'object',
  properties: {
    firstName: {
      type: 'string'
    },
    lastName: {
      type: 'string'
    },
    age: {
      description: 'Age in years',
      type: 'integer'
    },
    reg: {
      type: 'string'
    }
  }
})

console.log(stringify({
  firstName: 'Matteo',
  lastName: 'Collina',
  age: 32,
  reg: /"([^"]|\\")*"/
}))
```

## 选项

你可以选择提供 `fast-json-stringify` 作为第二个参数的选项对象:

```js
const fastJson = require('fast-json-stringify')
const stringify = fastJson(mySchema, {
  schema: { ... },
  ajv: { ... },
  rounding: 'ceil'
})
```

-   `schema`: 按美元属性分类的外部参考计划. [更多细节](https://npmcn.com/package/%40ardatan/fast-json-stringify/#readme-ref)
-   `ajv`数字 : [ajv v8 实例设置](https://ajv.js.org/options.html) 对于需要 `ajv`。 。 。 . [更多细节](https://npmcn.com/package/%40ardatan/fast-json-stringify/#readme-anyof)
-   `rounding`: 如何设置 `integer` 类型将在非整数时四舍五入. [更多细节](https://npmcn.com/package/%40ardatan/fast-json-stringify/#readme-integer)
-   `largeArrayMechanism`: 设置用于处理大型 (默认) `20000` 或更多项)数组. [更多细节](https://npmcn.com/package/%40ardatan/fast-json-stringify/#readme-largearrays)

## API 密码

### 快速 JsonStringify (schema) (英语)

构建一个 `stringify()` 基于 [jsonschema 草稿 7 spec](https://json-schema.org/specification-links.html#draft-7)。 。 。 .

支持类型 :

-   `'string'`
-   `'integer'`
-   `'number'`
-   `'array'`
-   `'object'`
-   `'boolean'`
-   `'null'`

并入巢者也.

#### 具体使用案例

| 实例 | 序列为 |
| --- | --- |
| `Date` | `string` 通过 `toISOString()` |
| `RegExp` | `string` |
| `BigInt` | `integer` 通过 `toString` |

[JSON Schema 内置格式](https://json-schema.org/understanding-json-schema/reference/string.html#built-in-formats) 日期将按下列顺序排列:

| 格式 | 序列化格式示例 |
| --- | --- |
| `date-time` | `2020-04-03T09:11:08.615Z` |
| `date` | `2020-04-03` |
| `time` | `09:11:08` |

**说明**:如果字符串格式化了日期而不是日期对象,则不会对其进行操纵. 报告的格式应适当.

带有日期对象的示例:

```javascript
const stringify = fastJson({
  title: 'Example Schema with string date-time field',
  type: 'string',
  format: 'date-time'
})

const date = new Date()
console.log(stringify(date)) // '"YYYY-MM-DDTHH:mm:ss.sssZ"'
```

#### 需求

您可以通过在图中添加字段名称来设置对象的特定字段 `required` 阵列在您的计划中. 示例

```javascript
const schema = {
  title: 'Example Schema with required field',
  type: 'object',
  properties: {
    nickname: {
      type: 'string'
    },
    mail: {
      type: 'string'
    }
  },
  required: ['mail']
}
```

如果字符串对象缺少所需的字段, `fast-json-stringify` 将投出一个错误.

#### 缺少字段

如果一个字段 _当前_ 在计谋中 _不存在_ 在要字符串的对象中, `fast-json-stringify` 将不会将其写入最后字符串. 示例

```javascript
const stringify = fastJson({
  title: 'Example Schema',
  type: 'object',
  properties: {
    nickname: {
      type: 'string'
    },
    mail: {
      type: 'string'
    }
  }
})

const obj = {
  mail: 'mail@example.com'
}

console.log(stringify(obj)) // '{"mail":"mail@example.com"}'
```

#### 默认

`fast-json-stringify` 支持 `default` 用于序列化值的 jsonschema 密钥 如果是的话 `undefined` 或者不在场.

示例

```javascript
const stringify = fastJson({
  title: 'Example Schema',
  type: 'object',
  properties: {
    nickname: {
      type: 'string',
      default: 'the default string'
    }
  }
})

console.log(stringify({})) // '{"nickname":"the default string"}'
console.log(stringify({nickname: 'my-nickname'})) // '{"nickname":"my-nickname"}'
```

#### 图案属性

`fast-json-stringify` 支持JSON schema定义的图案属性. _特性_ 必须是对象,如果密钥是有效的正则克并值是对象,则以这种方式声明: `{ type: 'type' }`。 。 。 . _特性_ 将只对属性对象中未明确列出的属性工作. 示例

```javascript
const stringify = fastJson({
  title: 'Example Schema',
  type: 'object',
  properties: {
    nickname: {
      type: 'string'
    }
  },
  patternProperties: {
    'num': {
      type: 'number'
    },
    '.*foo$': {
      type: 'string'
    }
  }
})

const obj = {
  nickname: 'nick',
  matchfoo: 42,
  otherfoo: 'str',
  matchnum: 3
}

console.log(stringify(obj)) // '{"matchfoo":"42","otherfoo":"str","matchnum":3,"nickname":"nick"}'
```

#### 其他属性

`fast-json-stringify` 支持 JSON schema 定义的其他属性. _额外收益_ 必须是物体或布尔,以这种方式声明: `{ type: 'type' }`。 。 。 . _额外收益_ 将只为未明确列出的属性工作 _属性_ 财务报告和审定财务报表 _特性_ 对象.

若为 _额外收益_ 不存在或设置为 `false`,其中未明确列出的所有财产 _属性_ 财务报告和审定财务报表 _特性_ 如 [缺少字段](https://npmcn.com/package/%40ardatan/fast-json-stringify/#readme-missingFields)。 。 。 . 缺失的字段被忽略,以避免在序列化前需要重写对象. 然而,其他规则也会在类似情况下适用. 若为 _额外收益_ 设置为 `true`,它将被使用 `JSON.stringify` 来字符串附加属性。 如果你想达到最大性能 我们强烈鼓励你尽可能使用固定的策略. 附加属性总是会被序列化于对象的末尾. 示例

```javascript
const stringify = fastJson({
  title: 'Example Schema',
  type: 'object',
  properties: {
    nickname: {
      type: 'string'
    }
  },
  patternProperties: {
    'num': {
      type: 'number'
    },
    '.*foo$': {
      type: 'string'
    }
  },
  additionalProperties: {
    type: 'string'
  }
})

const obj = {
  nickname: 'nick',
  matchfoo: 42,
  otherfoo: 'str',
  matchnum: 3,
  nomatchstr: 'valar morghulis',
  nomatchint: 313
}

console.log(stringify(obj)) // '{"nickname":"nick","matchfoo":"42","otherfoo":"str","matchnum":3,"nomatchstr":"valar morghulis",nomatchint:"313"}'
```

#### 任意和唯一

`fast-json-stringify` 支持 **任何一个** 财务报告和审定财务报表 **其中一个** jSON schema定义的关键词. 两者必须是一系列有效的JSON计划. 不同的计划会按指定的顺序进行测试. 计划越多 `stringify` 在找到火柴之前必须先试试 速度越慢.

_任何一个_ 财务报告和审定财务报表 _其中一个_ 使用情况 [页:1](https://www.npmjs.com/package/ajv) 作为 JSON 的 schema 验证器,用于找到匹配数据的 schema 。 这对业绩有影响——仅作为最后手段使用.

示例

```javascript
const stringify = fastJson({
  title: 'Example Schema',
  type: 'object',
  properties: {
    'undecidedType': {
      'anyOf': [{
    type: 'string'
      }, {
    type: 'boolean'
      }]
    }
  }
})
```

指定对象 JSON 计划时 _任何一个_,添加 _所需经费_ 验证关键字,只匹配对象与您想要的属性.

示例

```javascript
const stringify = fastJson({
  title: 'Example Schema',
  type: 'array',
  items: {
    anyOf: [
      {
        type: 'object',
        properties: {
          savedId: { type: 'string' }
        },
        // without "required" validation any object will match
        required: ['savedId']
      },
      {
        type: 'object',
        properties: {
          error: { type: 'string' }
        },
        required: ['error']
      }
    ]
  }
})
```

#### 如果/当时/过去

`fast-json-stringify` 支持 `if/then/else` jsonschema 特性。 见 [ajv 文档](https://ajv.js.org/keywords.html#ifthenelse)。 。 。 .

示例

```javascript
const stringify = fastJson({
  'type': 'object',
  'properties': {
  },
  'if': {
    'properties': {
      'kind': { 'type': 'string', 'enum': ['foobar'] }
    }
  },
  'then': {
    'properties': {
      'kind': { 'type': 'string', 'enum': ['foobar'] },
      'foo': { 'type': 'string' },
      'bar': { 'type': 'number' }
    }
  },
  'else': {
    'properties': {
      'kind': { 'type': 'string', 'enum': ['greeting'] },
      'hi': { 'type': 'string' },
      'hello': { 'type': 'number' }
    }
  }
})

console.log(stringify({
  kind: 'greeting',
  foo: 'FOO',
  bar: 42,
  hi: 'HI',
  hello: 45
})) // {"kind":"greeting","hi":"HI","hello":45}
console.log(stringify({
  kind: 'foobar',
  foo: 'FOO',
  bar: 42,
  hi: 'HI',
  hello: 45
})) // {"kind":"foobar","foo":"FOO","bar":42}
```

**编号** 不要声明属性两次 否则你会打印两次!

#### 重新使用 - 美元调整

如果您想要重用一个值的定义, 您可以使用属性 `$ref`。 。 。 . 价值 `$ref` 必须是字符串在 [JSON 指针](https://tools.ietf.org/html/rfc6901) 格式. 示例

```javascript
const schema = {
  title: 'Example Schema',
  definitions: {
    num: {
      type: 'object',
      properties: {
        int: {
          type: 'integer'
        }
      }
    },
    str: {
      type: 'string'
    }
  },
  type: 'object',
  properties: {
    nickname: {
      $ref: '#/definitions/str'
    }
  },
  patternProperties: {
    'num': {
      $ref: '#/definitions/num'
    }
  },
  additionalProperties: {
    $ref: '#/definitions/def'
  }
}

const stringify = fastJson(schema)
```

如果需要使用外部定义,可以把它作为选择 `fast-json-stringify`。 。 。 . 示例

```javascript
const schema = {
  title: 'Example Schema',
  type: 'object',
  properties: {
    nickname: {
      $ref: 'strings#/definitions/str'
    }
  },
  patternProperties: {
    'num': {
      $ref: 'numbers#/definitions/num'
    }
  },
  additionalProperties: {
    $ref: 'strings#/definitions/def'
  }
}

const externalSchema = {
  numbers: {
    definitions: {
      num: {
        type: 'object',
        properties: {
          int: {
            type: 'integer'
          }
        }
      }
    }
  },
  strings: require('./string-def.json')
}

const stringify = fastJson(schema, { schema: externalSchema })
```

外部定义也可以相互参照. 示例

```javascript
const schema = {
  title: 'Example Schema',
  type: 'object',
  properties: {
    foo: {
      $ref: 'strings#/definitions/foo'
    }
  }
}

const externalSchema = {
  strings: {
    definitions: {
      foo: {
        $ref: 'things#/definitions/foo'
      }
    }
  },
  things: {
    definitions: {
      foo: {
        type: 'string'
      }
    }
  }
}

const stringify = fastJson(schema, { schema: externalSchema })
```

#### 长整数

默认情况下, 库会自动处理 [大点](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt)。 。 。 .

#### 整数

这个 `type: integer` 如果提供了浮动点,则属性将被截断. 您可以自定义此行为 `rounding` 选项 [`round`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round), (中文(简体) ), [`ceil`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil), (中文(简体) ), [`floor`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor) 或者说 [`trunc`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc)默认为 `trunc`数字 :

```js
const stringify = fastJson(schema, { rounding: 'ceil' })
```

#### 无效

根据 [打开 API 3.0 规格](https://swagger.io/docs/specification/data-models/data-types/#null),必须宣布无效值 `nullable`。 。 。 .

##### 可忽略对象

```javascript
const stringify = fastJson({
  'title': 'Nullable schema',
  'type': 'object',
  'nullable': true,
  'properties': {
    'product': {
      'nullable': true,
      'type': 'object',
      'properties': {
        'name': {
          'type': 'string'
        }
      }
    }
  }
})

console.log(stringify({product: {name: "hello"}})) // "{"product":{"name":"hello"}}"
console.log(stringify({product: null})) // "{"product":null}"
console.log(stringify(null)) // null
```

否则,无效值将不但没有引起错误,反而被胁迫如下:

-   `integer` - > (中文) `0`
-   `number` - > (中文) `0`
-   `string` - > (中文) `""`
-   `boolean` - > (中文) `false`

#### 大阵列

大型阵列在本文档范围内被定义为包含:, 默认, `20000` 元素或更多元素。 该值可通过选项调整 参数 `largeArraySize`。 。 。 .

在某个时候,由于使用默认机制造成的间接费用 `fast-json-stringify` 来处理数组开始指数化增长,引导 以减缓总体处决.

##### 设置

为了改进用户设置 `largeArrayMechanism` 财务报告和审定财务报表 `largeArraySize` 选项.

`largeArrayMechanism`默认值为 `default`有效的数值是:

-   `default` - 这个选项是业绩和功能之间的折衷办法,由 仍然提供预期的功能 可能的性能收益。 有了这个选项, **大阵列** 这将是 通过加入其使用字符串的元素而字符串化 `Array.join` 改为 更好性能的字符串连接
-   `json-stringify` - 此选项将删除对计划验证的支持 在内部 **大阵列** 完全没有。 这样做之前的间接费用 提及无效,大大改善了执行时间。 注意没有变化 在未考虑的数组的行为中 _大块_

`largeArraySize`默认值为 `20000`有效数值 等整数:

-   `20000`
-   `2e4`
-   `'20000'`
-   `'2e4'` - 说吧 _注意此选项将转换为 `2`没有 `20000`_
-   `1.5` - 说吧 _注意此选项将转换为 `1`_

##### 基准

供参考的是,现提出一些基准,用于与这三个基准进行比较 机制。 以旧机器为基准.

-   机器 : `ST1000LM024 HN-M 1TB HDD, Intel Core i7-3610QM @ 2.3GHz, 12GB RAM, 4C/8T`。 。 。 .
-   节点.js `v16.13.1`

```
JSON.stringify large array x 157 ops/sec ±0.73% (86 runs sampled)
fast-json-stringify large array default x 48.72 ops/sec ±4.92% (48 runs sampled)
fast-json-stringify large array json-stringify x 157 ops/sec ±0.76% (86 runs sampled)
compile-json-stringify large array x 175 ops/sec ±4.47% (79 runs sampled)
AJV Serialize large array x 58.76 ops/sec ±4.59% (60 runs sampled)
```

## 担保通知

将计划定义作为应用程序代码, 它 无法使用用户提供的策略.

实现低成本和高性能的校正 `fast-json-stringify` 创建和编译函数(使用 `Function` (原始内容存档于2019-03-28). resources. instructionor) on signation. 虽然 `schema` 正在验证任何开发者错误, 无法保证无法提供用户生成的计划 让你的应用程序暴露在远程攻击中.

用户负责发送可信赖的数据. `fast-json-stringify` 保证你将得到 有效的输出,但输入必须符合计划或者可以被强制用于计划。 如果输入 不符合计划,你会得到未定义的行为.

### 调试模式

调试模式可以在您的开发过程中被激活, 以了解当事物不发生时会发生什么 工作如所期望的那样.

```js
const debugCompiled = fastJson({
  title: 'default string',
  type: 'object',
  properties: {
    firstName: {
      type: 'string'
    }
  }
}, { mode: 'debug' })

console.log(debugCompiled) // it is a object contain code, ajv instance
const rawString = debugCompiled.code // it is the generated code
console.log(rawString) 

const stringify = fastJson.restore(debugCompiled) // use the generated string to get back the `stringify` function
console.log(stringify({ firstName: 'Foo', surname: 'bar' })) // '{"firstName":"Foo"}'
```

## 鸣谢

这个项目由下列各方慷慨赞助: [临近格式](https://nearform.com/)。 。 。 .

## 许可证

麻省理工学院

## 常见问题

### @ardatan/fast-json-stringify 是什么？

将您的 JSON 以最大速度字符串

### 如何安装 @ardatan/fast-json-stringify？

在项目目录运行 npm install @ardatan/fast-json-stringify，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：ajv（^8\.10\.0）、ajv-formats（^2\.1\.1）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @ardatan/fast-json-stringify 支持 TypeScript 吗？

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

### @ardatan/fast-json-stringify 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @ardatan/fast-json-stringify 可以商用吗？

@ardatan/fast-json-stringify 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @ardatan/fast-json-stringify 的下载量有多少？

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

### @ardatan/fast-json-stringify 还在维护吗？

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

