MCPcopy
hub / github.com/esm-dev/esm.sh / encodeBuildMeta

Function encodeBuildMeta

server/build_meta.go:25–63  ·  view source on GitHub ↗
(meta *BuildMeta)

Source from the content-addressed store, hash-verified

23}
24
25func encodeBuildMeta(meta *BuildMeta) []byte {
26 buf := bytes.NewBuffer(nil)
27 buf.Write([]byte{'E', 'S', 'M', '\r', '\n'})
28 if meta.CJS {
29 buf.Write([]byte{'j', '\n'})
30 }
31 if meta.CSSInJS {
32 buf.Write([]byte{'c', '\n'})
33 }
34 if meta.TypesOnly {
35 buf.Write([]byte{'t', '\n'})
36 }
37 if meta.ExportDefault {
38 buf.Write([]byte{'e', '\n'})
39 }
40 if meta.CSSEntry != "" {
41 buf.Write([]byte{'.', ':'})
42 buf.WriteString(meta.CSSEntry)
43 buf.WriteByte('\n')
44 }
45 if meta.Dts != "" {
46 buf.Write([]byte{'d', ':'})
47 buf.WriteString(meta.Dts)
48 buf.WriteByte('\n')
49 }
50 if len(meta.Imports) > 0 {
51 for _, path := range meta.Imports {
52 buf.Write([]byte{'i', ':'})
53 buf.WriteString(path)
54 buf.WriteByte('\n')
55 }
56 }
57 if len(meta.Integrity) > 0 {
58 buf.Write([]byte{'s', ':'})
59 buf.WriteString(meta.Integrity)
60 buf.WriteByte('\n')
61 }
62 return buf.Bytes()
63}
64
65func decodeBuildMeta(data []byte) (*BuildMeta, error) {
66 meta := &BuildMeta{}

Callers 3

esmRouterFunction · 0.85
BuildMethod · 0.85
TestEncodeBuildMetaFunction · 0.85

Calls 1

WriteMethod · 0.80

Tested by 1

TestEncodeBuildMetaFunction · 0.68