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

@lopatnov/join

v2.1.0

Published

SQL-like join operations for JavaScript objects — merge two objects using 9 composable join types (left, right, inner, full and more) with deep merge support.

Readme

@lopatnov/join

A TypeScript library providing SQL-like join operations for JavaScript objects. Merge two objects using one of 9 composable join types, with support for deep merging of nested objects.

npm downloads npm version License GitHub issues GitHub stars


Table of Contents


Installation

npm install @lopatnov/join

Browser:

<script src="https://lopatnov.github.io/join/dist/join.umd.min.js"></script>

Import

TypeScript / ES Modules

import { join, JoinTypes } from "@lopatnov/join";

CommonJS

const { join, JoinTypes } = require("@lopatnov/join");

Join Types

Join Types

The library uses a 4-bit flag system to describe which parts of two objects appear in the result:

| Bit | Name | Meaning | | :-: | ------------ | ---------------------------------------------- | | 3 | left | Include properties unique to the left object | | 2 | innerLeft | Include shared properties, keeping left values | | 1 | innerRight | Include shared properties, using right values | | 0 | right | Include properties unique to the right object |

Named Join Types

| Join Type | Bits | Description | | :----------- | :----: | ---------------------------------------------------------------- | | none | 0000 | Empty result — no properties from either object | | left | 1000 | Only properties unique to the left object | | right | 0001 | Only properties unique to the right object | | innerLeft | 0100 | Shared properties only, keeping left values | | innerRight | 0010 | Shared properties only, replacing with right values | | innerJoin | 0110 | Shared properties, deep-merged (left + right values combined) | | leftJoin | 1110 | Left-unique + shared properties (deep-merged) | | rightJoin | 0111 | Shared properties (deep-merged) + right-unique | | fullJoin | 1111 | All properties from both objects, shared ones deep-merged | | expand | 1011 | Left-unique + right values for shared + right-unique (default) |

Custom join types can be composed with bitwise OR:

const customJoin = join(JoinTypes.left | JoinTypes.innerLeft | JoinTypes.right);

API

function join(
  joinType?: JoinTypes
): <TContext>(
  context: TContext
) => <TJoinObject>(joinObject: TJoinObject) => TContext & TJoinObject;

join uses a curried three-step pattern:

| Step | Call | Description | | ---- | --------------------------- | ---------------------------------------------------- | | 1 | join(JoinTypes.xxx) | Set the join type; returns a context-setter function | | 2 | contextSetter(leftObject) | Set the left object; returns a joiner function | | 3 | joiner(rightObject) | Set the right object; returns the merged result |

JoinTypes.expand is the default join type when join() is called with no arguments.


Usage Examples

Right Join

Returns only the properties unique to the right object:

const rightJoin = join(JoinTypes.right);

const contextJoinBy = rightJoin({
  sample1: "One",
  sample2: "Two",
  sample3: "Three"
});

const result = contextJoinBy({
  sample2: "Dos",
  sample3: "Tres",
  sample4: "Quatro"
});

console.log(result); // { sample4: "Quatro" }

Left Join

Returns only the properties unique to the left object:

const leftJoin = join(JoinTypes.left);

const contextJoinBy = leftJoin({
  sample1: "One",
  sample2: "Two",
  sample3: "Three"
});

const result = contextJoinBy({
  sample2: "Dos",
  sample3: "Tres",
  sample4: "Quatro"
});

console.log(result); // { sample1: "One" }

Custom Bitwise Composition

Returns left-unique + shared (from left) + right-unique properties:

const customJoin = join(JoinTypes.left | JoinTypes.innerLeft | JoinTypes.right);

const contextJoinBy = customJoin({
  sample1: "One",
  sample2: "Two",
  sample3: "Three"
});

const result = contextJoinBy({
  sample2: "Dos",
  sample3: "Tres",
  sample4: "Quatro"
});

console.log(result); // { sample1: "One", sample2: "Two", sample3: "Three", sample4: "Quatro" }

Inner Join (Deep Merge)

Returns shared properties with their values deep-merged:

const result = join(JoinTypes.innerJoin)({
  sample1: "One",
  sample2: "Two",
  sample3: { smile: "cheese" }
})({
  sample2: "Dos",
  sample3: { sorrir: "queijo" },
  sample4: "Quatro"
});

console.log(result);
// { sample2: "Dos", sample3: { smile: "cheese", sorrir: "queijo" } }

Demo


Contributing

Contributions are welcome! Please read CONTRIBUTING.md before opening a pull request.


Built With


License

Apache-2.0 © 2020–2026 Oleksandr Lopatnov · LinkedIn