@koine/utils 1.0.75 → 1.0.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/capitalize.d.ts +1 -1
- package/capitalize.js +4 -4
- package/getParamAsInt.d.ts +1 -1
- package/getParamAsInt.js +5 -4
- package/node/capitalize.js +4 -4
- package/node/getParamAsInt.js +5 -4
- package/package.json +1 -1
package/capitalize.d.ts
CHANGED
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
* @category text
|
|
5
5
|
* @see https://stackoverflow.com/a/11409944/1938970
|
|
6
6
|
*/
|
|
7
|
-
export declare function capitalize<T extends string>(
|
|
7
|
+
export declare function capitalize<T extends string>(string: null | T): Capitalize<T>;
|
|
8
8
|
export default capitalize;
|
package/capitalize.js
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* @category text
|
|
5
5
|
* @see https://stackoverflow.com/a/11409944/1938970
|
|
6
6
|
*/
|
|
7
|
-
export function capitalize(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
export function capitalize(string) {
|
|
8
|
+
var ensuredString = string || "";
|
|
9
|
+
return (ensuredString.charAt(0).toUpperCase() +
|
|
10
|
+
ensuredString.slice(1));
|
|
11
11
|
}
|
|
12
12
|
export default capitalize;
|
package/getParamAsInt.d.ts
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
* @param {string} [raw] - The _raw_ query parameter
|
|
9
9
|
* @param {number} [fallback] - Fallback number, we return `null` if not provided
|
|
10
10
|
*/
|
|
11
|
-
export declare function getParamAsInt(raw?: string | string[], fallback?:
|
|
11
|
+
export declare function getParamAsInt<TFallback extends number | null | undefined>(raw?: string | string[], fallback?: TFallback): number | TFallback;
|
|
12
12
|
export default getParamAsInt;
|
package/getParamAsInt.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import getParamAsString from "./getParamAsString";
|
|
2
|
-
import isUndefined from "./isUndefined";
|
|
3
2
|
/**
|
|
4
3
|
* Get query parameter as `int`eger treating the `ParsedUrlQuery` result of
|
|
5
4
|
* [`querystring`](https://nodejs.org/api/querystring.html) (used in next.js
|
|
@@ -11,9 +10,11 @@ import isUndefined from "./isUndefined";
|
|
|
11
10
|
* @param {number} [fallback] - Fallback number, we return `null` if not provided
|
|
12
11
|
*/
|
|
13
12
|
export function getParamAsInt(raw, fallback) {
|
|
13
|
+
if (fallback === void 0) { fallback = null; }
|
|
14
14
|
var string = getParamAsString(raw);
|
|
15
|
-
if (string)
|
|
16
|
-
parseInt(string, 10);
|
|
17
|
-
|
|
15
|
+
if (string) {
|
|
16
|
+
return parseInt(string, 10);
|
|
17
|
+
}
|
|
18
|
+
return fallback;
|
|
18
19
|
}
|
|
19
20
|
export default getParamAsInt;
|
package/node/capitalize.js
CHANGED
|
@@ -7,10 +7,10 @@ exports.capitalize = void 0;
|
|
|
7
7
|
* @category text
|
|
8
8
|
* @see https://stackoverflow.com/a/11409944/1938970
|
|
9
9
|
*/
|
|
10
|
-
function capitalize(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
function capitalize(string) {
|
|
11
|
+
var ensuredString = string || "";
|
|
12
|
+
return (ensuredString.charAt(0).toUpperCase() +
|
|
13
|
+
ensuredString.slice(1));
|
|
14
14
|
}
|
|
15
15
|
exports.capitalize = capitalize;
|
|
16
16
|
exports.default = capitalize;
|
package/node/getParamAsInt.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getParamAsInt = void 0;
|
|
4
4
|
var getParamAsString_1 = require("./getParamAsString");
|
|
5
|
-
var isUndefined_1 = require("./isUndefined");
|
|
6
5
|
/**
|
|
7
6
|
* Get query parameter as `int`eger treating the `ParsedUrlQuery` result of
|
|
8
7
|
* [`querystring`](https://nodejs.org/api/querystring.html) (used in next.js
|
|
@@ -14,10 +13,12 @@ var isUndefined_1 = require("./isUndefined");
|
|
|
14
13
|
* @param {number} [fallback] - Fallback number, we return `null` if not provided
|
|
15
14
|
*/
|
|
16
15
|
function getParamAsInt(raw, fallback) {
|
|
16
|
+
if (fallback === void 0) { fallback = null; }
|
|
17
17
|
var string = (0, getParamAsString_1.default)(raw);
|
|
18
|
-
if (string)
|
|
19
|
-
parseInt(string, 10);
|
|
20
|
-
|
|
18
|
+
if (string) {
|
|
19
|
+
return parseInt(string, 10);
|
|
20
|
+
}
|
|
21
|
+
return fallback;
|
|
21
22
|
}
|
|
22
23
|
exports.getParamAsInt = getParamAsInt;
|
|
23
24
|
exports.default = getParamAsInt;
|