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 🙏

© 2024 – Pkg Stats / Ryan Hefner

xrefparser

v3.1.0

Published

OpenEdge XREF parser

Downloads

22

Readme

OpenEdge XREF parser in TypeScript

This is a parser/searcher library for OpenEdge xref files.

Initialization

Searching the sources which contain creates and deletes of in 'Klantbes' table is as easy as:

import { Parser, Searcher } from 'xrefparser';

const parser = new Parser();
const xrefdata = parser.parseDir('c:/usr/xref', 'D:\\wintmp\\build492943069\\devmain\\');

const searcher = new Searcher(xrefdata);

const sources = searcher
                .getTableReferences('Klantbes', true, undefined, true)
                .map(table => table.sourcefile);

console.log(sources);

Parser class

When instantiated there's basically one relevant method; parseDir

parseDir

parseDir(dirname: string, sourcebasedir?: string): XrefFile[]

dirname is the root directory where all the .xref files are located. sourcebasedir is the optional parameter stating what the root directory of the sources when they were compiled. This is substracted from the sourcefile properties.

Searcher class

The only constructor takes XrefFile[] as input.

add

add(xreffiles: Xreffile[]);

This method add/merges the xreffiles into the existing Xreffile[]'s.

getDatabaseNames

getDatabaseNames(sources?: string[]): string[]

Returns an array of database names found in sources. If sources is undefined, all the database names of all sources are returned.

getDatabaseReferences

getDatabaseReferences(databaseName: string): XrefFile[]

Returns an array with all the XrefFile contains references to the databaseName

getFieldReferences

getFieldReferences(fieldname: string, tablename?: string, hasUpdates?: boolean): XrefFile[]

Looks for occurences of fieldname, optionally in table tablename. The optional hasUpdates parameter gives the possibility the search for sources which update a certain field (or not). If tablename or hasUpdates are not to be taken into consideration, omit them or pass undefined.

getTableReferences

getTableReferences(tablename: string, hasCreates?: boolean, hasUpdates?: boolean, hasDeletes?: boolean): Xreffile[]

Looks for uses of tablename in the all the Xreffile objects and returns XrefFile[]. Use map as in the example to turn it into an array of source names (or whatever you want). If for the has* parameters undefined is used, the particular action is not searched for. This contrary to hasCreated = false where sources are returned that do not create the particular table.

Performance

Above case takes on a Dell XPS15 9560 around 8s to parse all the xref files and 3ms to search for create/delete references in the 'Klantbes' table. There are around 3850 xref files which are combined 350MB on disk.

Release notes

The release notes can be found at github/releasenotes.md

Example Xreffile

The Parser turns in the .xref files into an array of Xreffile objects. Beneath an example which is pretty self explanatory:

{
  "xreffile": "C:/devoe/sandbox/src/xref_out/xref/CustomerBE.cls.xref",
  "sourcefile": "xref/CustomerBE.cls",
  "cpInternal": "UTF-8",
  "cpStream": "UTF-8",
  "includes": [
    "xref/findfirstcustomer.i"
  ],
  "tablenames": [
    "Customer"
  ],
  "classes": [],
  "invokes": [
    "xref.BaseClass:Cleanup",
    "xref.BusinessEntity:BusinessEntity",
    "xref.CustomerBE:Cleanup"
  ],
  "annotations": [
    "todo(version=12.x, message=refactor for efficiency)",
    "linecheck(lineno=44)",
    "linecheck(lineno=46)"
  ],
  "tables": [
    {
      "name": "Customer",
      "database": "sports2000",
      "isCreated": false,
      "isDeleted": false,
      "isUpdated": true,
      "fields": [
        {
          "name": "CustNum",
          "isUpdated": false
        },
        {
          "name": "CreditLimit",
          "isUpdated": true
        },
        {
          "name": "Name",
          "isUpdated": false
        }
      ]
    }
  ],
  "class": {
    "name": "xref.CustomerBE",
    "inherits": "xref.BusinessEntity",
    "implements": [
      "xref.IDisposable"
    ]
  }
}