From 7261a26c7d5ed464506f63a6b924835123892396 Mon Sep 17 00:00:00 2001 From: Jan Kuri Date: Mon, 13 Nov 2017 00:36:54 +0100 Subject: [PATCH] style(): update code style for handling allowed extensions --- src/ngx-uploader/classes/ngx-uploader.class.ts | 11 +++++------ src/ngx-uploader/module/ngx-uploader.module.ts | 1 - 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/ngx-uploader/classes/ngx-uploader.class.ts b/src/ngx-uploader/classes/ngx-uploader.class.ts index 1c012c76..bc602cce 100644 --- a/src/ngx-uploader/classes/ngx-uploader.class.ts +++ b/src/ngx-uploader/classes/ngx-uploader.class.ts @@ -37,17 +37,16 @@ export class NgUploaderService { } handleFiles(incomingFiles: FileList): void { - let allowedIncomingFiles: File[] = []; - - for (let i = 0; i < incomingFiles.length; i++) { - let checkFile = incomingFiles[i]; + const allowedIncomingFiles: File[] = [].reduce.call(incomingFiles, (acc: File[], checkFile: File, i: number) => { if (this.isContentTypeAllowed(checkFile.type)) { - allowedIncomingFiles.push(checkFile); + acc = acc.concat(checkFile); } else { const rejectedFile: UploadFile = this.makeUploadFile(checkFile, i); this.serviceEvents.emit({ type: 'rejected', file: rejectedFile }); } - } + + return acc; + }, []); this.queue.push(...[].map.call(allowedIncomingFiles, (file: File, i: number) => { const uploadFile: UploadFile = this.makeUploadFile(file, i); diff --git a/src/ngx-uploader/module/ngx-uploader.module.ts b/src/ngx-uploader/module/ngx-uploader.module.ts index 0f58ee1a..9f9ceb6d 100644 --- a/src/ngx-uploader/module/ngx-uploader.module.ts +++ b/src/ngx-uploader/module/ngx-uploader.module.ts @@ -13,4 +13,3 @@ import { NgFileSelectDirective } from '../directives/ng-file-select.directive'; ] }) export class NgUploaderModule {} -