@sigeo/export-to-csv
Advanced tools
Comparing version 0.1.0 to 0.2.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var isEmpty = require("lodash/isEmpty"); | ||
var moment = require("moment"); | ||
var exportToCsv = function (data, fileName) { | ||
if (isEmpty(data)) { | ||
return new Error("Export CSV - You should pass me an array of arrays!"); | ||
} | ||
var name = fileName || moment().format("YYYY-MM-DD"); | ||
var csvContent = "data:text/csv;charset=utf-8," + (data && data.map(function (e) { return e.join(","); }).join("\n")); | ||
var encodedUri = encodeURI(csvContent); | ||
var link = document.createElement("a"); | ||
link.setAttribute("href", encodedUri); | ||
link.setAttribute("download", name + ".csv"); | ||
document.body.appendChild(link); | ||
link.click(); | ||
document.body.removeChild(link); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports["default"] = void 0; | ||
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty")); | ||
var _moment = _interopRequireDefault(require("moment")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
var exportToCsv = function exportToCsv(data, fileName) { | ||
if ((0, _isEmpty["default"])(data)) { | ||
return new Error('Export CSV - You should pass me an array of arrays!'); | ||
} | ||
var name = fileName || (0, _moment["default"])().format('YYYY-MM-DD'); | ||
var csvContent = "data:text/csv;charset=utf-8,".concat(data && data.map(function (e) { | ||
return e.join(','); | ||
}).join('\n')); | ||
var encodedUri = encodeURI(csvContent); | ||
var link = document.createElement('a'); | ||
link.setAttribute('href', encodedUri); | ||
link.setAttribute('download', "".concat(name, ".csv")); | ||
document.body.appendChild(link); | ||
link.click(); | ||
document.body.removeChild(link); | ||
}; | ||
exports.default = exportToCsv; | ||
var _default = exportToCsv; | ||
exports["default"] = _default; |
{ | ||
"name": "@sigeo/export-to-csv", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Export to CSV - Simple way to generate a CSV from Vanilla JS!", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"build": "./node_modules/.bin/tsc", | ||
"build": "./node_modules/@babel/cli/bin/babel.js index.js -d lib --copy-files", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
@@ -20,7 +20,11 @@ }, | ||
"homepage": "https://github.com/sigeodev/export-to-csv#readme", | ||
"devDependencies": { | ||
"@babel/cli": "^7.4.4", | ||
"@babel/core": "^7.4.4", | ||
"@babel/preset-env": "^7.4.4" | ||
}, | ||
"dependencies": { | ||
"lodash": "^4.17.11", | ||
"moment": "^2.24.0", | ||
"typescript": "^3.5.1" | ||
"moment": "^2.24.0" | ||
} | ||
} |
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
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
39451
2
3
42
- Removedtypescript@^3.5.1
- Removedtypescript@3.9.10(transitive)