now has better structure
This commit is contained in:
@ -1,14 +1,16 @@
|
||||
/// <reference path="typings/main.d.ts" />
|
||||
import plugins = require("./smartpath.plugins");
|
||||
import SmartpathAbsolute = require("./smartpath.absolute");
|
||||
|
||||
import SmartpathTransform = require("./smartpath.transform");
|
||||
import SmartpathGet = require("./smartpath.get");
|
||||
|
||||
/**
|
||||
*
|
||||
* @type {{getPath: (function(any): undefined)}}
|
||||
*/
|
||||
let smartpath = {
|
||||
absolute: SmartpathAbsolute
|
||||
transform: SmartpathTransform,
|
||||
get: SmartpathGet
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
11
ts/smartpath.get.ts
Normal file
11
ts/smartpath.get.ts
Normal file
@ -0,0 +1,11 @@
|
||||
/// <reference path="typings/main.d.ts" />
|
||||
import plugins = require("./smartpath.plugins");
|
||||
|
||||
export let type = function(pathStringArg:string):string {
|
||||
let urlRegex = /http[s|\s]:\/\/.*/i
|
||||
if(urlRegex.exec(pathStringArg)){
|
||||
return "url";
|
||||
} else {
|
||||
return "local";
|
||||
};
|
||||
};
|
@ -1,7 +1,10 @@
|
||||
/// <reference path="typings/main.d.ts" />
|
||||
import plugins = require("./smartpath.plugins");
|
||||
|
||||
var makeAbsolute = function(localPathArg:string, baseArg?:string):string {
|
||||
/* ------------------------------------------ *
|
||||
* ------------ helpers --------------------- *
|
||||
* ------------------------------------------ */
|
||||
let makeAbsolute = function(localPathArg:string, baseArg?:string):string {
|
||||
let absolutePath:string;
|
||||
if(baseArg){
|
||||
absolutePath = plugins.path.join(baseArg,localPathArg);
|
||||
@ -11,7 +14,10 @@ var makeAbsolute = function(localPathArg:string, baseArg?:string):string {
|
||||
return absolutePath;
|
||||
};
|
||||
|
||||
var absolute = function(relativeArg:any, baseArg?:string):any {
|
||||
/* ------------------------------------------ *
|
||||
* ------- export functions ----------------- *
|
||||
* ------------------------------------------ */
|
||||
export let toAbsolute = function(relativeArg:any, baseArg?:string):any {
|
||||
if(typeof relativeArg === "string"){
|
||||
return makeAbsolute(relativeArg,baseArg);
|
||||
} else if(Array.isArray(relativeArg)){
|
||||
@ -26,6 +32,4 @@ var absolute = function(relativeArg:any, baseArg?:string):any {
|
||||
"Input is neither String nor Array");
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
export = absolute;
|
||||
};
|
Reference in New Issue
Block a user