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

@yukiflowstack/json-yaml-processors

v0.2.3

Published

Generic JSON and YAML file processors with git diff extraction and format preservation

Readme

@alpnpmrepo/json-yaml-processors

Generic JSON and YAML file processors for extracting and applying changes from git diffs.

Features

  • Extract property-level changes from git diffs
  • Support for both JSON and YAML files
  • Format-preserving change application
  • TypeScript strict mode enabled
  • MIT licensed

Installation

npm install @alpnpmrepo/json-yaml-processors

Usage

Basic Example

import { FileProcessorFactory } from '@alpnpmrepo/json-yaml-processors';

// Create a processor for your file
const processor = FileProcessorFactory.createProcessor('config.json');

// Extract changes from a git diff
const result = processor.extractChanges(
  'config.json',       // source file path
  sourceContent,       // source file content
  targetContent,       // target file content
  gitDiff              // git diff output
);

// Process the extracted changes
result.changes.forEach(change => {
  console.log(`Property: ${change.propertyPath.join('.')}`);
  console.log(`Change type: ${change.changeType}`);
  console.log(`Old value: ${change.oldValue}`);
  console.log(`New value: ${change.newValue}`);
});

// Apply changes to target content
const updatedContent = processor.applyChanges(targetContent, result.changes);

JSON Processing

import { JsonProcessor } from '@alpnpmrepo/json-yaml-processors';

const jsonProcessor = new JsonProcessor();

// Extract changes
const result = jsonProcessor.extractChanges(
  'package.json',
  sourceJson,
  targetJson,
  gitDiff
);

// Changes include full property paths
result.changes.forEach(change => {
  console.log(change.propertyPath); // e.g., ["dependencies", "typescript"]
  console.log(change.newValue);     // e.g., "^5.0.0"
});

YAML Processing

import { YamlProcessor } from '@alpnpmrepo/json-yaml-processors';

const yamlProcessor = new YamlProcessor();

// Extract changes (preserves YAML formatting)
const result = yamlProcessor.extractChanges(
  'config.yaml',
  sourceYaml,
  targetYaml,
  gitDiff
);

// Supports multi-line blocks
result.changes.forEach(change => {
  if (change.sourceBlockContent) {
    console.log('Multi-line block change detected');
  }
});

API

FileProcessorFactory

Factory for creating the appropriate processor based on file extension.

static createProcessor(filePath: string): IFileProcessor

IFileProcessor

Common interface implemented by all processors.

Methods

  • canProcess(filePath: string): boolean - Check if processor can handle file
  • getFileType(): 'json' | 'yaml' | 'text' | 'binary' - Get file type identifier
  • parseContent(content: string): unknown - Parse file content
  • serializeContent(data: unknown, originalContent?: string): string - Serialize data
  • extractChanges(sourceFilePath: string, sourceContent: string, targetContent: string, gitDiff: string): IExtractChangesResult - Extract changes from git diff
  • applyChanges(targetContent: string, changes: IFileChange[]): string - Apply changes to content

IFileChange

Represents a single property change.

interface IFileChange {
  id: string;                  // Unique identifier
  file: string;                // File path
  fileType: 'json' | 'yaml';   // File type
  changeType: 'add' | 'modify' | 'delete';
  propertyPath: string[];      // Hierarchical path (e.g., ["server", "port"])
  lineNumber: number;          // Line number in file
  oldValue?: unknown;          // Previous value (for modify/delete)
  newValue: unknown;           // New value (for add/modify)
  sourceBlockContent?: string; // For YAML multi-line blocks
}

Architecture

This package provides pure file processing

It focuses solely on: ✅ Parsing JSON/YAML files ✅ Extracting changes from git diffs ✅ Applying changes while preserving formatting

License

MIT