Add function docs for parse utils
This commit is contained in:
parent
47f8109d34
commit
a04aed0d67
@ -1,11 +1,13 @@
|
|||||||
/**
|
/**
|
||||||
* Utility functions for parsing
|
* Utility functions for parsing
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse a string as positive integer or NaN
|
* Parse a string as positive integer or NaN
|
||||||
*
|
*
|
||||||
* @param {string} value
|
* @param {string} value
|
||||||
|
* @returns {number} integer or NaN
|
||||||
*/
|
*/
|
||||||
function strictParseInt(value) {
|
function strictParseInt(value) {
|
||||||
if (/^([1-9][0-9]*)$/.test(value))
|
if (/^([1-9][0-9]*)$/.test(value))
|
||||||
@ -13,7 +15,12 @@ function strictParseInt(value) {
|
|||||||
return NaN;
|
return NaN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse building ID from URL
|
||||||
|
*
|
||||||
|
* @param {String} url
|
||||||
|
* @returns {number|undefined}
|
||||||
|
*/
|
||||||
function parseBuildingURL(url) {
|
function parseBuildingURL(url) {
|
||||||
const re = /\/building\/([^/]+).html/;
|
const re = /\/building\/([^/]+).html/;
|
||||||
const matches = re.exec(url);
|
const matches = re.exec(url);
|
||||||
@ -24,6 +31,12 @@ function parseBuildingURL(url) {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse category slug from URL
|
||||||
|
*
|
||||||
|
* @param {String} url
|
||||||
|
* @returns {String} [age]
|
||||||
|
*/
|
||||||
function parseCategoryURL(url) {
|
function parseCategoryURL(url) {
|
||||||
const default_cat = 'age';
|
const default_cat = 'age';
|
||||||
if (url === "/") {
|
if (url === "/") {
|
||||||
|
Loading…
Reference in New Issue
Block a user