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

ldif-stream

v0.2.1

Published

Read LDIF entries as a stream

Downloads

405

Readme

node-ldif-stream

Streaming LDIF parser for Node based on RFC2849

What's better than awesomely parsing an LDIF file in an RFC-compliant way? Parsing it in a Node stream! This small library makes it easy.

Based on my ldif parsing package.

Usage

Installation

npm install ldif-stream

Streaming a file

var Streamer = require('ldif-stream');
var options = {};

Streamer.file('./example.ldif',options)
  .on('data',function(data){
    console.log('Found LDIF data');
    console.log(data);
  })
  .on('end',function(){
    console.log('All done!');
  });

Stream any stream

var Streamer = require('ldif-stream');
var stream = fs.createReadStream('example.ldif','utf8');
var options = {};

Streamer(stream,options)
  .on('data',function(data){
    console.log('Found LDIF data');
    console.log(data);
  })
  .on('end',function(){
    console.log('All done!');
  });

Pipeline transformations

Since there are many ways the data could be transformed to be useful, this library allows you to specify an array of transformations in the pipeline option. Each transformation receives the options passed in to the stream when it was created.

The default pipeline is [ Streamer.record, Streamer.object ]. This breaks the stream into individual records (probably already happened with line splitting), and then converts each record into an object.

The available transformations are described below.

Streamer.record

The ldif library parses a string of LDIF into a containerized format that includes a little outer cruft to wrap the entries contained in the file. This transformation breaks out any records contained in each chunk, into separate chunks, one record each.

The internal parsed format and the "object" format both have an entries key, so this transformation can work on either as input. It simply shifts records off of entries and emits a new chunk for each record.

Streamer.object

Transforms single records (or entire containers) into a simple object format. Reference the ldif package documentation for toObject() and it's associated options, which can be mixed into the options given to the streamer, to alter the behavior of the output of this transformation.

Streamer.ldif

Not really sure why you'd want to stream back into LDIF format, but why not? This will return a chunk of parsed and re-outputted LDIF for each chunk it receives.

TODO

  • Document writing transformers
  • Document streamer options
  • Test suite