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

pacfactory

v0.1.6

Published

A collection of semantic clients implementing the PAC architecture

Downloads

12

Readme

PacFactory

A collection of semantic clients implementing the PAC architecture

Introduction

PacFactory extends the standard JsapApi used for semantic queries, introducing 4 semantic modules:

  • Producer
  • Consumer
  • CachedConsumer
  • SynchronousConsumer

Installation

Usage

Import semantic modules:

Producer

Create a producer:

Update Sepa with forced bindings:

Alternatively, a new Class that extends the Producer can be created to implement a custom producer:

Consumer

Create a consumer:

A Consumer contains an event emitter that fires on: first,added and received results. The event emitter can be listened to react to a notification:

The Consumer class implements the wrapper method "on", which can be used to write a cleaner code:

Alternatively, a new Class that extends the Consumer can be created to implement a custom consumer:

After declaring the event listeners, the consumer needs to subscribe to sepa to begin receiving notifications:

Cached Consumer

A Cached Consumer is an extension of a consumer. In addition to emitting an event on results, it contains a builtin Map, which can be used to temporarily store sepa notification, effectively acting as a buffer fo sparql notifications. While the CachedConsumer constructor provides a basic implementation for the modules, it is recommended to implement a custom CachedConsumer which has its own caching logic.

Define a cached consumer with custom caching logic:

Create the CachedConsumer and subscribe:

Get the internal cache:

Synchronous Consumer

Similarly to the CachedConsumer, the SynchronousConsumer has an internal cache which gets updated on notification. The difference is that the SynchronousConsumer has a second subscription: the SynchronizationFlag. The SyncFlag can be used to signal the end of a notification stream. Usually, the producer sends two or more messages containing triples, and the SyncConsumer starts caching the messages. Then, the producer sends a Production finished flag. The SyncConsumer provides a custom emitter for this event, the 'newsyncflag' event. Being an extension of a cached consumer, it is necessary to implement a custom caching logic and specify the syncflag bindings. Define a SyncConsumer with custom flag and caching logic:

Create a SynchronousConsumer:

Listen to the syncflag event, then subscribe to sepa: