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

Method String

minify.go:241–247  ·  view source on GitHub ↗

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

(mediatype string, v string)

Source from the content-addressed store, hash-verified

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.
241func (m *M) String(mediatype string, v string) (string, error) {
242 out := buffer.NewWriter(make([]byte, 0, len(v)))
243 if err := m.Minify(mediatype, out, buffer.NewReader([]byte(v))); err != nil {
244 return v, err
245 }
246 return string(out.Bytes()), nil
247}
248
249// Reader wraps a Reader interface and minifies the stream.
250// Errors from the minifier are returned by the reader.

Callers 15

TestDataURIFunction · 0.45
MinifyMethod · 0.45
MatchMethod · 0.45
TestMinifyFunction · 0.45
TestAddFunction · 0.45
TestMatchFunction · 0.45
TestWildcardFunction · 0.45
TestReaderFunction · 0.45
TestWriterFunction · 0.45
TestResponseWriterFunction · 0.45
TestMiddlewareFunction · 0.45
ExampleM_Minify_customFunction · 0.45

Calls 4

MinifyMethod · 0.95
lenFunction · 0.85
stringFunction · 0.50
BytesMethod · 0.45

Tested by 15

TestDataURIFunction · 0.36
TestMinifyFunction · 0.36
TestAddFunction · 0.36
TestMatchFunction · 0.36
TestWildcardFunction · 0.36
TestReaderFunction · 0.36
TestWriterFunction · 0.36
TestResponseWriterFunction · 0.36
TestMiddlewareFunction · 0.36
ExampleM_Minify_customFunction · 0.36
TestMinifyFunction · 0.36
TestJSFunction · 0.36