Skip to content

Typing and refactoring of serializer.js #740

Description

@DJ1TJOO

Some context
I'm currently working on a project for my university to create a visual shacl editor, to accomplish this I'm using this library. Since the documentation is limited I'm looking a lot through the source code to find out how I can do certain operations. As a hobby project I would like to get better at refactoring code, so my idea to refactor the serializer.js.

The plan

  • Fase 1: Convert serializer.js -> serializer.ts, by adding typings, trying to avoid any code changes unless absolutely nessesary (repo)
  • Fase 2: Split up the code into multiple classes (repo):
    • There are different types of serializers in the serializer.js file: statementsToN3, statementsToNTriples, statementsToXML, and statementsToJsonld
    • All of these share code like namespaces/prefixes, base, flags, store, etc.
    • Some share other code
      • statementsToN3 and statementsToNTriples share atomicTermToN3
      • statementsToN3 and statementsToXML share rootSubjects
      • statementsToJsonld is just statementsToN3 with some extra code after it
    • To address this I have the following in mind: split up into multiple classes, but still do not change any code of the methods, just move
Image
  • Fase 3: Refactor code: like flags could become a object with clearer names
  • Fase 4: Possible add new features, I'm currently thinking about giving options on which predicates should come first, or a way to add comments?

The question
Is rdflib.js interested in any of this, or should I just keep it to my self?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions