Skip to content

Data deserialization is unequal #249

@moonsky-all

Description

@moonsky-all

Description

Some non numeric values are processed into numbers

Reproduction Steps

import { decode, encode } from '@toon-format/toon';
import deepEqual from 'fast-deep-equal';

const indent: number = 1;

function encodeToon(data: any): string {
  return encode(data, { indent });
}

function decodeToon<T>(toon: string): T {
  return decode(toon, { indent }) as any;
}

// The following values deserialize data unevenly
const data = [
  '.6226633103089010',
  '+8613334445577',
]

const encoded = encodeToon(data);
// [ 0.622663310308901, 8613334445577 ]
const decoded = decodeToon(encoded);

console.log(deepEqual(data, decoded)); // false

Expected Behavior

Should be equal

Actual Behavior

Not equal

Environment

"@toon-format/toon": "^2.1.0",

[email protected]
OS: macOS 15.7.2

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions