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

dependant-object-keys

v1.0.6

Published

This is a small utility type, which allows you to create one way "dependancies", or "constraints" between keys in diffrent objects.

Readme

Dependant Object Keys (Name WIP)

This is a small utility type, which allows you to create one way "dependancies", or "constraints" between keys in diffrent objects.

Currently the type only supports boolean => any dependancies, but I plan to support any => any dependancies in the future.

Installation

Install dependant-object-keys:

  • with npm
  npm install dependant-object-keys
  • with yarn
   yarn add dependant-object-keys

Usage/Examples

To import the type, use import type like so:

import type { DependantObj } from 'dependant-object-keys'

Then define the interface to use as the allowed values (you can use one of your existing interfaces / data structures),

and the object defining which keys are supposed to exist, it should be extandable to the following type:

interface BooleanIndex {
  [key: string]: boolean
}

(again, you can use on of your existing data structures)

interface AnyIndex {
  [key: string | symbol | number]: any
}

interface TestKeyMap1 extends AnyIndex {
  foo: 'fai' | 'fom'
  bar: 'bir' | 'bor'
}

const testMap1 = {
  isFoo: true,
  isBar: false,
} as const // We use as const to ensure the type signature is exact with the values in the object

You don't have to use "is" as a prefix, but you should know the type unpacks that, and the resuling type def will be whatever name was in the testMap1 object, without the "is", if it exists, so for testMap1 the resulting type def object will look like this:

type ResType = {
  foo: 'fai' | 'fom'
}

The same ResType type will be generated for the following testMap:

const testMapSame = {
  foo: true,
  bar: false,
}

Then we can define the actual constrained object, here are several examples of expected outcomes:

const obj1 = {
  foo: 'fai',
  bar: 'bir', // will give TS error -  Object literal may only specify known properties,
  // and 'syntax' does not exist in type DependantObj<typeof testMap1, TestKeyMap>
} satisfies DependantObj<typeof testMap1, TestKeyMap>

const testMap2 = {
  isFoo: true,
  isBar: true,
} as const

const obj2 = {
  foo: 'hi', // will give TS error - Type '"hi"' is not assignable to type '"fai" | "fom"'.
} satisfies DependantObj<typeof testMap2, TestKeyMap> // will also give TS error - Property 'bar' is missing in type '{ foo: "fai"; }',
// but required in type DependantObj<typeof testMap2, TestKeyMap>

Authors

Acknowledgements

  • Tom Bachar - who sent me on the right direction for solving this problem.

  • Noy Morgenshtein - which helped me understand typescripts conditional types.

Feedback

If you have any feedback, please reach out to me @ [email protected], or feel free to open up a github issue / discussion for the repo!

Contributing

This is a simple project in it's baby stages, so any and all contributions are always welcome!