CSV and object generator
输出文本,对象或数组
This package provides a flexible generator of CSV strings and Javascript objects implementing the Node.js stream.Readable API.
Source code for this project is available on GitHub.
Features includes:
random or pseudo-random seed based generation stream.Readable implementation
使用
Run npm install csv
to install the full csv module or run npm install csv-generate
if you are only interested by the CSV parser.
Use the callback style API for simplicity or the stream based API for scalability.
回调 API
- generate([options])
Node.js 流 API
- generate([options], callback)
For additionnal usage and example, you may refer to the example page, the "samples" folder and the "test" folder.
选项
duration
以毫秒为单位运行周期, 默认4分.
columns
限定生成字段的数量和生成方法.
- 如果是整数, 它对应于字段的数量.
- 如果是数组, 每个元素对应一字段.
- 如果是函数, 该函数将生成的域值.
- 如果是字符, 调用注册的同名函数.
max_word_length
每个字的最大字符数.
seed
如果提供了一个数字,生成幂等随机字符
length
阅读行数.
objectMode
Whether this stream should behave as a stream of objects. Meaning that stream.read(n) returns a single value instead of a Buffer of size n. Default=false
highWaterMark
The maximum number of bytes to store in the internal buffer before ceasing to read from the underlying resource. Default=16kb
所有选项都是可选的.
迁移
Most of the generator is imported from its parent project CSV in a effort to split it between the generator, the parser, the transformer and the stringifier.