Skip to content

Commit

Permalink
feat: esm migration
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Sep 17, 2021
1 parent 0fd5209 commit b5c0d4b
Show file tree
Hide file tree
Showing 262 changed files with 2,820 additions and 13,854 deletions.
139 changes: 68 additions & 71 deletions packages/csv-generate/lib/browser/index.js
Expand Up @@ -2,81 +2,26 @@
(function (Buffer){(function (){
"use strict";

function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }

function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

/*
CSV Generate - main module
Please look at the [project documentation](https://csv.js.org/generate/) for
additional information.
*/
var stream = require('stream');
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Generator = exports.generate = exports["default"] = void 0;

var util = require('util');
var _stream = _interopRequireDefault(require("stream"));

module.exports = function () {
var options;
var callback;
var _util = _interopRequireDefault(require("util"));

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 = {};
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

var generator = new Generator(options);

if (callback) {
var data = [];
generator.on('readable', function () {
var d;

while (d = generator.read()) {
data.push(d);
}
});
generator.on('error', callback);
generator.on('end', function () {
if (generator.options.objectMode) {
callback(null, data);
} else {
if (generator.options.encoding) {
callback(null, data.join(''));
} else {
callback(null, Buffer.concat(data));
}
}
});
}
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }

return generator;
};
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

Generator = function (_Generator) {
function Generator() {
return _Generator.apply(this, arguments);
}
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

Generator.toString = function () {
return _Generator.toString();
};
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

return Generator;
}(function () {
var Generator = function Generator() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

// Convert Stream Readable options if underscored
Expand All @@ -89,7 +34,8 @@ Generator = function (_Generator) {
} // Call parent constructor


stream.Readable.call(this, options); // Clone and camelize options
_stream["default"].Readable.call(this, options); // Clone and camelize options


this.options = {};

Expand Down Expand Up @@ -153,11 +99,12 @@ Generator = function (_Generator) {
}

return this;
});
};

util.inherits(Generator, stream.Readable); // Export the class
exports.Generator = Generator;

_util["default"].inherits(Generator, _stream["default"].Readable); // Generate a random number between 0 and 1 with 2 decimals. The function is idempotent if it detect the "seed" option.

module.exports.Generator = Generator; // Generate a random number between 0 and 1 with 2 decimals. The function is idempotent if it detect the "seed" option.

Generator.prototype.random = function () {
if (this.options.seed) {
Expand Down Expand Up @@ -344,6 +291,56 @@ Generator.camelize = function (str) {
});
};

var generate = function generate() {
var options;
var callback;

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 = {};
}

var generator = new Generator(options);

if (callback) {
var data = [];
generator.on('readable', function () {
var d;

while (d = generator.read()) {
data.push(d);
}
});
generator.on('error', callback);
generator.on('end', function () {
if (generator.options.objectMode) {
callback(null, data);
} else {
if (generator.options.encoding) {
callback(null, data.join(''));
} else {
callback(null, Buffer.concat(data));
}
}
});
}

return generator;
};

exports.generate = generate;
var _default = generate;
exports["default"] = _default;

}).call(this)}).call(this,require("buffer").Buffer)
},{"buffer":5,"stream":24,"util":43}],2:[function(require,module,exports){
(function (global){(function (){
Expand Down

0 comments on commit b5c0d4b

Please sign in to comment.