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)
| 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. |
| 231 | func (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. |