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

Method Bytes

minify.go:231–237  ·  view source on GitHub ↗

Bytes minifies an array of bytes (safe for concurrent use). When an error occurs it return the original array and the error. It returns an error when no such mimetype exists (ErrNotExist) or any error occurred in the minifier function.

(mediatype string, v []byte)

Source from the content-addressed store, hash-verified

229// Bytes minifies an array of bytes (safe for concurrent use). When an error occurs it return the original array and the error.
230// It returns an error when no such mimetype exists (ErrNotExist) or any error occurred in the minifier function.
231func (m *M) Bytes(mediatype string, v []byte) ([]byte, error) {
232 out := buffer.NewWriter(make([]byte, 0, len(v)))
233 if err := m.Minify(mediatype, out, buffer.NewReader(v)); err != nil {
234 return v, err
235 }
236 return out.Bytes(), nil
237}
238
239// String minifies a string (safe for concurrent use). When an error occurs it return the original string and the error.
240// It returns an error when no such mimetype exists (ErrNotExist) or any error occurred in the minifier function.

Callers 12

DataURIFunction · 0.45
UpdateErrorPositionFunction · 0.45
StringMethod · 0.45
TestMinifyFunction · 0.45
minifyStmtMethod · 0.45
minifyVarDeclMethod · 0.45
minifyExprMethod · 0.45
TestBinaryNumberFunction · 0.45
TestOctalNumberFunction · 0.45
TestHexadecimalNumberFunction · 0.45
TestStringFunction · 0.45
MinifyFunction · 0.45

Calls 2

MinifyMethod · 0.95
lenFunction · 0.85

Tested by 5

TestMinifyFunction · 0.36
TestBinaryNumberFunction · 0.36
TestOctalNumberFunction · 0.36
TestHexadecimalNumberFunction · 0.36
TestStringFunction · 0.36