Skip to content

Commit b5c0d4b

Browse files
committed
feat: esm migration
1 parent 0fd5209 commit b5c0d4b

262 files changed

Lines changed: 2820 additions & 13854 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/csv-generate/lib/browser/index.js

Lines changed: 68 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -2,81 +2,26 @@
22
(function (Buffer){(function (){
33
"use strict";
44

5-
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; } } }; }
6-
7-
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); }
8-
9-
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; }
10-
11-
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); }
12-
13-
/*
14-
CSV Generate - main module
15-
16-
Please look at the [project documentation](https://csv.js.org/generate/) for
17-
additional information.
18-
*/
19-
var stream = require('stream');
5+
Object.defineProperty(exports, "__esModule", {
6+
value: true
7+
});
8+
exports.Generator = exports.generate = exports["default"] = void 0;
209

21-
var util = require('util');
10+
var _stream = _interopRequireDefault(require("stream"));
2211

23-
module.exports = function () {
24-
var options;
25-
var callback;
12+
var _util = _interopRequireDefault(require("util"));
2613

27-
if (arguments.length === 2) {
28-
options = arguments[0];
29-
callback = arguments[1];
30-
} else if (arguments.length === 1) {
31-
if (typeof arguments[0] === 'function') {
32-
options = {};
33-
callback = arguments[0];
34-
} else {
35-
options = arguments[0];
36-
}
37-
} else if (arguments.length === 0) {
38-
options = {};
39-
}
14+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
4015

41-
var generator = new Generator(options);
42-
43-
if (callback) {
44-
var data = [];
45-
generator.on('readable', function () {
46-
var d;
47-
48-
while (d = generator.read()) {
49-
data.push(d);
50-
}
51-
});
52-
generator.on('error', callback);
53-
generator.on('end', function () {
54-
if (generator.options.objectMode) {
55-
callback(null, data);
56-
} else {
57-
if (generator.options.encoding) {
58-
callback(null, data.join(''));
59-
} else {
60-
callback(null, Buffer.concat(data));
61-
}
62-
}
63-
});
64-
}
16+
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; } } }; }
6517

66-
return generator;
67-
};
18+
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); }
6819

69-
Generator = function (_Generator) {
70-
function Generator() {
71-
return _Generator.apply(this, arguments);
72-
}
20+
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; }
7321

74-
Generator.toString = function () {
75-
return _Generator.toString();
76-
};
22+
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); }
7723

78-
return Generator;
79-
}(function () {
24+
var Generator = function Generator() {
8025
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
8126

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

9136

92-
stream.Readable.call(this, options); // Clone and camelize options
37+
_stream["default"].Readable.call(this, options); // Clone and camelize options
38+
9339

9440
this.options = {};
9541

@@ -153,11 +99,12 @@ Generator = function (_Generator) {
15399
}
154100

155101
return this;
156-
});
102+
};
157103

158-
util.inherits(Generator, stream.Readable); // Export the class
104+
exports.Generator = Generator;
105+
106+
_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.
159107

160-
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.
161108

162109
Generator.prototype.random = function () {
163110
if (this.options.seed) {
@@ -344,6 +291,56 @@ Generator.camelize = function (str) {
344291
});
345292
};
346293

294+
var generate = function generate() {
295+
var options;
296+
var callback;
297+
298+
if (arguments.length === 2) {
299+
options = arguments[0];
300+
callback = arguments[1];
301+
} else if (arguments.length === 1) {
302+
if (typeof arguments[0] === 'function') {
303+
options = {};
304+
callback = arguments[0];
305+
} else {
306+
options = arguments[0];
307+
}
308+
} else if (arguments.length === 0) {
309+
options = {};
310+
}
311+
312+
var generator = new Generator(options);
313+
314+
if (callback) {
315+
var data = [];
316+
generator.on('readable', function () {
317+
var d;
318+
319+
while (d = generator.read()) {
320+
data.push(d);
321+
}
322+
});
323+
generator.on('error', callback);
324+
generator.on('end', function () {
325+
if (generator.options.objectMode) {
326+
callback(null, data);
327+
} else {
328+
if (generator.options.encoding) {
329+
callback(null, data.join(''));
330+
} else {
331+
callback(null, Buffer.concat(data));
332+
}
333+
}
334+
});
335+
}
336+
337+
return generator;
338+
};
339+
340+
exports.generate = generate;
341+
var _default = generate;
342+
exports["default"] = _default;
343+
347344
}).call(this)}).call(this,require("buffer").Buffer)
348345
},{"buffer":5,"stream":24,"util":43}],2:[function(require,module,exports){
349346
(function (global){(function (){

0 commit comments

Comments
 (0)