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

sdmp-node-journal

v0.2.2

Published

An implementation of the SDMP Journal in JavaScript.

Downloads

14

Readme

sdmp-node-journal

An implementation of the SDMP journal in JavaScript.

This module does not verify resources or authors in any way. It simply blindly maintains a journal list.

install it

Install it the normal npm way:

npm install sdmp-node-journal

Or by copying the code into your project some other more difficult way.

initialize it

Initialize it with a string containing the full journal (according to the SDMP specs, this must contain at least the first journal line):

var NodeJournal = require('sdmp-node-journal')
var existingJournal = 'GlvAreTo0lCS...'
var journal = NodeJournal(existingJournal)

journal entry object

All functions and streams digest and produce an object containing some or all of the following properties:

write to it: .write(journalEntry, callback)

Write to the journal by calling .write on the instantiated journal. The two properties are:

  • journalEntry - A journal entry object containing author and resource. (If an identifier or line property is included, this is considered an error.)
  • callback - A traditional error-first callback function. If there are no errors, the second parameter is a complete journal entry object for that line.

The error object returned has the following possible properties:

  • invalidJournalEntry - The properties author and resource are not string.
  • containsIdentifierOrLine - The property line or identifier are not falsey.

For example (data truncated with ... for readability):

journal.write({
	author: 'GlvAreTo...',
	resource: 'OTA8fSUK...'
}, function(error, entry) {
	console.log(entry.identifier) // 22tfYa3X...
})

read from it: .read(journalEntry, callback)

Read from the journal by calling .read on the instantiated journal. The two properties are:

  • journalEntry - A journal entry object containing at least one of author, resource, identifier, or line.
  • callback - A traditional error-first callback function. The returned data is an array of any lines that match all parameters on the journalEntry passed in. Journal lines are considered to match when the line contains all of the parameters given in the journalEntry object.

The error object returned has the following possible properties:

  • invalidJournalEntry - At least one of author, resource, identifier, or line must be set. All properties must be falsey or of the type string.

For example (data truncated with ... for readability):

journal.read({
	line: '22tfYa3X...'
}, function(error, entry) {
	console.log(entry.line) // 22tfYa3X...@GlvAreTo.../OTA8fSUK...
	console.log(entry.identifier) // 22tfYa3X...
	console.log(entry.author) // GlvAreTo...
	console.log(entry.resource) // OTA8fSUK...
})

write emitter: .on('write', callback)

On any call to .write, the write event is emitted. The callback is given the journal entry object that was written to the journal.

read all: .readAll()

Returns the entire journal as an ordered array of journal entry objects.

license

Released under the Very Open License