Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jsonexport

Package Overview
Dependencies
Maintainers
3
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonexport - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

bin/builddist.js

7

CHANGELOG.md
## Change log
----------------------
- v2.2.0 - Better browser distribution
- Browser based files in dist are overwritten for best browser building
- Found unused code and removed
- Updated all depencies
- Some had minor version changes
- This package now changes its minor from 2.1 to 2.2
- Added npm-run-all to safely run npm muli commands across all operating systems
- v2.0.11 - Tailored for browser by including distribution folder (ackerapple)

@@ -4,0 +11,0 @@ - v2.0.10 - enclose strings containing quotes with more quotes (dozen1488)

4

dist/core/join-rows.js
'use strict';
var os = require('os');
var EOL = require('./eol');
var helper = require('./helper');

@@ -11,4 +11,4 @@

//Merge all rows in a single output with the correct End of Line string
var r = rows.join(join || os.EOL || '\n');
var r = rows.join(join || EOL || '\n');
return r;
};
/* jshint node:true */
'use strict';
'use strict';
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Transform = require('stream').Transform;
var Stream = function (_Transform) {
_inherits(Stream, _Transform);
function Stream(parser) {
_classCallCheck(this, Stream);
var _this = _possibleConstructorReturn(this, (Stream.__proto__ || Object.getPrototypeOf(Stream)).call(this));
_this._parser = parser;
_this._options = parser._options;
_this._headers = _this._options.headers || [];
_this._hasHeaders = false;
_this._lastError = null;
return _this;
var Stream = function (_Transform) {
throw new Error("jsonexport called without third argument as a callback and is required")
}
_createClass(Stream, [{
key: '_mergeChunk',
value: function _mergeChunk(chunk) {
var self = this;
self._extra = self._extra || "";
// Memory limit
if (self._extra.length > chunk.toString().length * 3) return null;
// Remove starting comma
if (self._extra.charAt(0) == ',') self._extra = self._extra.substr(1);
// Append extra to chunk
chunk = self._extra + chunk.toString();
// Clear extra memory
if (self._extra.length > 0) self._extra = "";
return chunk;
}
}, {
key: '_wrapArray',
value: function _wrapArray(data) {
if (data.charAt(0) != '[') data = '[' + data;
if (data.charAt(data.length - 1) != ']') data += ']';
return data;
}
}, {
key: '_transform',
value: function _transform(chunk, encoding, done) {
var self = this;
var json = null;
// Append extra data to chunk data
chunk = this._mergeChunk(chunk);
if (!chunk) return done(this._lastError);
// Split chunk in objects
var parts = chunk.split('}');
while (json === null && parts.length > 0) {
try {
var data = self._wrapArray(parts.join('}'));
json = JSON.parse(data);
} catch (ex) {
this._lastError = ex;
var extraChunk = parts.pop();
self._extra = extraChunk + (self._extra || "");
if (parts.length > 0) parts[parts.length - 1] += "}";
}
}
if (!json) return done();
this._parser.parse(json, function (err, csvChunk) {
if (err) return done(err);
if (!self.hasHeaders) {
self.hasHeaders = true;
self.push(self._parser.headers);
}
self.push(self._options.endOfLine + csvChunk);
done();
}, true);
}
}]);
return Stream;
}(Transform);
module.exports = Stream;
module.exports = Stream;

@@ -12,4 +12,3 @@ /* jshint node:true */

var os = require('os');
var Transform = require('stream').Transform;
var EOL = require('../core/eol');
var joinRows = require('../core/join-rows');

@@ -251,21 +250,21 @@ var Handler = require('./handler');

var defaultOptions = {
headers: [], // Array
rename: [], // Array
headerPathString: '.', // String
rowDelimiter: ',', // String
textDelimiter: '"', // String
arrayPathString: ';', // String
undefinedString: '', // String
endOfLine: os.EOL || '\n', // String
mainPathItem: null, // String
booleanTrueString: null, // String
booleanFalseString: null, // String
includeHeaders: true, // Boolean
fillGaps: false, // Boolean
verticalOutput: true, // Boolean
headers: [], // Array
rename: [], // Array
headerPathString: '.', // String
rowDelimiter: ',', // String
textDelimiter: '"', // String
arrayPathString: ';', // String
undefinedString: '', // String
endOfLine: EOL || '\n', // String
mainPathItem: null, // String
booleanTrueString: null, // String
booleanFalseString: null, // String
includeHeaders: true, // Boolean
fillGaps: false, // Boolean
verticalOutput: true, // Boolean
//Handlers
handleString: undefined, // Function
handleNumber: undefined, // Function
handleBoolean: undefined, // Function
handleDate: undefined // Function
handleString: undefined, // Function
handleNumber: undefined, // Function
handleBoolean: undefined, // Function
handleDate: undefined // Function
};

@@ -272,0 +271,0 @@ return Object.assign({}, defaultOptions, userOptions);

@@ -1,2 +0,2 @@

var os = require('os');
const EOL = require('./eol');
const helper = require('./helper');

@@ -10,4 +10,4 @@

//Merge all rows in a single output with the correct End of Line string
var r = rows.join(join || os.EOL || '\n');
var r = rows.join(join || EOL || '\n');
return r;
};

@@ -7,4 +7,3 @@ /* jshint node:true */

*/
const os = require('os');
const Transform = require('stream').Transform;
const EOL = require('../core/eol')
const joinRows = require('../core/join-rows');

@@ -160,21 +159,21 @@ const Handler = require('./handler');

let defaultOptions = {
headers: [], // Array
rename: [], // Array
headerPathString: '.', // String
rowDelimiter: ',', // String
textDelimiter: '"', // String
arrayPathString: ';', // String
undefinedString: '', // String
endOfLine: os.EOL || '\n', // String
mainPathItem: null, // String
booleanTrueString: null, // String
booleanFalseString: null, // String
includeHeaders: true, // Boolean
fillGaps: false, // Boolean
verticalOutput: true, // Boolean
headers: [], // Array
rename: [], // Array
headerPathString: '.', // String
rowDelimiter: ',', // String
textDelimiter: '"', // String
arrayPathString: ';', // String
undefinedString: '', // String
endOfLine: EOL || '\n', // String
mainPathItem: null, // String
booleanTrueString: null, // String
booleanFalseString: null, // String
includeHeaders: true, // Boolean
fillGaps: false, // Boolean
verticalOutput: true, // Boolean
//Handlers
handleString: undefined, // Function
handleNumber: undefined, // Function
handleBoolean: undefined, // Function
handleDate: undefined, // Function
handleString: undefined, // Function
handleNumber: undefined, // Function
handleBoolean: undefined, // Function
handleDate: undefined, // Function
};

@@ -181,0 +180,0 @@ return Object.assign({}, defaultOptions, userOptions);

{
"name": "jsonexport",
"version": "2.1.0",
"version": "2.2.0",
"description": "Makes easy to convert JSON to CSV",

@@ -9,3 +9,5 @@ "main": "./lib",

"lint": "./node_modules/.bin/jshint ./lib/index.js",
"build:dist": "babel lib --out-dir dist --presets=env"
"build:dist": "npm-run-all build:dist:js build:dist:overwrite",
"build:dist:js": "babel lib --out-dir dist --presets=env",
"build:dist:overwrite": "node ./bin/builddist.js"
},

@@ -48,7 +50,8 @@ "pre-commit": [

"babel-cli": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-preset-env": "^1.7.0",
"benchmark": "^2.1.4",
"chai": "^4.0.1",
"chai": "^4.1.2",
"jshint": "^2.9.5",
"mocha": "^5.1.1",
"mocha": "^5.2.0",
"npm-run-all": "^4.1.3",
"pre-commit": "^1.2.2"

@@ -55,0 +58,0 @@ },

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc