serialize-whatever

Serialize and deserialize whatever.


License
MIT
Install
npm install serialize-whatever@1.0.0

Documentation

serialize-whatever

Serialize and deserialize whatever.

npm i serialize-whatever pnpm add serialize-whatever yarn add serialize-whatever

API

# Ptr

    {

    # $p

      number

    }

# createContext(extraTypes, ptrs)

    # extraTypes  =  []

      [ Ctor, [ AnyFn, AnyFn ] ] []

    # ptrs  =  ...

      Map<object, Ptr>

    createContext(extraTypes, ptrs)  =>

      {

      # replacer

        # (top, clear)

          # top

            unknown

          # clear  =  true

            boolean

          (top, clear)  =>

            # (this, key)

              # this

                any

              # key

                string

              (this, key)  =>

                string | Entry | Ptr

      # reviver

        # (classes, refs, pending)

          # classes

            Ctor []

          # refs  =  ...

            Map<number, object>

          # pending  =  ...

            Map<number, Set<[ any, string |

            # (result)

              # result

                any

              (result)  =>

                void

            ]>>

          (classes, refs, pending)  =>

            # (this, key, value)

              # this

                any

              # key

                string

              # value

                any

              (this, key, value)  =>

                any

      }

# deserialize(serialized, classes)

    # serialized

      string

    # classes  =  []

      Ctor []

    deserialize(serialized, classes)  =>

      unknown

# replacer(top, clear)

    # top

      unknown

    # clear  =  true

      boolean

    replacer(top, clear)  =>

      # (this, key)

        # this

          any

        # key

          string

        (this, key)  =>

          string | Entry | Ptr

# reviver(classes, refs, pending)

    # classes

      Ctor []

    # refs  =  ...

      Map<number, object>

    # pending  =  ...

      Map<number, Set<[ any, string |

      # (result)

        # result

          any

        (result)  =>

          void

      ]>>

    reviver(classes, refs, pending)  =>

      # (this, key, value)

        # this

          any

        # key

          string

        # value

          any

        (this, key, value)  =>

          any

# serialize(any, indent, clear)

    # any

      unknown

    # indent

      number

    # clear

      boolean

    serialize(any, indent, clear)  =>

      string

# thru(x)

    # x

      any

    thru(x)  =>

      any

Credits

Contributing

Fork or edit and submit a PR.

All contributions are welcome!

License

MIT © 2022 stagas