Support TypedArrays
メンテナーはふだん 2 日以内に返信
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- javascript
調査の方向性
まず、issue で示されている Array.isArray チェックの周辺にある index.js を読み、Float32Array の例を再現します。提案されているスキーマ互換性と largeArrayMechanism の動作がどのようになるべきかを確認します。互換性のあるスキーマに対して TypedArrays が正しくシリアライズされ、通常の配列の動作が変更されなければ完了です。
索引モデルが issue の本文から書いたものです。
説明
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the feature has not already been requested
🚀 Feature Proposal
fast-json-stringify does not work with TypedArray objects (Float32Array, etc.). Normally, using JSON.stringify to serialize a TypedArray results in writing it as an object (e.g., new Float32Array([0.1,0.2]) gets serialized as {"0":0.1,"1":0.2}). However, since fast-json-stringify uses a JSON Schema to guide its output, it can know that a given property is an array; it seems reasonable and consistent to allow it to serialize TypedArrays as well as regular arrays.
Proposed implementation:
- The Array.isArray check could be broadened to also allow TypedArrays.
- TypedArray can only hold (floating point or integer) numbers, so it would not work with many JSON Schemas. One option would be to only allow TypedArray if the JSON Schema is compatible with TypedArray (e.g., only number items); another option would be to allow it as is and then let individual elements fail validation.
- If a TypedArray is in use, largeArrayMechanism is ignored (treated as
default).
Motivation
Our application uses TypedArray for several purposes. This is fast internally but is noticeably slower to serialize. Using fast-json-stringify, locally patched to support TypedArray, is over 2.5x faster for a Float32Array of 4000 randomly generated numbers.
Example
const array = new Float32Array(new Array(4000).fill(1));
const stringify = fastJson({
title: 'Example Schema',
type: 'array',
items: {
type: 'number'
}
})
console.log(stringify(array));
- 主要言語
- JavaScript
- スター
- 3.7k
- フォーク
- 245
- 平均マージ
- 3日 5時間
- マージ済み PR(30日)
- 16
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
fastify/fast-json-stringify のほかの issue
-
benchmark question
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
fastify/fast-json-stringify#782 · コメント 15 件 ·
メンテナーはふだん 2 日以内に返信
-
allOf Fails to Handle Array of if/then as Chained else Conditions対応中かも @junaidkhan80121 が 18 日前に担当しました。 オープンbug
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
fastify/fast-json-stringify#778 · コメント 5 件 ·
メンテナーはふだん 2 日以内に返信
-
When `asString` receives `undefined` an exception is thrown対応中かも @cpruijsen が 47 日前に担当しました。 オープンbug
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
fastify/fast-json-stringify#680 · コメント 2 件 ·
メンテナーはふだん 2 日以内に返信
-
emit CJS/ESM syntax in standalone mode based on AJV code options対応中かも @jaideeppyne が 101 日前に担当しました。 オープンfeature request
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
fastify/fast-json-stringify#679 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
feature request
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
fastify/fast-json-stringify#627 · コメント 4 件 · リアクション 3 件 ·
メンテナーはふだん 2 日以内に返信
fastify/fast-json-stringify の issue をすべて見る
似ている issue
-
FEATURE REQUEST
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
linuxmint/cinnamon-spices-applets#9356 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
needs-triage Platform(Default)
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 63/100
メンテナーはふだん 1 日以内に返信