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

@letskomplai/gated

v1.0.0

Published

A functional feature flagging library for Node.js

Readme

@letskomplai/gated

A simple, functional feature flagging library for Node.js. It is designed to solve the 80% use case of having feature toggles on Subjects (users, teams etc). While there are many feature flagging platforms, they are overkill + add complexity of deploying a separate service. Gated is a simple, light-weight alternative that can be used to manage feature flags in your application, saving data in your DB.

Installation

npm install @letskomplai/gated
# or
yarn add @letskomplai/gated
# or
pnpm add @letskomplai/gated

Usage

Configuration

First, configure the library with a data adapter. Gated provides a simple in-memory adapter and a Prisma adapter out of the box.

import { configure, MemoryAdapter } from '@letskomplai/gated';

configure({
  adapter: new MemoryAdapter(),
});

Creating a Flag

import { createFlag } from '@letskomplai/gated';

await createFlag({
  key: 'new-feature',
  description: 'Enable the new experimental feature',
});

Checking for Access

Check if a feature is enabled for a specific subject (e.g., a user).

import { isEnabled } from '@letskomplai/gated';

const subject = { id: 'user-123', attributes: { company: 'acme' } };

if (await isEnabled('new-feature', subject)) {
  // Show the new feature
} else {
  // Show the old feature
}

Granting and Revoking Access

You can grant and revoke access to features for specific subjects.

import { grantAccess, revokeAccess } from '@letskomplai/gated';

const subject = { id: 'user-123' };

// Grant access
await grantAccess('new-feature', subject);

// Revoke access
await revokeAccess('new-feature', subject);

Adapters

  • MemoryAdapter: A simple in-memory adapter for testing and development. Data is not persisted.

  • PrismaAdapter: An adapter for using a Prisma-compatible database as a backend. To use it, you need to add the required models to your schema.prisma file.

    1. Update your schema.prisma

    Copy the models from the prisma/schema.prisma file in this repository into your own prisma/schema.prisma file. You can find the file here.

    2. Run Prisma migrations

    After updating your schema, run the migrate command to update your database:

    npx prisma migrate dev --name add_gated_models

    3. Configure Gated with the PrismaAdapter

    Finally, instantiate the PrismaAdapter with your Prisma client and pass it to the configure function.

    import { configure, PrismaAdapter } from '@letskomplai/gated';
    import { PrismaClient } from '@prisma/client';
    
    const prisma = new PrismaClient();
    
    configure({
      adapter: new PrismaAdapter(prisma),
    });

Development

  • Build: npm run build
  • Run tests: npm test
  • Lint: npm run lint
  • Format: npm run format