jsread

package
v0.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package jsread reads TypeScript and JavaScript files for the env and outbound plugins: the environment variable names the code reads and the public hosts it calls, is configured for, or mentions.

esbuild turns TS, TSX and JSX into plain JavaScript (types and JSX gone) with a source map; tdewolff's JavaScript lexer splits that into tokens (strings, template literals, comments and regular expressions handled as the language defines them); the patterns below are matched on the token stream; the source map takes each match back to its line in the original file. Nothing is executed. tdewolff's syntax tree has no positions, which is why the reader works on tokens. See https://cernly.dev/how/plugins/.

Index

Constants

View Source
const (
	Mention = "mention"
	Default = "default"
	Request = "request"
)

Usage grades, as outbound-go has them.

Variables

This section is empty.

Functions

func Package

func Package(has func(string) bool, file string) string

Package returns the folder of the nearest package.json, the unit deps-npm uses, or "." when there is none.

func Source

func Source(p string) bool

Source reports the files the reader takes: TypeScript and JavaScript sources, not declaration files, tests or minified bundles.

Types

type Env

type Env struct {
	Name string
	Line int
}

type Host

type Host struct {
	Host  string
	Usage string
	Line  int
}

type Result

type Result struct {
	Env   []Env
	Hosts []Host
}

func Read

func Read(r *repo.Repo, file string, src []byte) (Result, error)

Read reads one file. The result is cached for the scan by path and content, since the env and outbound plugins both read every file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL