Documentation
¶
Overview ¶
Package lib exposes the Ferret-facing CSV:: functions.
Index ¶
- func Decode(ctx context.Context, args ...runtime.Value) (runtime.Value, error)
- func DecodeRows(ctx context.Context, args ...runtime.Value) (runtime.Value, error)
- func DecodeRowsStream(ctx context.Context, args ...runtime.Value) (runtime.Value, error)
- func DecodeStream(ctx context.Context, args ...runtime.Value) (runtime.Value, error)
- func Encode(ctx context.Context, args ...runtime.Value) (runtime.Value, error)
- func RegisterLib(ns runtime.Namespace) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decode ¶
Decode decodes CSV text into an array of objects. When opts.header is true, the first record defines object keys; otherwise opts.columns or generated colN names are used.
@param data {String} CSV text. @param opts {Object?} Decoding options. @return {Array<Object>} Decoded objects.
func DecodeRows ¶
DecodeRows decodes CSV text into an array of raw row arrays. It keeps header rows as data and applies decoding options to each field.
@param data {String} CSV text. @param opts {Object?} Decoding options. @return {Array<Array<Any>>} Decoded row arrays.
func DecodeRowsStream ¶
DecodeRowsStream decodes CSV content from string or binary input. It returns an iterator value over row arrays keyed by the original CSV record number after parsing.
@param data {String|Binary} CSV content. @param opts {Object?} Decoding options. @return {Iterator<Array<Any>>} Iterator over decoded row arrays.
func DecodeStream ¶
DecodeStream decodes CSV content from string or binary input. It returns an iterator value over objects keyed by the original CSV record number after parsing.
@param data {String|Binary} CSV content. @param opts {Object?} Decoding options. @return {Iterator<Object>} Iterator over decoded objects.
func Encode ¶
Encode encodes an array of objects or row arrays into CSV text. Object input can emit a header row depending on opts.header and opts.columns.
@param data {Array<Any>} Objects or row arrays to encode. @param opts {Object?} Encoding options. @return {String} CSV text.
func RegisterLib ¶
RegisterLib registers the CSV::DECODE, CSV::DECODE_ROWS, CSV::DECODE_STREAM, CSV::DECODE_ROWS_STREAM, and CSV::ENCODE functions in the provided namespace.
Types ¶
This section is empty.