MCPcopy
hub / github.com/tdewolff/minify / Minify

Function Minify

bindings/js/go/minify.go:225–260  ·  view source on GitHub ↗

export Minify

(cOptions *C.MinifyOptions, cResult *C.MinifyResult)

Source from the content-addressed store, hash-verified

223
224//export Minify
225func Minify(cOptions *C.MinifyOptions, cResult *C.MinifyResult) {
226 opts, err := parseOptions(cOptions)
227 if err != nil {
228 setResult(cResult, err, "")
229 return
230 }
231
232 dataBytes := []byte(opts.Data)
233 if len(dataBytes) == 0 {
234 setResult(cResult, errors.New("data is required"), "")
235 return
236 }
237 mediatype, err := resolveType(opts.Type)
238 if err != nil {
239 setResult(cResult, err, "")
240 return
241 }
242 if mediatype == "" {
243 setResult(cResult, errors.New("type is required"), "")
244 return
245 }
246
247 m, err := newMinifier(opts)
248 if err != nil {
249 setResult(cResult, err, "")
250 return
251 }
252
253 outBuf := buffer.NewWriter(make([]byte, 0, len(dataBytes)))
254 if err := m.Minify(mediatype, outBuf, buffer.NewReader(dataBytes)); err != nil {
255 setResult(cResult, err, "")
256 return
257 }
258
259 setResult(cResult, nil, string(outBuf.Bytes()))
260}
261
262//export FreeCString
263func FreeCString(ptr unsafe.Pointer) {

Callers

nothing calls this directly

Calls 8

parseOptionsFunction · 0.85
setResultFunction · 0.85
lenFunction · 0.85
resolveTypeFunction · 0.85
newMinifierFunction · 0.85
MinifyMethod · 0.65
stringFunction · 0.50
BytesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…