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

@lsst/pik-core

v0.6.5

Published

Core library for parsing and switching @pik config markers

Readme

@lsst/pik-core

Core library for pik - provides parsing, switching, config loading, and plugin types.

Installation

npm install @lsst/pik-core

Parsing and Switching

Parse and switch @pik config markers in source files:

import { Parser, SingleSwitcher } from '@lsst/pik-core';

const content = `
// @pik:select Environment
// const env = 'DEV';    // @pik:option DEV
const env = 'LOCAL';     // @pik:option LOCAL
`;

// Parse content
const parser = Parser.forExtension('ts');
const { selectors } = parser.parse(content);

// Switch option
const switcher = SingleSwitcher.forExtension('ts');
const newContent = switcher.switch(content, selectors[0], 'DEV');

Config Loading

Load pik configuration from project files:

import { loadConfig, defineConfig } from '@lsst/pik-core';

// Load config (looks for pik.config.ts, .pik.config.ts, etc.)
const config = await loadConfig();

// Type-safe config definition
export default defineConfig({
  select: { include: ['src/**/*.ts'] },
  worktree: { baseDir: '../' },
});

Creating Plugins

Create custom plugins using the PikPlugin interface:

import type { Command } from 'commander';
import type { PikPlugin } from '@lsst/pik-core';

interface MyPluginConfig {
  apiKey: string;
}

export function myPlugin(config: MyPluginConfig): PikPlugin {
  return {
    name: 'My Plugin',
    description: 'Does something cool',
    command: 'my',
    aliases: ['m'],

    register(program: Command) {
      program
        .command('my')
        .alias('m')
        .description('My custom command')
        .action(() => {
          console.log(`Using: ${config.apiKey}`);
        });
    },
  };
}

API

Parser

// Create parser for file extension
const parser = Parser.forExtension('ts');

// Parse content
const result = parser.parse(content);
// result.selectors: Selector[]
// result.content: string

SingleSwitcher

// Create switcher for file extension
const switcher = SingleSwitcher.forExtension('ts');

// Switch to option (deactivates all others)
const newContent = switcher.switch(content, selector, 'optionName');

CommentStyle

import { CommentStyle } from '@lsst/pik-core';

// Get comment style for extension
const style = CommentStyle.fromExtension('py'); // { lineComment: '#' }

// Register custom style
CommentStyle.register('custom', new CommentStyle(';;'));

isValidPlugin

import { isValidPlugin } from '@lsst/pik-core';

// Validate a plugin object
if (isValidPlugin(obj)) {
  // obj is PikPlugin
}

Types

interface Selector {
  name: string;
  line: number;
  options: Option[];
}

interface Option {
  name: string;
  line: number;
  content: string;
  isActive: boolean;
}

interface PikPlugin {
  name: string;
  description: string;
  command: string;
  aliases?: string[];
  register: (program: Command) => void;
}

interface PikConfig {
  plugins?: PikPlugin[];
  [pluginName: string]: unknown;
}

License

MIT