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

@aboviq/kollektor

v1.2.0

Published

Generic file collector, useful for mono repos and microservices

Downloads

27

Readme

@aboviq/kollektor

Build status NPM version XO code style

Generic file collector, useful for mono repos and microservices

Installation

Install @aboviq/kollektor using npm:

npm install @aboviq/kollektor

Usage

Module usage

const kollektor = require('@aboviq/kollektor');

// Read all package.json files in a mono-repo async:
const packages = await kollektor({
	handlers: {
		'package.json': packageFile => require(packageFile)
	}
});

// ...or sync:
const packages = kollektor.sync({
	handlers: {
		'package.json': packageFile => require(packageFile)
	}
});

API

kollektor(options)

| Name | Type | Description | | ------- | -------- | ------------------------------------------------- | | options | Object | Options for specifying the behaviour of Kollektor |

Returns: Promise<Array<Object>>, all collected information depending on given handlers.

kollektor.sync(options)

| Name | Type | Description | | ------- | -------- | ------------------------------------------------- | | options | Object | Options for specifying the behaviour of Kollektor |

Returns: Array<Object>, all collected information depending on given handlers.

Options

options.cwd

Type: String
Default: process.cwd()

Sets the current working directory

options.handlers

Type: Object<Handler>

Example:

{
	"handlers": {
		"package.json": () => {},
		"*.yml": () => {},
		"README.md": () => {}
	}
}
Handler definition

Type: Function
Signature: handlerName :: String -> Object -> Object

handlerName is the name of the handler and is usually a filename, e.g. "package.json" which will call the handler for each package.json file it finds. The handlerName can also be a simple pattern matching multiple files, e.g: "*.yml".

When a file is found that matches the handlerName the handler function will be called with these arguments:

| Name | Type | Description | | -------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | fullPath | String | The full path to the found file | | data | Object | This contains dir (the relative path of the folder), dirPath (the full path of the folder) and all data returned from previous handlers affecting the same folder |

The handler function can be async (return a promise) for the asynchronous version of Kollektor but must be synchronous for the sync version.

Any Object returned from a handler is merged with the current folder's data and will be fed to the next handler affecting files in the same folder. When all handlers have been called and completed for a specific folder the resulting data is what's being returned in the Array of collected information. See the tests for more details on how it works.

Contributing

See Contribution Guidelines and our Code Of Conduct.

License

MIT © Aboviq AB