javascript

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package javascript implements the JavaScript (and TypeScript) import extractor. The dispatcher in package depusage routes both Language values here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DepKey

func DepKey(raw string) string

DepKey normalizes a raw npm module string to a lockfile-key form.

"lodash"           -> "lodash"
"lodash/merge"     -> "lodash"
"@scope/pkg"       -> "@scope/pkg"
"@scope/pkg/sub"   -> "@scope/pkg"
"./foo"            -> ""    (relative)
"../foo"           -> ""    (relative)
"/abs/path"        -> ""    (absolute)
"node:fs"          -> ""    (node builtin)
""                 -> ""

Built-in modules (node:fs, node:path, etc.) and bare names that match the historic builtin list (fs, path, http, ...) are NOT stripped here — that's the consumer's job. depusage only refuses the patterns that can never be a registry dep: relative, absolute, and node: scheme.

func Extract

func Extract(body []byte, opts extract.Options) (extract.Result, error)

Extract runs the JS/TS import pass over body.

func IsRelative

func IsRelative(raw string) bool

IsRelative reports whether the raw module string is a relative or absolute filesystem path. Used by the extractor to flag the extract.ImportRelative kind.

Types

This section is empty.

Jump to

Keyboard shortcuts

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