1.0.5 • Published 7 years ago

link-to-func v1.0.5

Weekly downloads
2
License
ISC
Repository
github
Last release
7 years ago

link-to-func

router link to function

npm install link-to-func

Usage

var LinkToFunc = require('link-to-func')

var absPath = 'https://url.com';

var newsList = LinkToFunc.absPath(absPath, '/home/news/list');
var newsDetail1 = LinkToFunc.absPath(absPath, '/home/news/detail/:id');
var newsDetail2 = LinkToFunc.absPath(absPath, '/home/news(/:id)');

//basic
console.log(newsList()); // /home/news/list
console.log(newsDetail1(1));// /home/news/detail/1
console.log(newsDetail2());// /home/news
console.log(newsDetail2(1));// /home/news/1

//toAbsPath
console.log(newsList.toAbsPath());// https://url.com/home/news/list
console.log(newsDetail1.toAbsPath(1));// https://url.com/home/news/detail/1
console.log(newsDetail2.toAbsPath());// https://url.com/home/news
console.log(newsDetail2.toAbsPath(1));// https://url.com/home/news/1

//getLink
console.log(newsList.getLink());// /home/news/list
console.log(newsDetail1.getLink());// /home/news/detail/:id
console.log(newsDetail2.getLink());// /home/news(/:id)
1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago