From 6acbcdd172805bebb23cd8252e73a30591d5f186 Mon Sep 17 00:00:00 2001 From: Adrien Castex Date: Mon, 10 Jul 2017 14:07:10 +0200 Subject: [PATCH] Cleaned the code --- examples/v1/gatewayPhysical/ts/PhysicalGFSManager.ts | 4 ++-- examples/v1/gatewayPhysical/ts/PhysicalGateway.ts | 2 +- examples/v2/customMethod2/index.ts | 2 +- examples/v2/webResource/index.ts | 2 +- lib/helper/v2/IfParser.js | 2 +- lib/manager/PhysicalGFSManager.js | 2 +- lib/manager/v2/fileSystem/FileSystem.js | 7 +++---- lib/manager/v2/fileSystem/StandardMethods.js | 6 +++--- src/helper/v2/IfParser.ts | 2 +- src/manager/PhysicalGFSManager.ts | 2 +- src/manager/v2/fileSystem/FileSystem.ts | 7 +++---- src/manager/v2/fileSystem/StandardMethods.ts | 6 +++--- test/v2/tests.ts/lockUnlock/.createFiles.ts | 4 ++-- 13 files changed, 23 insertions(+), 25 deletions(-) diff --git a/examples/v1/gatewayPhysical/ts/PhysicalGFSManager.ts b/examples/v1/gatewayPhysical/ts/PhysicalGFSManager.ts index d6980105..2182f3f5 100644 --- a/examples/v1/gatewayPhysical/ts/PhysicalGFSManager.ts +++ b/examples/v1/gatewayPhysical/ts/PhysicalGFSManager.ts @@ -1,9 +1,9 @@ -import { SerializedObject, FSManager, Errors, IResource, ResourceType, PhysicalFSManager, PhysicalFile, PhysicalFolder, PhysicalResource } from '../../../lib/index.js' +import { SerializedObject, FSManager, Errors, IResource, ResourceType, PhysicalFSManager, PhysicalFile, PhysicalFolder, PhysicalResource } from 'webdav-server' import { PhysicalGateway } from './PhysicalGateway' export class PhysicalGFSManager extends PhysicalFSManager { - uid : string = "PhysicalGFSManager_1.0.0"; + uid : string = 'PhysicalGFSManager_1.0.0'; serialize(resource : any, obj : SerializedObject) : object { diff --git a/examples/v1/gatewayPhysical/ts/PhysicalGateway.ts b/examples/v1/gatewayPhysical/ts/PhysicalGateway.ts index ee5ec7a0..2f016952 100644 --- a/examples/v1/gatewayPhysical/ts/PhysicalGateway.ts +++ b/examples/v1/gatewayPhysical/ts/PhysicalGateway.ts @@ -1,5 +1,5 @@ import { PhysicalGFSManager } from './PhysicalGFSManager' -import * as webdav from '../../../lib/index.js' +import * as webdav from 'webdav-server' import * as path from 'path' import * as fs from 'fs' diff --git a/examples/v2/customMethod2/index.ts b/examples/v2/customMethod2/index.ts index 33124f73..66267df1 100644 --- a/examples/v2/customMethod2/index.ts +++ b/examples/v2/customMethod2/index.ts @@ -4,7 +4,7 @@ import * as request from 'request' // Server instantiation const server = new webdav.WebDAVServer(); -let folderNotify = { }; +const folderNotify = { }; server.method('TRACE', { unchunked(ctx : webdav.HTTPRequestContext, data : Buffer, cb : () => void) { diff --git a/examples/v2/webResource/index.ts b/examples/v2/webResource/index.ts index 550b46c7..2a2291c7 100644 --- a/examples/v2/webResource/index.ts +++ b/examples/v2/webResource/index.ts @@ -7,7 +7,7 @@ class WebFileSystemSerializer implements v2.FileSystemSerializer { uid() : string { - return "WebFileSystemSerializer_1.0.0"; + return 'WebFileSystemSerializer_1.0.0'; } serialize(fs : WebFileSystem, callback : v2.ReturnCallback) : void diff --git a/lib/helper/v2/IfParser.js b/lib/helper/v2/IfParser.js index dc4f22a2..5e5f9f57 100644 --- a/lib/helper/v2/IfParser.js +++ b/lib/helper/v2/IfParser.js @@ -101,7 +101,7 @@ function parseIfHeader(ifHeader) { }); match = rex.exec(ifHeader); } - if (orArray.length == 0) + if (orArray.length === 0) return function (ctx, resource, callback) { return callback(null, true); }; return function (ctx, resource, callback) { var nb = orArray.length; diff --git a/lib/manager/PhysicalGFSManager.js b/lib/manager/PhysicalGFSManager.js index a85af5f7..f13f2dcf 100644 --- a/lib/manager/PhysicalGFSManager.js +++ b/lib/manager/PhysicalGFSManager.js @@ -16,7 +16,7 @@ var PhysicalGFSManager = (function (_super) { __extends(PhysicalGFSManager, _super); function PhysicalGFSManager() { var _this = _super !== null && _super.apply(this, arguments) || this; - _this.uid = "PhysicalGFSManager_1.0.0"; + _this.uid = 'PhysicalGFSManager_1.0.0'; return _this; } PhysicalGFSManager.prototype.serialize = function (resource, obj) { diff --git a/lib/manager/v2/fileSystem/FileSystem.js b/lib/manager/v2/fileSystem/FileSystem.js index 7e5767c0..d6e40377 100644 --- a/lib/manager/v2/fileSystem/FileSystem.js +++ b/lib/manager/v2/fileSystem/FileSystem.js @@ -632,7 +632,7 @@ var FileSystem = (function () { cb(null, can ? path : null); }); }) - .error(function (e) { return __callback(e); }) + .error(__callback) .done(function () { return __callback(null, data.filter(function (p) { return !!p; }).map(function (p) { return p.fileName(); })); }); }); }; @@ -804,7 +804,7 @@ var FileSystem = (function () { }); }) .error(callback) - .done(function () { return callback(); }); + .done(function (_) { return callback(); }); } }; FileSystem.prototype.listDeepLocks = function (ctx, startPath, _depth, _callback) { @@ -872,8 +872,7 @@ var FileSystem = (function () { callback(null, paths .map(function (p) { return new Path_1.Path(p); }) .map(function (p) { - for (var i = 0; i < fsFullPath.paths.length; ++i) - p.removeRoot(); + fsFullPath.paths.forEach(function () { return p.removeRoot(); }); return p; })); }); diff --git a/lib/manager/v2/fileSystem/StandardMethods.js b/lib/manager/v2/fileSystem/StandardMethods.js index 93a58dff..67b92577 100644 --- a/lib/manager/v2/fileSystem/StandardMethods.js +++ b/lib/manager/v2/fileSystem/StandardMethods.js @@ -70,7 +70,7 @@ var StandardMethods = (function () { pmTo.setProperty(name, prop.value, prop.attributes, cb); }) .error(callback) - .done(function () { return callback(); }); + .done(function (_) { return callback(); }); }); }); }); @@ -104,9 +104,9 @@ var StandardMethods = (function () { return callback(e); var subDepth = depth === -1 ? -1 : Math.max(0, depth - 1); new Workflow_1.Workflow() - .each(files, function (file, cb) { return StandardMethods.standardCopy(ctx, subPathFrom.getChildPath(file), fsFrom, subPathTo.getChildPath(file), fsTo, overwrite, subDepth, function (e) { return cb(e); }); }) + .each(files, function (file, cb) { return StandardMethods.standardCopy(ctx, subPathFrom.getChildPath(file), fsFrom, subPathTo.getChildPath(file), fsTo, overwrite, subDepth, cb); }) .error(callback) - .done(function () { return callback(); }); + .done(function (_) { return callback(); }); }); }; fsFrom.type(ctx, subPathFrom, function (e, type) { diff --git a/src/helper/v2/IfParser.ts b/src/helper/v2/IfParser.ts index 3ee9bbe2..40cca58a 100644 --- a/src/helper/v2/IfParser.ts +++ b/src/helper/v2/IfParser.ts @@ -145,7 +145,7 @@ export function parseIfHeader(ifHeader : string) match = rex.exec(ifHeader); } - if(orArray.length == 0) + if(orArray.length === 0) return (ctx : RequestContext, resource : Resource, callback : ReturnCallback) => callback(null, true); return function(ctx : RequestContext, resource : Resource, callback : ReturnCallback) { diff --git a/src/manager/PhysicalGFSManager.ts b/src/manager/PhysicalGFSManager.ts index 1d65c3ab..318a7d37 100644 --- a/src/manager/PhysicalGFSManager.ts +++ b/src/manager/PhysicalGFSManager.ts @@ -5,7 +5,7 @@ import { IResource } from '../resource/IResource' export class PhysicalGFSManager extends PhysicalFSManager { - uid : string = "PhysicalGFSManager_1.0.0"; + uid : string = 'PhysicalGFSManager_1.0.0'; serialize(resource : any, obj : SerializedObject) : object { diff --git a/src/manager/v2/fileSystem/FileSystem.ts b/src/manager/v2/fileSystem/FileSystem.ts index 8e48c654..35b82900 100644 --- a/src/manager/v2/fileSystem/FileSystem.ts +++ b/src/manager/v2/fileSystem/FileSystem.ts @@ -1061,7 +1061,7 @@ export abstract class FileSystem implements ISerializableFileSystem cb(null, can ? path : null); }); }) - .error((e) => __callback(e)) + .error(__callback) .done(() => __callback(null, data.filter((p) => !!p).map((p) => p.fileName()))); }) } @@ -1302,7 +1302,7 @@ export abstract class FileSystem implements ISerializableFileSystem }) }) .error(callback) - .done(() => callback()); + .done((_) => callback()); } } @@ -1438,8 +1438,7 @@ export abstract class FileSystem implements ISerializableFileSystem callback(null, paths .map((p) => new Path(p)) .map((p) => { - for(let i = 0; i < fsFullPath.paths.length; ++i) - p.removeRoot(); + fsFullPath.paths.forEach(() => p.removeRoot()); return p; }) ); diff --git a/src/manager/v2/fileSystem/StandardMethods.ts b/src/manager/v2/fileSystem/StandardMethods.ts index 5c4a0c7f..114e38a0 100644 --- a/src/manager/v2/fileSystem/StandardMethods.ts +++ b/src/manager/v2/fileSystem/StandardMethods.ts @@ -109,7 +109,7 @@ export abstract class StandardMethods pmTo.setProperty(name, prop.value, prop.attributes, cb) }) .error(callback) - .done(() => callback()) + .done((_) => callback()) }) }) }) @@ -154,9 +154,9 @@ export abstract class StandardMethods const subDepth = depth === -1 ? -1 : Math.max(0, depth - 1); new Workflow() - .each(files, (file, cb) => StandardMethods.standardCopy(ctx, subPathFrom.getChildPath(file), fsFrom, subPathTo.getChildPath(file), fsTo, overwrite, subDepth, (e) => cb(e))) + .each(files, (file, cb) => StandardMethods.standardCopy(ctx, subPathFrom.getChildPath(file), fsFrom, subPathTo.getChildPath(file), fsTo, overwrite, subDepth, cb)) .error(callback) - .done(() => callback()); + .done((_) => callback()); }) } diff --git a/test/v2/tests.ts/lockUnlock/.createFiles.ts b/test/v2/tests.ts/lockUnlock/.createFiles.ts index 65631cb7..aeccbb37 100644 --- a/test/v2/tests.ts/lockUnlock/.createFiles.ts +++ b/test/v2/tests.ts/lockUnlock/.createFiles.ts @@ -178,9 +178,9 @@ export function lockResource( const lock = { scope: activeLock.find('DAV:lockscope').elements[0].name.replace('DAV:', '').toLowerCase(), type: activeLock.find('DAV:locktype').elements[0].name.replace('DAV:', '').toLowerCase(), - depth: sDepth === 'infinity' ? -1 : parseInt(sDepth), + depth: sDepth === 'infinity' ? -1 : parseInt(sDepth, 10), owner: activeLock.find('DAV:owner').elements, - timeoutSec: parseInt(sTimeout.substring(sTimeout.indexOf(':') + 1)), + timeoutSec: parseInt(sTimeout.substring(sTimeout.indexOf(':') + 1), 10), uuid: activeLock.find('DAV:locktoken').find('DAV:href').findText(), root: activeLock.find('DAV:lockroot').find('DAV:href').findText() };