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

seqappend

v2.0.1

Published

Helper to make subsequent calls to fs.appendFile sequential

Downloads

1

Readme

seqappend - sequential append!

Forces repeated calls to fs.appendFile to be added to the file in the correct order. Writes to the file are still made asynchronously.

Life without seqappend:

89
90
78
73
92
94
91
95
96
93
99
97
100
98

(This is from the end of badFile.txt after running npm run test. These numbers "should" count in order to 100.)

General use, with no callbacks:

const writeLog = require('seqappend')('logfile.txt');

writeLog('Several...');
writeLog('...logged...');
writeLog('.......events');

...or:

const SeqAppend = require('seqappend');

const writeLog = SeqAppend('log.txt');

writeLog('Several...');
writeLog('...logged...');
writeLog('.......events');

...or even:

const SeqAppend = require('seqappend');

const writeLog1 = SeqAppend('log1.txt');
const writeLog2 = SeqAppend('log2.txt');

writeLog1('Several...');
writeLog1('...logged...');
writeLog1('.......events');

writeLog2('In...');
writeLog2('...multiple...');
writeLog2('............files');

Using Callbacks

Callbacks are declared in the constructor

const SeqAppend = require('seqappend');

const writeLog = SeqAppend('log.txt', (err)=>console.log(err));

writeLog1('data');

Callbacks are passed into the constructor, and are run for every call to fs.appendFile made internally by seqappend. Since seqappend concatenates write requests and writes them at once, the callback is not necessarily called once for every write request.

Originally, callbacks were to be supported with the 'write' operations, but the resulting behavior was difficult to predict, and you still couldn't expect every callback passed into the 'write' function to be called. Functionality to call every callback could be provided by keeping a second array of callbacks and iterating through them when the write is complete, but this is not a requirement for my use case. If you have a compelling use case for this then please get in touch and maybe I'll be bored that evening...

One final caveat...

If you have more than one 'write' function writing to the same file, then the data may not be written in teh correct order.