Support TypedArrays
Los mantenedores suelen responder en 2 días
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- javascript
- Área
- backend-api-design
Línea de trabajo
Empieza leyendo index.js alrededor de la comprobación de Array.isArray mencionada en la issue y reproduce el ejemplo de Float32Array. Revisa cómo deberían funcionar la compatibilidad propuesta del esquema y el comportamiento de largeArrayMechanism; se considera terminado cuando TypedArrays se serializan correctamente para esquemas compatibles sin cambiar el comportamiento de los arrays normales.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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));
- Lenguaje dominante
- JavaScript
- Estrellas
- 3.7k
- Forks
- 245
- Merge medio
- 3 d 5 h
- PR fusionados (30 d)
- 16
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de fastify/fast-json-stringify
-
benchmark question
Dificultad 5/5 Más de una semana Aptitud para principiantes 20/100
fastify/fast-json-stringify#782 · 15 comentarios ·
Los mantenedores suelen responder en 2 días
-
allOf Fails to Handle Array of if/then as Chained else ConditionsPosiblemente ocupada @junaidkhan80121 la tomó hace 18 días. Abiertobug
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
fastify/fast-json-stringify#778 · 5 comentarios ·
Los mantenedores suelen responder en 2 días
-
When `asString` receives `undefined` an exception is thrownPosiblemente ocupada @cpruijsen la tomó hace 47 días. Abiertobug
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
fastify/fast-json-stringify#680 · 2 comentarios ·
Los mantenedores suelen responder en 2 días
-
emit CJS/ESM syntax in standalone mode based on AJV code optionsPosiblemente ocupada @jaideeppyne la tomó hace 101 días. Abiertofeature request
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
fastify/fast-json-stringify#679 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
feature request
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
fastify/fast-json-stringify#627 · 4 comentarios · 3 reacciones ·
Los mantenedores suelen responder en 2 días
Todos los issues de fastify/fast-json-stringify
Issues similares
-
FEATURE REQUEST
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
linuxmint/cinnamon-spices-applets#9356 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
needs-triage Platform(Default)
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 63/100
Los mantenedores suelen responder en 1 día