Skip to content

How should the reviver function behave? #7

Description

@peetklecha

Should JSON.parseImmutable take a reviver function, and if so, what should its behavior be?

Assuming there is a reviver function: It seems straightforward that in cases where the reviver returns either a primitive or the same object it was passed, that it should behave just like the reviver in JSON.parse. What's less obvious is what do if the reviver returns an object other than the object it was passed. Is it accepted without condition? Does the engine freeze it? Does the engine validate that it is frozen? Or does the engine reject it?

For simplicity, my weak preference is for the engine to simply throw if the reviver attempts to return any object other than the one it was passed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions