How to use list filter on ssh2-sftp-client

359 views Asked by At

I'm not quite sure how to use the filter on the list method of ssh2-sftp-client, my objective was to only list files which include a certain string.

The npm page is not particularly helpful on this.

          let data = await sftp.list(
            'engine/',
            (name: string) => !name.includes('READ')
          );

This returns an error, saying that includes is not a function.

Any guidance you guys could provide would be great.

1

There are 1 answers

0
Kita On

Got it,

      let data = await sftp.list('engine/', function (item: any) {
        return !item.name.includes('READ');
      });

Was waiting for a string, when it was an array of objects.

Thanks!