-
Notifications
You must be signed in to change notification settings - Fork 336
Open
Description
////// 纯代码库: lib/params.js /////// // url :: IO String
var url = new IO(function() { return window.location.href; });
// toPairs = String -> [[String]]
var toPairs = compose(map(split('=')), split('&'));
// params :: String -> [[String]]
var params = compose(toPairs, last, split('?'));
// findParam :: String -> IO Maybe [String]
var findParam = function(key) {
return map(compose(Maybe.of, filter(compose(eq(key), head)), p
arams), url);
};
////// 非纯调用代码: main.js ///////
// 调用 __value() 来运行它!
findParam("searchTerm").__value();
// Maybe(['searchTerm', 'wafflehouse'])
我这边输出结果是个二维数组
// Maybe([['searchTerm', 'wafflehouse']])
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels