umt 1.3.6 → 1.4.0
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/module/Simple/Tool/birthdaySimple.d.ts +21 -0
- package/module/Simple/Tool/birthdaySimple.js +31 -0
- package/module/Simple/Tool/birthdaySimple.js.map +1 -0
- package/module/Simple/Tool/index.d.ts +1 -1
- package/module/Simple/Tool/index.js +1 -1
- package/module/Simple/Tool/index.js.map +1 -1
- package/module/Validate/boolean/core.d.ts +2 -0
- package/module/Validate/boolean/core.js +5 -0
- package/module/Validate/boolean/core.js.map +1 -0
- package/module/Validate/boolean/index.d.ts +1 -0
- package/module/Validate/boolean/index.js +2 -0
- package/module/Validate/boolean/index.js.map +1 -0
- package/module/Validate/index.d.ts +2 -0
- package/module/Validate/index.js +2 -0
- package/module/Validate/index.js.map +1 -1
- package/module/Validate/isNumber.d.ts +1 -1
- package/module/Validate/isNumber.js +1 -1
- package/module/Validate/number/double.d.ts +2 -0
- package/module/Validate/number/double.js +9 -0
- package/module/Validate/number/double.js.map +1 -0
- package/module/Validate/number/index.d.ts +1 -0
- package/module/Validate/number/index.js +1 -0
- package/module/Validate/number/index.js.map +1 -1
- package/module/Validate/object/core.d.ts +8 -0
- package/module/Validate/object/core.js +27 -0
- package/module/Validate/object/core.js.map +1 -0
- package/module/Validate/object/index.d.ts +1 -0
- package/module/Validate/object/index.js +2 -0
- package/module/Validate/object/index.js.map +1 -0
- package/module/Validate/type.d.ts +1 -0
- package/package.json +8 -8
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { dayType, monType } from "../../types/dateType";
|
|
2
|
+
import { hoursTypeInt } from "../../types/clockType";
|
|
3
|
+
export interface BIRTHDAYSIMPLE {
|
|
4
|
+
<T extends monType>(birthdays: Date | `${number}-${T}-${dayType<T>}` | `${number}:${T}:${dayType<T>}` | `${number}/${T}/${dayType<T>}` | {
|
|
5
|
+
year: number;
|
|
6
|
+
mon: number;
|
|
7
|
+
day: number;
|
|
8
|
+
}, timeDifference?: hoursTypeInt): number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 年齢を取得する
|
|
12
|
+
* @param birthdays - 誕生日
|
|
13
|
+
* @param timeDifference - 時差 (default: 9)
|
|
14
|
+
* @returns number
|
|
15
|
+
* @example birthdaySimple("2000-01-01");
|
|
16
|
+
* birthdaySimple("2000:01:01");
|
|
17
|
+
* birthdaySimple("2000/01/01");
|
|
18
|
+
* birthdaySimple({ year: 2000, mon: 1, day: 1 });
|
|
19
|
+
* birthdaySimple(new Date(2000, 0, 1));
|
|
20
|
+
*/
|
|
21
|
+
export declare const birthdaySimple: BIRTHDAYSIMPLE;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { birthday } from "../../Tool/birthday";
|
|
2
|
+
/**
|
|
3
|
+
* 年齢を取得する
|
|
4
|
+
* @param birthdays - 誕生日
|
|
5
|
+
* @param timeDifference - 時差 (default: 9)
|
|
6
|
+
* @returns number
|
|
7
|
+
* @example birthdaySimple("2000-01-01");
|
|
8
|
+
* birthdaySimple("2000:01:01");
|
|
9
|
+
* birthdaySimple("2000/01/01");
|
|
10
|
+
* birthdaySimple({ year: 2000, mon: 1, day: 1 });
|
|
11
|
+
* birthdaySimple(new Date(2000, 0, 1));
|
|
12
|
+
*/
|
|
13
|
+
export const birthdaySimple = ((birthdays, timeDifference = 9) => {
|
|
14
|
+
if (typeof birthdays === "string") {
|
|
15
|
+
if (birthdays.includes(":")) {
|
|
16
|
+
const [year, mon, day] = birthdays.split(":").map(Number);
|
|
17
|
+
return birthday(year, mon, day, timeDifference);
|
|
18
|
+
}
|
|
19
|
+
if (birthdays.includes("/")) {
|
|
20
|
+
const [year, mon, day] = birthdays.split("/").map(Number);
|
|
21
|
+
return birthday(year, mon, day, timeDifference);
|
|
22
|
+
}
|
|
23
|
+
const [year, mon, day] = birthdays.split("-").map(Number);
|
|
24
|
+
return birthday(year, mon, day, timeDifference);
|
|
25
|
+
}
|
|
26
|
+
if (birthdays instanceof Date) {
|
|
27
|
+
return birthday(birthdays.getFullYear(), birthdays.getMonth(), birthdays.getDate(), timeDifference);
|
|
28
|
+
}
|
|
29
|
+
return birthday(birthdays.year, birthdays.mon, birthdays.day, timeDifference);
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=birthdaySimple.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"birthdaySimple.js","sourceRoot":"","sources":["../../../src/Simple/Tool/birthdaySimple.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAa3C;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAC7B,SAK8C,EAC9C,iBAA+B,CAAC,EAChC,EAAE;IACF,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;QAClC,IAAI,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAC5B,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAIvD,CAAC;YACF,OAAO,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,cAAc,CAAC,CAAC;QAClD,CAAC;QACD,IAAI,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAC5B,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAIvD,CAAC;YACF,OAAO,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,cAAc,CAAC,CAAC;QAClD,CAAC;QACD,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAIvD,CAAC;QACF,OAAO,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,cAAc,CAAC,CAAC;IAClD,CAAC;IACD,IAAI,SAAS,YAAY,IAAI,EAAE,CAAC;QAC9B,OAAO,QAAQ,CACb,SAAS,CAAC,WAAW,EAAE,EACvB,SAAS,CAAC,QAAQ,EAAgB,EAClC,SAAS,CAAC,OAAO,EAA4B,EAC7C,cAAc,CACf,CAAC;IACJ,CAAC;IACD,OAAO,QAAQ,CACb,SAAS,CAAC,IAAI,EACd,SAAS,CAAC,GAAiB,EAC3B,SAAS,CAAC,GAA6B,EACvC,cAAc,CACf,CAAC;AACJ,CAAC,CAAmB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Simple/Tool/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Simple/Tool/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/Validate/boolean/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAGvC,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,OAAgB,EAAE,EAAE;IAC1C,OAAO,CAAC,KAAc,EAAmC,EAAE,CACzD,IAAI,CAAU,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;AACjD,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./core";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Validate/boolean/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC"}
|
package/module/Validate/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Validate/index.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AAEzB,iBAAiB;AACjB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Validate/index.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AAEzB,iBAAiB;AACjB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"double.js","sourceRoot":"","sources":["../../../src/Validate/number/double.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAG/C,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,OAAgB,EAA8B,EAAE;IACrE,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,OAAO;QACP,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC;KACrC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Validate/number/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Validate/number/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ValidateCoreReturnType, ValidateType } from "../../Validate/type";
|
|
2
|
+
export declare const object: <T extends {
|
|
3
|
+
[key: string]: (value: any) => ValidateCoreReturnType<any>;
|
|
4
|
+
}>(option: T, message?: string) => (value: { [key in keyof T]: ValidateType<ReturnType<T[key]>["type"]>; }) => {
|
|
5
|
+
validate: boolean;
|
|
6
|
+
message: string;
|
|
7
|
+
type: { [key in keyof T]: ValidateType<ReturnType<T[key]>["type"]>; };
|
|
8
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { isObject } from "../../Validate/isObject";
|
|
2
|
+
export const object = (option, message) => {
|
|
3
|
+
return (value) => {
|
|
4
|
+
if (!isObject(value)) {
|
|
5
|
+
return {
|
|
6
|
+
validate: false,
|
|
7
|
+
message: message || "",
|
|
8
|
+
type: value,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
for (const validate in option) {
|
|
12
|
+
if (!option[validate](value[validate]).validate) {
|
|
13
|
+
return {
|
|
14
|
+
validate: false,
|
|
15
|
+
message: option[validate](value).message,
|
|
16
|
+
type: value,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
validate: true,
|
|
22
|
+
message: "",
|
|
23
|
+
type: value,
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/Validate/object/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAG/C,MAAM,CAAC,MAAM,MAAM,GAAG,CAMpB,MAAS,EACT,OAAgB,EAChB,EAAE;IACF,OAAO,CACL,KAEC,EACD,EAAE;QACF,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACrB,OAAO;gBACL,QAAQ,EAAE,KAAK;gBACf,OAAO,EAAE,OAAO,IAAI,EAAE;gBACtB,IAAI,EAAE,KAAK;aACZ,CAAC;QACJ,CAAC;QACD,KAAK,MAAM,QAAQ,IAAI,MAAM,EAAE,CAAC;YAC9B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;gBAChD,OAAO;oBACL,QAAQ,EAAE,KAAK;oBACf,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO;oBACxC,IAAI,EAAE,KAAK;iBACZ,CAAC;YACJ,CAAC;QACH,CAAC;QACD,OAAO;YACL,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,EAAE;YACX,IAAI,EAAE,KAAK;SACZ,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./core";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Validate/object/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC"}
|
|
@@ -12,3 +12,4 @@ export interface ValidateReturnType<T> {
|
|
|
12
12
|
export interface ValidateFunctionType<T> {
|
|
13
13
|
(value: T): boolean;
|
|
14
14
|
}
|
|
15
|
+
export type ValidateType<T> = T extends "string" ? string : T extends "number" ? number : T extends "boolean" ? boolean : T extends `array<${infer U}>` ? U[] : T extends `object<${infer V}>` ? V : never;
|
package/package.json
CHANGED
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
},
|
|
6
6
|
"description": "個人的に作った便利関数集 個人用途なので破壊的変更がある可能性があります。 Main Packageに依存関係はありません。 JavaScriptからの呼び出しに対応しています。",
|
|
7
7
|
"devDependencies": {
|
|
8
|
-
"@biomejs/biome": "1.4.
|
|
9
|
-
"@swc/core": "^1.3.
|
|
8
|
+
"@biomejs/biome": "1.4.1",
|
|
9
|
+
"@swc/core": "^1.3.100",
|
|
10
10
|
"@swc/jest": "^0.2.29",
|
|
11
11
|
"@types/jest": "^29.5.10",
|
|
12
|
-
"@types/node": "^20.10.
|
|
12
|
+
"@types/node": "^20.10.2",
|
|
13
13
|
"@typescript-eslint/eslint-plugin": "^6.13.1",
|
|
14
14
|
"@typescript-eslint/parser": "^6.13.1",
|
|
15
|
-
"bun-types": "^1.0.
|
|
16
|
-
"eslint": "^8.
|
|
15
|
+
"bun-types": "^1.0.15",
|
|
16
|
+
"eslint": "^8.55.0",
|
|
17
17
|
"eslint-plugin-unicorn": "^49.0.0",
|
|
18
18
|
"gh-pages": "^6.1.0",
|
|
19
19
|
"jest": "^29.7.0",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"tsc-alias": "^1.8.8",
|
|
23
23
|
"typedoc": "^0.25.4",
|
|
24
24
|
"typescript": "^5.3.2",
|
|
25
|
-
"umt": "^1.3.
|
|
25
|
+
"umt": "^1.3.6"
|
|
26
26
|
},
|
|
27
27
|
"directories": {
|
|
28
28
|
"doc": "doc",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"format": "biome format . --write",
|
|
55
55
|
"eslint": "eslint src"
|
|
56
56
|
},
|
|
57
|
-
"version": "1.
|
|
58
|
-
}
|
|
57
|
+
"version": "1.4.0"
|
|
58
|
+
}
|