Skip to content

Commit

Permalink
fix: fallback to setTimeout is setImmediate is undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Nov 1, 2021
1 parent 899dc67 commit 3d6a2d0
Show file tree
Hide file tree
Showing 19 changed files with 198 additions and 162 deletions.
14 changes: 7 additions & 7 deletions packages/csv-parse/dist/cjs/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6253,15 +6253,15 @@ const parse = function(){
});
}
if(data !== undefined){
// Give a chance for events to be registered later
if(typeof setImmediate === 'function'){
setImmediate(function(){
parser.write(data);
parser.end();
});
}else {
const writer = function(){
parser.write(data);
parser.end();
};
// Support Deno, Rollup doesnt provide a shim for setImmediate
if(typeof setImmediate === 'function'){
setImmediate(writer);
}else {
setTimeout(writer, 0);
}
}
return parser;
Expand Down
14 changes: 7 additions & 7 deletions packages/csv-parse/dist/esm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6249,15 +6249,15 @@ const parse = function(){
});
}
if(data !== undefined){
// Give a chance for events to be registered later
if(typeof setImmediate === 'function'){
setImmediate(function(){
parser.write(data);
parser.end();
});
}else {
const writer = function(){
parser.write(data);
parser.end();
};
// Support Deno, Rollup doesnt provide a shim for setImmediate
if(typeof setImmediate === 'function'){
setImmediate(writer);
}else {
setTimeout(writer, 0);
}
}
return parser;
Expand Down
14 changes: 7 additions & 7 deletions packages/csv-parse/dist/iife/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6252,15 +6252,15 @@ var csv_parse = (function (exports) {
});
}
if(data !== undefined){
// Give a chance for events to be registered later
if(typeof setImmediate === 'function'){
setImmediate(function(){
parser.write(data);
parser.end();
});
}else {
const writer = function(){
parser.write(data);
parser.end();
};
// Support Deno, Rollup doesnt provide a shim for setImmediate
if(typeof setImmediate === 'function'){
setImmediate(writer);
}else {
setTimeout(writer, 0);
}
}
return parser;
Expand Down
14 changes: 7 additions & 7 deletions packages/csv-parse/dist/umd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6255,15 +6255,15 @@
});
}
if(data !== undefined){
// Give a chance for events to be registered later
if(typeof setImmediate === 'function'){
setImmediate(function(){
parser.write(data);
parser.end();
});
}else {
const writer = function(){
parser.write(data);
parser.end();
};
// Support Deno, Rollup doesnt provide a shim for setImmediate
if(typeof setImmediate === 'function'){
setImmediate(writer);
}else {
setTimeout(writer, 0);
}
}
return parser;
Expand Down
14 changes: 7 additions & 7 deletions packages/csv-parse/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1248,15 +1248,15 @@ const parse = function(){
});
}
if(data !== undefined){
// Give a chance for events to be registered later
if(typeof setImmediate === 'function'){
setImmediate(function(){
parser.write(data);
parser.end();
});
}else{
const writer = function(){
parser.write(data);
parser.end();
};
// Support Deno, Rollup doesnt provide a shim for setImmediate
if(typeof setImmediate === 'function'){
setImmediate(writer);
}else{
setTimeout(writer, 0);
}
}
return parser;
Expand Down
16 changes: 7 additions & 9 deletions packages/csv-stringify/dist/cjs/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5541,19 +5541,17 @@ const stringify = function(){
});
}
if(data !== undefined){
// Give a chance for events to be registered later
if(typeof setImmediate === 'function'){
setImmediate(function(){
for(const record of data){
stringifier.write(record);
}
stringifier.end();
});
}else {
const writer = function(){
for(const record of data){
stringifier.write(record);
}
stringifier.end();
};
// Support Deno, Rollup doesnt provide a shim for setImmediate
if(typeof setImmediate === 'function'){
setImmediate(writer);
}else {
setTimeout(writer, 0);
}
}
return stringifier;
Expand Down
16 changes: 7 additions & 9 deletions packages/csv-stringify/dist/esm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5537,19 +5537,17 @@ const stringify = function(){
});
}
if(data !== undefined){
// Give a chance for events to be registered later
if(typeof setImmediate === 'function'){
setImmediate(function(){
for(const record of data){
stringifier.write(record);
}
stringifier.end();
});
}else {
const writer = function(){
for(const record of data){
stringifier.write(record);
}
stringifier.end();
};
// Support Deno, Rollup doesnt provide a shim for setImmediate
if(typeof setImmediate === 'function'){
setImmediate(writer);
}else {
setTimeout(writer, 0);
}
}
return stringifier;
Expand Down
16 changes: 7 additions & 9 deletions packages/csv-stringify/dist/iife/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5540,19 +5540,17 @@ var csv_stringify = (function (exports) {
});
}
if(data !== undefined){
// Give a chance for events to be registered later
if(typeof setImmediate === 'function'){
setImmediate(function(){
for(const record of data){
stringifier.write(record);
}
stringifier.end();
});
}else {
const writer = function(){
for(const record of data){
stringifier.write(record);
}
stringifier.end();
};
// Support Deno, Rollup doesnt provide a shim for setImmediate
if(typeof setImmediate === 'function'){
setImmediate(writer);
}else {
setTimeout(writer, 0);
}
}
return stringifier;
Expand Down
16 changes: 7 additions & 9 deletions packages/csv-stringify/dist/umd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5543,19 +5543,17 @@
});
}
if(data !== undefined){
// Give a chance for events to be registered later
if(typeof setImmediate === 'function'){
setImmediate(function(){
for(const record of data){
stringifier.write(record);
}
stringifier.end();
});
}else {
const writer = function(){
for(const record of data){
stringifier.write(record);
}
stringifier.end();
};
// Support Deno, Rollup doesnt provide a shim for setImmediate
if(typeof setImmediate === 'function'){
setImmediate(writer);
}else {
setTimeout(writer, 0);
}
}
return stringifier;
Expand Down
16 changes: 7 additions & 9 deletions packages/csv-stringify/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -594,19 +594,17 @@ const stringify = function(){
});
}
if(data !== undefined){
// Give a chance for events to be registered later
if(typeof setImmediate === 'function'){
setImmediate(function(){
for(const record of data){
stringifier.write(record);
}
stringifier.end();
});
}else{
const writer = function(){
for(const record of data){
stringifier.write(record);
}
stringifier.end();
};
// Support Deno, Rollup doesnt provide a shim for setImmediate
if(typeof setImmediate === 'function'){
setImmediate(writer);
}else{
setTimeout(writer, 0);
}
}
return stringifier;
Expand Down
40 changes: 22 additions & 18 deletions packages/csv/dist/cjs/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6542,15 +6542,15 @@ const parse = function(){
});
}
if(data !== undefined){
// Give a chance for events to be registered later
if(typeof setImmediate === 'function'){
setImmediate(function(){
parser.write(data);
parser.end();
});
}else {
const writer = function(){
parser.write(data);
parser.end();
};
// Support Deno, Rollup doesnt provide a shim for setImmediate
if(typeof setImmediate === 'function'){
setImmediate(writer);
}else {
setTimeout(writer, 0);
}
}
return parser;
Expand Down Expand Up @@ -6667,13 +6667,19 @@ const transform = function(){
const transformer = new Transformer(options, handler);
let error = false;
if (records) {
setImmediate(function(){
const writer = function(){
for(const record of records){
if(error) break;
transformer.write(record);
}
transformer.end();
});
};
// Support Deno, Rollup doesnt provide a shim for setImmediate
if(typeof setImmediate === 'function'){
setImmediate(writer);
}else {
setTimeout(writer, 0);
}
}
if(callback || options.consume) {
const result = [];
Expand Down Expand Up @@ -7266,19 +7272,17 @@ const stringify = function(){
});
}
if(data !== undefined){
// Give a chance for events to be registered later
if(typeof setImmediate === 'function'){
setImmediate(function(){
for(const record of data){
stringifier.write(record);
}
stringifier.end();
});
}else {
const writer = function(){
for(const record of data){
stringifier.write(record);
}
stringifier.end();
};
// Support Deno, Rollup doesnt provide a shim for setImmediate
if(typeof setImmediate === 'function'){
setImmediate(writer);
}else {
setTimeout(writer, 0);
}
}
return stringifier;
Expand Down
40 changes: 22 additions & 18 deletions packages/csv/dist/esm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6538,15 +6538,15 @@ const parse = function(){
});
}
if(data !== undefined){
// Give a chance for events to be registered later
if(typeof setImmediate === 'function'){
setImmediate(function(){
parser.write(data);
parser.end();
});
}else {
const writer = function(){
parser.write(data);
parser.end();
};
// Support Deno, Rollup doesnt provide a shim for setImmediate
if(typeof setImmediate === 'function'){
setImmediate(writer);
}else {
setTimeout(writer, 0);
}
}
return parser;
Expand Down Expand Up @@ -6663,13 +6663,19 @@ const transform = function(){
const transformer = new Transformer(options, handler);
let error = false;
if (records) {
setImmediate(function(){
const writer = function(){
for(const record of records){
if(error) break;
transformer.write(record);
}
transformer.end();
});
};
// Support Deno, Rollup doesnt provide a shim for setImmediate
if(typeof setImmediate === 'function'){
setImmediate(writer);
}else {
setTimeout(writer, 0);
}
}
if(callback || options.consume) {
const result = [];
Expand Down Expand Up @@ -7262,19 +7268,17 @@ const stringify = function(){
});
}
if(data !== undefined){
// Give a chance for events to be registered later
if(typeof setImmediate === 'function'){
setImmediate(function(){
for(const record of data){
stringifier.write(record);
}
stringifier.end();
});
}else {
const writer = function(){
for(const record of data){
stringifier.write(record);
}
stringifier.end();
};
// Support Deno, Rollup doesnt provide a shim for setImmediate
if(typeof setImmediate === 'function'){
setImmediate(writer);
}else {
setTimeout(writer, 0);
}
}
return stringifier;
Expand Down
Loading

0 comments on commit 3d6a2d0

Please sign in to comment.