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

concat-strings

v1.0.3

Published

A simple Node.js module for concatenating strings with various options and error handling

Readme

concat-strings

A simple Node.js module that provides functions to concatenate strings with various options.

Description

This module concatenates two or more strings and provides additional functionality like concatenating with custom separators. It includes proper error handling to ensure all inputs are valid strings.

Installation

From npm

npm install concat-strings

From source

Clone this repository or download the files:

git clone https://github.com/mattesja/concat-strings.git
cd concat-strings
npm install

Usage

Basic String Concatenation

const { concatStrings } = require('concat-strings');

// Concatenate multiple strings
const result = concatStrings('Hello', ' ', 'World', '!');
console.log(result); // Output: "Hello World!"

// Concatenate two strings
const greeting = concatStrings('Good', ' morning');
console.log(greeting); // Output: "Good morning"

String Concatenation with Separator

const { concatStringsWithSeparator } = require('concat-strings');

// Concatenate with a custom separator
const fruits = concatStringsWithSeparator(' - ', 'Apple', 'Banana', 'Orange');
console.log(fruits); // Output: "Apple - Banana - Orange"

// Concatenate with comma separator
const names = concatStringsWithSeparator(', ', 'John', 'Jane', 'Bob');
console.log(names); // Output: "John, Jane, Bob"

Using Both Functions

const { concatStrings, concatStringsWithSeparator } = require('concat-strings');

const firstName = 'John';
const lastName = 'Doe';

// Basic concatenation
const fullName = concatStrings(firstName, ' ', lastName);
console.log(fullName); // Output: "John Doe"

// With separator
const formattedName = concatStringsWithSeparator(' | ', firstName, lastName);
console.log(formattedName); // Output: "John | Doe"

API Reference

concatStrings(...strings)

Concatenates multiple strings together without any separator.

Parameters:

  • ...strings (string): Variable number of string arguments to concatenate

Returns:

  • string: The concatenated result

Throws:

  • TypeError: If any argument is not a string

concatStringsWithSeparator(separator, ...strings)

Concatenates multiple strings with a specified separator between them.

Parameters:

  • separator (string): The separator to insert between strings
  • ...strings (string): Variable number of string arguments to concatenate

Returns:

  • string: The concatenated result with separators

Throws:

  • TypeError: If the separator or any string argument is not a string

Error Handling

Both functions include robust error handling:

try {
  concatStrings('Hello', 123); // This will throw an error
} catch (error) {
  console.error(error.message); // "Argument at index 1 is not a string. Expected string, got number"
}

try {
  concatStringsWithSeparator(null, 'Hello', 'World'); // This will throw an error
} catch (error) {
  console.error(error.message); // "Separator must be a string. Expected string, got object"
}

Testing

You can test the functions by uncommenting the example usage lines in index.js and running:

node index.js

License

ISC

Author

mattesja

Repository

https://github.com/mattesja/concat-strings

Issues

Report issues at: https://github.com/mattesja/concat-strings/issues