Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promise example does nt work #13

Open
mtt-artis opened this issue Jan 20, 2023 · 1 comment
Open

Promise example does nt work #13

mtt-artis opened this issue Jan 20, 2023 · 1 comment

Comments

@mtt-artis
Copy link

the example code doesnt work on my machine

const fs = require('fs');

const fileNames = ['file1.csv', 'file2.csv', 'file3.csv'];
const fileIndex = 0;
const nextStreamAsync = () => {
  return new Promise((res) => {
    if (fileIndex === fileNames.length) {
      return null;
    }
    return fs.createReadStream(fileNames[fileIndex++]);
  });
};

const combinedStream = new StreamConcat(nextStreamAsync);

but this does

const fs = require('fs');

const fileNames = ['file1.csv', 'file2.csv', 'file3.csv'];

let fileIndex = 0;
const nextStreamAsync = () => {
  return new Promise((res) => {
    if (fileIndex === filesPath.length) {
      return res(null)
    }
    return res(fs.createReadStream(filesPath[fileIndex++]))
  });
};
const combinedStream = new StreamConcat(nextStreamAsync);

you should resolve the promise

@sedenardi
Copy link
Owner

@mtt-artis Apologies for the delay, thanks for the catch! Feel free to submit a PR with that change and I'll take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants