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

async-concat-with-sourcemaps

v1.1.6

Published

Concatenate file contents with a custom separator and generate a source map

Downloads

8

Readme

Asynchronous concat with source maps NPM version build status Test coverage

NPM module for concatenating files and generating source maps.

Advantage over concat-with-sourcemaps

The original concat-with-sourcemaps module uses system memory (RAM) to store the concatencated files. While it makes concatenation fast, this can be a problem for machines with less RAM. This module addresses this problem by (optionally) storing the concatenated contents into a temporary file while allowing the Node.js's garbage collector to free some memory used in storing the file contents.

Installation

npm i async-concat-with-sourcemaps

Usage example

async function usingAsyncConcat() {
  // store concatenated file in /tmp directory
  var concat = new Concat(true, 'all.js', '\n', '/tmp');
  await concat.add(null, "// (c) John Doe");
  await concat.add('file1.js', file1Content);
  await concat.add('file2.js', file2Content, file2SourceMap);

  var concatenatedContent = await concat.content();
  var sourceMapForContent = await concat.sourceMap();
}

API

new Concat(generateSourceMap, outFileName, separator)

Initialize a new concat object.

Parameters:

  • generateSourceMap: whether or not to generate a source map (default: false)
  • outFileName: the file name/path of the output file (for the source map)
  • separator: the string that should separate files (default: no separator)
  • tmpDir: (optional) directory used to store concatencated files. Passing undefined will use system memory.

concat.add(fileName, content, sourceMap)

Add a file to the output file. Returns a Promise<void>.

Parameters:

  • fileName: file name of the input file (can be null for content without a file reference, e.g. a license comment)
  • content: content (Buffer or string) of the input file
  • sourceMap: optional source map of the input file (string). Will be merged into the output source map.

concat.content()

The resulting concatenated file content (Buffer). Returns a Promise<Buffer>.

concat.sourceMap()

The resulting source map of the concatenated files (string). Returns a Promise<string | undefined>.

concat.tmpFile

Path to the temporary file.