async getFilesByExt()

in src/io/base.ts [73:93]


  async getFilesByExt(...extensions: string[]) {
    for (let i = 0; i < extensions.length; i++) {
      const ext = extensions[i];
      if (ext.indexOf('.') !== 0) {
        throw new Error("File extension must start with '.'");
      }
    }

    const filesObject = await this.getFiles();
    const files: string[] = [];

    Object.keys(filesObject).forEach((filename) => {
      extensions.forEach((ext) => {
        if (filename.endsWith(ext)) {
          files.push(filename);
        }
      });
    });

    return files;
  }