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

@rdfc/js-runner

v3.0.1

Published

## Usage

Downloads

913

Readme

JavaScript runner for RDF-Connect

Usage

To use the JavaScript (Node or Bun) runner for RDF-Connect, you need to have a pipeline configuration that includes JavaScript/TypeScript processors. The runner can be added to your RDF-Connect pipeline as follows:

@prefix rdfc: <https://w3id.org/rdf-connect#>.
@prefix owl: <http://www.w3.org/2002/07/owl#>.

### Import the runner
<> owl:imports <./node_modules/@rdfc/js-runner/index.ttl>.

### Define the pipeline and add the Node runner
<> a rdfc:Pipeline;
   rdfc:consistsOf [
       rdfc:instantiates rdfc:NodeRunner;  # Use rdfc:BunRunner for Bun
       rdfc:processor <log>, <send>;  # List of JavaScript processors to be used in the pipeline. You should define and configure these processors separately.
   ].

This example assumes that the js-runner is installed in your project via npm or yarn in the current working directory.

You can install the js-runner package using the following command:

npm install @rdfc/js-runner

Logging

The JavaScript runner and processors use the winston logging library for logging. The JavasScript runner initiates a logger that is passed to each processor, allowing them to log messages at various levels (info, warn, error, debug). You can access this logger in your processor class code on the this.logger property. Here's an example of how to use the logger in a processor:

import { Processor } from '@rdfc/js-runner'

class MyProcessor extends Processor<MyProcessorArgs> {
  async init(this: MyProcessorArgs & this): Promise<void> {
    this.logger.info('I am initializing my processor!')
  }
  // ...
}

This logger is configured to forward log messages to the RDF-Connect logging system. This means you can view and manage these logs in the RDF-Connect logging interface, allowing for consistent log management across different components of your RDF-Connect pipeline.

If you want to create a child logger for a subclass or submethod, you can do so using the extendLogger method. Here's an example:

import { Processor, extendLogger } from '@rdfc/js-runner'

class MyProcessor extends Processor<MyProcessorArgs> {
  async init(this: MyProcessorArgs & this): Promise<void> {
    const childLogger = extendLogger(this.logger, 'init')
    childLogger.debug('This is a debug message from init.')
  }
  // ...
}

Develop a processor for this runner

The simplest way to start developing a processor for the JavaScript runner, is to start from the template-processor-ts template repository. It has everything set up to get you started quickly and let you focus on the actual processor logic.

At the very least, a JavaScript/TypeScript processor should consist of a class that inherits from the Processor abstract base class provided by the @rdfc/js-runner package. This class should implement the init method, which is called when the processor is initialized. This method is where you can set up any necessary configuration or state for your processor like opening a database connection or reading a file. Additionally, you should implement the transform method, which is called before the produce method. In this transform method, you should put any logic that handles incoming data by consuming readers, possibly transforming it, and passing it to the next processor in the pipeline. This method should only write to writers as reply to the data it receives from readers, not produce new data, as it is important that it does not write data to channels before all readers have been initialized and are ready to consume data. Finally, you should implement the produce method, which is called after all readers have been initialized and are ready to consume data. It is called after the transform method. This method is where you can produce (new) output data by writing to writers to send the data to the next step in the pipeline.

Next to the class, you should define a configuration for the processor in the processor.ttl file of your package. JavaScript/TypeScript processors must include the JavaScript specific configuration parameters rdfc:file, rdfc:class, and rdfc:entrypoint, which specify the file, class, and entrypoint path of the processor, respectively.

Development of the js-runner

The JavaScript runner is implemented in TypeScript. The source code is contained in the src folder. The main cli entry point is the bin/runner.js file, which you can also run after installation of the package using npx js-runner.

If you want to get started with the development of the js-runner, you can clone the repository and install the dependencies using the following commands.

Clone the repository:

git clone [email protected]:rdf-connect/js-runner.git
cd js-runner

Install the dependencies:

npm install

You can run the formatter and linter using:

npm run format
npm run lint

You can run the tests using:

npm test

You can then build the project using:

npm run build

Lastly, you can publish the package to npm using:

npm publish --access=public