json-to-csv-in-browser
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -1,2 +0,5 @@ | ||
export function download(filename, text) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.download = void 0; | ||
function download(filename, text) { | ||
var element = document.createElement('a'); | ||
@@ -10,4 +13,5 @@ element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); | ||
} | ||
exports.download = download; | ||
// Start file download. | ||
// download("hello.txt","This is the content of my file :)"); | ||
//# sourceMappingURL=download.js.map |
@@ -1,4 +0,4 @@ | ||
import { JsonArray } from "./JsonArray.js"; | ||
import { download } from "./download.js"; | ||
import { JsonArray } from "./JsonArray"; | ||
import { download } from "./download"; | ||
export { JsonArray, download }; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,4 +0,8 @@ | ||
import { JsonArray } from "./JsonArray.js"; | ||
import { download } from "./download.js"; | ||
export { JsonArray, download }; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.download = exports.JsonArray = void 0; | ||
var JsonArray_1 = require("./JsonArray"); | ||
Object.defineProperty(exports, "JsonArray", { enumerable: true, get: function () { return JsonArray_1.JsonArray; } }); | ||
var download_1 = require("./download"); | ||
Object.defineProperty(exports, "download", { enumerable: true, get: function () { return download_1.download; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -1,18 +0,22 @@ | ||
export class JsonArray { | ||
constructor(JsonArray) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.JsonArray = void 0; | ||
var JsonArray = /** @class */ (function () { | ||
function JsonArray(JsonArray) { | ||
this._JsonArray = JsonArray; | ||
this.setHeaders(); | ||
} | ||
convertToCSVstring() { | ||
let str = this._headers.toString(); | ||
this._JsonArray.forEach(arr => { | ||
let line = ""; | ||
this._headers.forEach(head => { | ||
let val = arr[head] === undefined ? "" : arr[head]; | ||
val = val.toString().search(",") >= 0 ? `"${val}"` : val; | ||
JsonArray.prototype.convertToCSVstring = function () { | ||
var _this = this; | ||
var str = this._headers.toString(); | ||
this._JsonArray.forEach(function (arr) { | ||
var line = ""; | ||
_this._headers.forEach(function (head) { | ||
var val = arr[head] === undefined ? "" : arr[head]; | ||
val = val.toString().search(",") >= 0 ? "\"" + val + "\"" : val; | ||
if (line.length) { | ||
line = `${line}, ${val}`; | ||
line = line + ", " + val; | ||
} | ||
else { | ||
line = `${val === undefined ? "" : val}`; | ||
line = "" + (val === undefined ? "" : val); | ||
} | ||
@@ -23,7 +27,9 @@ }); | ||
return str; | ||
} | ||
setHeaders() { | ||
this._headers = Object.keys(this._JsonArray[0]).map(key => key); | ||
} | ||
} | ||
}; | ||
JsonArray.prototype.setHeaders = function () { | ||
this._headers = Object.keys(this._JsonArray[0]).map(function (key) { return key; }); | ||
}; | ||
return JsonArray; | ||
}()); | ||
exports.JsonArray = JsonArray; | ||
//# sourceMappingURL=JsonArray.js.map |
{ | ||
"name": "json-to-csv-in-browser", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "This converts the json array in the browser to csv file that can be stored in disc", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"dev" : "tsc -p ." | ||
"dev" : "tsc -p . && cd lib && browserify index.js -o bundle.js && cd ../ && yalc publish && cd test && yalc update json-to-csv-in-browser && browserify client.js -o bundle.js" | ||
}, | ||
@@ -9,0 +9,0 @@ "repository": { |
@@ -1,5 +0,5 @@ | ||
import {JsonArray} from "./JsonArray.js" | ||
import {download} from "./download.js" | ||
import {JsonArray} from "./JsonArray" | ||
import {download} from "./download" | ||
export {JsonArray, download} | ||
@@ -7,4 +7,4 @@ { | ||
// "incremental": true, /* Enable incremental compilation */ | ||
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ | ||
"module": "es2015", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ | ||
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ | ||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ | ||
// "lib": [], /* Specify library files to be included in the compilation. */ | ||
@@ -11,0 +11,0 @@ // "allowJs": true, /* Allow javascript files to be compiled. */ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19634
20
234
2