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

js-servus

v1.0.1

Published

A utility library for common JavaScript/TypeScript tasks.

Readme

js-servus

npm version Node.js Version License: MIT

Description

js-servus is a lightweight and versatile JavaScript/TypeScript utility library that simplifies common coding tasks. It provides powerful, reusable functions for tasks like sorting, filtering, grouping, and merging objects with support for nested properties. Perfect for developers who want to save time and focus on building great applications.


Installation

Install the package using npm:

npm install js-servus

Features

  • Sort arrays of objects by single or nested properties.
  • Merge arrays of objects based on specified keys, including nested keys.
  • Filter objects with multiple conditions, supporting nested properties.
  • Group arrays of objects by properties or nested keys.
  • Lightweight and fully TypeScript-compatible.

Usage Examples

1. Sorting Arrays by Nested Properties

import { ArrayHelper } from 'js-servus';

const data = [
  { id: 1, name: 'Alice', address: { city: 'New York' } },
  { id: 2, name: 'Bob', address: { city: 'Los Angeles' } },
  { id: 3, name: 'Charlie', address: { city: 'New York' } },
];

const sorted = ArrayHelper.sortByLabel(data, 'address.city', 'asc');
console.log(sorted);

2. Merging Arrays Based on Keys

import { ArrayHelper } from 'js-servus';

const array1 = [
  { id: 1, name: 'Alice' },
  { id: 2, name: 'Bob' },
];

const array2 = [
  { id: 1, age: 30 },
  { id: 2, age: 25 },
];

const merged = ArrayHelper.mergeArrays(array1, array2, ['id']);
console.log(merged);

3. Filtering Arrays by Multiple Conditions

import { ArrayHelper } from 'js-servus';

const data = [
  { id: 1, name: 'Alice', age: 30, address: { city: 'New York' } },
  { id: 2, name: 'Bob', age: 25, address: { city: 'Los Angeles' } },
];

const filtered = ArrayHelper.filterByConditions(data, { 'address.city': 'New York', age: 30 });
console.log(filtered);

4. Grouping Arrays by Properties

import { ArrayHelper } from 'js-servus';

const data = [
  { id: 1, category: 'fruit', details: { type: 'citrus' } },
  { id: 2, category: 'fruit', details: { type: 'berry' } },
  { id: 3, category: 'vegetable', details: { type: 'root' } },
];

const grouped = ArrayHelper.groupBy(data, 'details.type');
console.log(grouped);

API Documentation

ArrayHelper

  • sortByLabel<T>(data: T[], key: string, order: 'asc' | 'desc'): T[] - Sorts an array of objects by a specified property or nested property.
  • mergeArrays<T, U>(array1: T[], array2: U[], keys: string[]): (T & U)[] - Merges two arrays based on matching keys.
  • filterByConditions<T>(data: T[], conditions: Record<string, any>): T[] - Filters objects by multiple conditions, supporting nested properties.
  • groupBy<T>(data: T[], key: string): Record<string, T[]> - Groups objects by a specified property or nested property.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request.


Support

If you encounter any issues, please open an issue on GitHub.