whatisgithub

What is js-yaml-source-map?

projectdiscovery/js-yaml-source-map — explained in plain English

Analysis updated 2026-07-13 · repo last pushed 2023-03-27

1TypeScriptAudience · developerComplexity · 2/5DormantSetup · easy

In one sentence

A TypeScript library that tracks where each piece of data lives in a YAML file, so your tools can point users to exact line numbers and columns when something needs fixing.

Mindmap

mindmap
  root((repo))
    What it does
      Tracks YAML data locations
      Maps values to line numbers
      Reports exact positions
    How it works
      Works alongside js-yaml
      Builds location map while parsing
      Lookups via dotted paths
    Use cases
      Config validators
      Error reporting tools
      Highlighting YAML sections
    Limitations
      No multi-document YAML files
      No object or array keys
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Build a config validator that tells users exactly which line has the mistake.

USE CASE 2

Create a tool that highlights specific values in a YAML file for users.

USE CASE 3

Report precise error locations in YAML-based pipelines or editors.

What is it built with?

TypeScriptjs-yamlNode.js

How does it compare?

projectdiscovery/js-yaml-source-mapabidoo22/pixelorama-mcpaditya-pandey/slate
Stars111
LanguageTypeScriptTypeScriptTypeScript
Last pushed2023-03-27
MaintenanceDormant
Setup difficultyeasymoderateeasy
Complexity2/53/52/5
Audiencedevelopervibe codergeneral

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

Just install the npm package alongside js-yaml and import it into your TypeScript project.

So what is it?

js-yaml-source-map is a tool that helps your code remember exactly where each piece of data came from in a YAML file. When a program reads a YAML file, it usually turns the text into a plain data object, losing track of original line numbers and positions. This library keeps that connection alive, so if you have a specific value in mind, you can find out exactly which line and column it lives on in the original file. You use it alongside js-yaml, a popular YAML parser. As js-yaml reads your file, this tool quietly listens and builds a map of every piece of data and its location. Later, you can ask it to look up any value using a simple path, like "fruits" or "people.0.age," and it returns the line number, column, and character position where that value appears in the source text. This is useful for anyone building tools that work with YAML files and need to report errors or highlight specific sections. For example, if you are building a configuration validator and a user has a mistake on a deeply nested setting, you could use this to tell them exactly which line to fix. Instead of just saying "something is wrong," your tool could point them to line 16, column 12, where the problematic value actually sits. The library handles a few different ways of asking for locations. You can use a dotted string like "states.NY.capital," an array-style path like ".people[1].name," or pass an array of keys. The README does note some limitations: it does not work with files containing multiple YAML documents in one file, and it cannot handle arrays or objects used as keys in the YAML itself.

Copy-paste prompts

Prompt 1
Install js-yaml-source-map alongside js-yaml in my TypeScript project, then parse a YAML config file and look up the line number for the value at the path 'database.host' so I can report it in an error message.
Prompt 2
Use js-yaml-source-map to parse a YAML file with nested keys like 'people[0].name' and get the exact line and column where that value appears, then print a user-friendly error pointing to that location.
Prompt 3
Help me add js-yaml-source-map to my existing js-yaml parsing code so I can build a validator that tells users exactly which line and column to fix when a value is wrong.

Frequently asked questions

What is js-yaml-source-map?

A TypeScript library that tracks where each piece of data lives in a YAML file, so your tools can point users to exact line numbers and columns when something needs fixing.

What language is js-yaml-source-map written in?

Mainly TypeScript. The stack also includes TypeScript, js-yaml, Node.js.

Is js-yaml-source-map actively maintained?

Dormant — no commits in 2+ years (last push 2023-03-27).

How hard is js-yaml-source-map to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is js-yaml-source-map for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.