npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

emfular

v3.0.1

Published

Pure TS library with basic types and parser to move from XPath references to runtime models

Readme

EMFular

This small TS library deals with the conversion between "flat" model representations of emf-jackson, which we call json representation, and a traversable in-memory representation which we call core representation. Basically, it converts the XPath-based references of emf-jackson into object references and vice versa. It consists of two parts:

  1. Referencing: defines the main properties both for the json (flat) and the core (traversable) representation. It also holds methods for serialization.
  2. Deserialization: deals with the conversion of json models into core models.

Referencing

Referencing consists of two classes:

  • The Ref class consists of an XPath reference $ref and the EClass eClass. It holds basic facilities to work with XPath, including traversal and path concatenation and is the basis for working with references in the JSON form that emf-jackson exports.
  • The Referencable class defines a contract for the core representation: Referencables have a UUID gId which is used for global identification and cross-referencing on graphical components. There are also references to all EMF-tree-children. These relationships are used on object creation and destruction. Each object also holds a Ref which might be out-dated but is updated and used on serialization into json. The necessary methods to prepare the XPath references are included.

Deserialization

Deserialization handles the construction of the core model from the json model. We handle the replacement of Ref references by object references during object construction. Hence, we need a deserializer that manages the already created objects and constructs new ones on demand. Basically, the whole construction process is triggered by calling the constructor of the EMF model's root element with the deserializer as only parameter.

The objects' constructors are responsible for the correct creation of their representations. The deserializer offers general methods to help them and relies on certain types, that the library exposes:

  • Deserializer context management: The deserializer stores objects via put, and delivers objects on getOrCreate(ref: Ref). (See below for an explanation of the creation process).
  • Access to json parts: There is a method getJsonFromTree($ref: string) to get the json for a specific XPath.
  • Helper methods: Additionally, there are methods to adapt eClasses. Emf-jackson sometimes omits them but since our deserialization heavily relies on them, we need to set them right upfront.

Object Creation by the Deserializer

The creation of new objects relies on a ConstructorPointer that should be available for the type of the object that is identified by its EClass. These pointers for all EClasses are a necessary parameter when creating a deserializer. export type ConstructorPointer = ($ref:string) => (p: Deserializer) => Referencable; The definition of these pointers must be handled by the programmer.

We recommend to write the ConstructorPointer so that it first sets the complete Ref and then calls a (dummy) constructor with the deserializer and the Ref as parameters. There is a typed helper ConstructorPointerFor for all ConstructorPointer definitions. The deserializer based object construction needs to be done on the constructor. This way, the object can be put into the deserializer as soon as it exists. The deserializer offers the method getJsonFromTree($ref: string) to access all relevant attributes and XPath references from the json model.

In our current reference implementation, KEML.web, the interplay of deserializer and constructors is visible.