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 🙏

© 2026 – Pkg Stats / Ryan Hefner

sweet-potato

v1.0.3

Published

Useful libs for command line node.js apps

Downloads

12

Readme

Welcome to your very own Sweet Potato 🍠

This is a little collection of node-js libs that are useful for command line tools. I plan to clean these up, add some tests and spin these off into their own little repos.

The libraries

allMyChildren

Iterates over all objects within a JavaScript object tree.

const allMyChildren = require('sweet-potato').allMyChildren;

allMyChildren(node, setLeafFromResult, runFunction, key, parent);

args

Pulls out arguments sent into a script on the command line and makes them available in an easier way than using process.args.

> node somescript.js fruit=apple v=carrot count=3

...now, in somescript.js:

const args = require('sweet-potato').args;
args.declare(['fruit', 'f'], 'string');
args.declare(['veggie', 'v'], 'string');
args.declare(['count', 'c'], 'number');

console.log(args.fruit); //'apple'
console.log(args.veggie); //'carrot'
console.log(args.count); //'3'

awaitNewFiles

Watch a particular directory until a new file arrives. Useful for watching for downloads.

const awaitNewFiles = require('sweet-potato').awaitNewFiles;

awaitNewFiles('/Users/mrpotato/Downloads', function(newFilesArray) {
    ...
});

customStringify

Alternative to JSON.stringify() when you have an object with circular structures.

const customStringify = require('sweet-potato').customStringify;

dateStuff

Some useful date functions lazily gathered into one library.

const dateStuff = require('sweet-potato').dateStuff;

log

Alternative to console.log that is both shorter to type, and provides more useful output for objects, arrays, etc.

const log = require('sweet-potato').log;

log(1); //prints 1
log(someObject); //prints JSON pretty printed
log(someArrayOfArrays); //prints using console.table.

permutator

Provides all permutations of an array.

const permutator = require('sweet-potato').permutator;

var arr = [1,2,3];
var p = permutator(arr);

//p should equal [ [ 1, 2, 3 ], [ 1, 3, 2 ], [ 2, 1, 3 ], [ 2, 3, 1 ], [ 3, 1, 2 ], [ 3, 2, 1 ] ]

readCsv

A simple wrapper around fast-csv;

const readCsv = require('sweet-potato').readCsv;

readCsv('/Users/mrpotato/Documents/harvest.csv', { leaveCaseAlone: true }, function(rows) {
    //rows is an array of JavaScript objects, one for each row of CSV
});

runCommand

A simple wrapper around child_process to run commands. This needs some rethinking to be generally usable.

const runCommand = require('sweet-potato').runCommand;

runCommand('open /Users/mrpotato/Documents/harvest.csv');

SeededRandom

A way to get pseudo-random numbers that are repeatable. At least on the same machine.

const SeededRandom = require('sweet-potato').SeededRandom;

var rand = new SeededRandom(5);
rand.next(); // returns 0.35067478337943214
rand.next(); // returns 0.9891305176801097
rand.get([1,2,3,4,5]); //returns 3 -- selects a random item from array
rand.get(10); //returns 2 -- selects a random number from 0 to 9 (less than 10)
rand.shuffle([1,2,3,4,5,6]); //returns [ 1, 4, 3, 5, 2, 6 ]

//rerunning this code should produce the same results.

writeCsv

Simple wrapper around csv-writer.

const writeCsv = require('sweet-potato').writeCsv;

writeCsv('/Users/mrpotato/Documents/gardenPlan.csv', arrayOfObjectsSameKeys);

FAQs

Why is it called Sweet Potato? I really like sweet potatoes, and literally all the other names are taken.

There's already a better library for function X Cool, sometimes these things are hard to find!

Some of this code is not good, so like, why? Been busy.