refactor: simplified validatePath

This commit is contained in:
Jean-Baptiste Pionnier
2018-10-18 11:58:49 +02:00
parent ff3ef16d18
commit 1f59ec3458
4 changed files with 11 additions and 4 deletions

View File

@@ -4,8 +4,10 @@ export const isFunction = (fn): boolean => typeof fn === 'function';
export const isObject = (fn): fn is object => typeof fn === 'object';
export const isString = (fn): fn is string => typeof fn === 'string';
export const isConstructor = (fn): boolean => fn === 'constructor';
export const validatePath = (path): string =>
path.charAt(0) !== '/' ? '/' + path : path;
export const validatePath = (path?: string): string =>
path
? path.charAt(0) !== '/' ? '/' + path : path
: '';
export const isNil = (obj): boolean => isUndefined(obj) || obj === null;
export const isEmpty = (array): boolean => !(array && array.length > 0);
export const isSymbol = (fn): boolean => typeof fn === 'symbol';