sniff

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package sniff detects the module format of a JavaScript file from its bytes. No JS parser; it strips string and comment content and looks for reserved-token signatures that survive minification. Best-effort.

Index

Constants

View Source
const (
	ESM      = "esm"
	UMD      = "umd"
	IIFE     = "iife"
	CJS      = "cjs"
	AMD      = "amd"
	SystemJS = "system"
	Unknown  = "unknown"
)

Variables

This section is empty.

Functions

func Format

func Format(src []byte) string

Format detects the module format. Order matters: UMD wrappers contain markers for several other formats, so UMD wins first.

func StripSourcemapURL

func StripSourcemapURL(src []byte) []byte

StripSourcemapURL removes every sourceMappingURL directive, preserving surrounding newlines so stack traces stay aligned.

Types

This section is empty.

Jump to

Keyboard shortcuts

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