Socket
Socket
Sign inDemoInstall

csv-generate

Package Overview
Dependencies
0
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.4 to 0.0.5

.npmignore

140

lib/index.js

@@ -8,61 +8,36 @@ // Generated by CoffeeScript 1.7.1

module.exports = function() {
var callback, data, generator, options;
if (arguments.length === 2) {
options = arguments[0];
callback = arguments[1];
} else if (arguments.length === 1) {
if (typeof arguments[0] === 'function') {
options = {};
callback = arguments[0];
} else {
options = arguments[0];
}
} else if (arguments.length === 0) {
options = {};
}
generator = new Generator(options);
if (callback) {
data = [];
generator.on('readable', function() {
var d, _results;
_results = [];
while (d = generator.read()) {
_results.push(data.push(options.objectMode ? d : d.toString()));
}
return _results;
});
generator.on('error', callback);
generator.on('end', function() {
return callback(null, options.objectMode ? data : data.join(''));
});
}
return generator;
};
/*
`generate([options])`: Generate random CSV data
================================================
This function is provided for conveniency in case you need to generate random CSV data.
Note, it is quite simple at the moment, more functionnalities could come later. Feel free
to ask for features and to participate by writting issues and preparing push requests.
Options may include
* `duration`
Period to run in milliseconds, default to 4 minutes.
* `columns`
Define the number of generated fields and the generation
method. If columns is an integer, it corresponds to the
number of fields. If it is an array, each element correspond
to a field. If the element is a function, the function will generate
the field value, if it is a string, it call the registered
function of the same name.
* `max_word_length`
Maximum number of characters per word.
* `seed`
Generate idempotent random characters if a number provided
* `length`
Number of lines to read.
* `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
Starting a generation:
```coffee
generate = require 'csv-generate'
data = []
generator = generate columns: ['int', 'bool'], seed: 1, duration: 1000
generator.on 'readable', ->
while(d = generator.read())
data.push d
generator.on 'error', (err) ->
console.log err.message
generator.on 'end', ->
console.log data
```
The module is also accessible through the `csv` module:
```coffee
csv = require 'csv'
csv.generate(seed: 1).pipe(csv.stringify).pipe(process.stdout)
```
*/
Generator = function(options) {

@@ -123,9 +98,4 @@ var i, v, _base, _base1, _base2, _base3, _base4, _base5, _base6, _base7, _base8, _i, _len, _ref;

module.exports.Generator = Generator;
/*
`random`
Generate a random number between 0 and 1 with 2 decimals.
*/
Generator.prototype.random = function() {

@@ -225,43 +195,1 @@ if (this.options.seed) {

};
/*
`generate([options])`
`generate([options], callback)`
*/
module.exports = function() {
var callback, data, generator, options;
if (arguments.length === 2) {
options = arguments[0];
callback = arguments[1];
} else if (arguments.length === 1) {
if (typeof arguments[0] === 'function') {
options = {};
callback = arguments[0];
} else {
options = arguments[0];
}
} else if (arguments.length === 0) {
options = {};
}
generator = new Generator(options);
if (callback) {
data = [];
generator.on('readable', function() {
var d, _results;
_results = [];
while (d = generator.read()) {
_results.push(data.push(options.objectMode ? d : d.toString()));
}
return _results;
});
generator.on('error', callback);
generator.on('end', function() {
return callback(null, options.objectMode ? data : data.join(''));
});
}
return generator;
};
module.exports.Generator = Generator;
{
"version": "0.0.4",
"version": "0.0.5",
"name": "csv-generate",
"description": "CSV and object generation implementing the Node.js `stream.Readable` API",
"keywords": [ "stream", "generate", "csv", "object" ],
"licenses": "BSD-3-Clause",
"repository": {

@@ -9,3 +11,3 @@ "type": "git",

},
"keywords": [ "stream", "generate", "csv", "object" ],
"homepage": "http://csv.adaltas.com/generate/",
"dependencies": {},

@@ -20,4 +22,6 @@ "devDependencies": {

"scripts": {
"test": "make test"
"coffee": "./node_modules/.bin/coffee -b -o lib src",
"pretest": "./node_modules/.bin/coffee -b -o lib src",
"test": "NODE_ENV=test ./node_modules/.bin/mocha --compilers coffee:coffee-script/register --reporter dot"
}
}

@@ -6,5 +6,7 @@ [![Build Status](https://secure.travis-ci.org/wdavidw/node-csv-generate.png)](http://travis-ci.org/wdavidw/node-csv-generate)

This module export a flexible generator of CSV string and Javascript objects
This package provides a flexible generator of CSV strings and Javascript objects
implementing the Node.js `stream.Readable` API.
[Documentation for the "csv-generate" package is available here][home].
Features includes:

@@ -14,2 +16,3 @@

* `stream.Readable` implementation
* BSD License

@@ -88,3 +91,3 @@ Usage

To generate the JavaScript files, run `make build`.
To generate the JavaScript files, run `npm run coffee`.

@@ -99,3 +102,4 @@ The test suite is run online with [Travis][travis] against the versions

[home]: http://csv.adaltas.com/generate/
[csv]: https://github.com/wdavidw/node-csv
[travis]: https://travis-ci.org/#!/wdavidw/node-csv-generate
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc