@kizmann/pico-js 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/pico-js.js +370 -2
- package/docs/index.html +12 -0
- package/package.json +2 -1
- package/tsconfig.json +14 -0
- package/types/index.d.ts +25 -0
- package/types/utility/any.d.ts +66 -0
- package/types/utility/array.d.ts +46 -0
- package/types/utility/now.d.ts +148 -0
- package/types/utility/number.d.ts +31 -0
- package/types/utility/object.d.ts +54 -0
- package/types/utility/string.d.ts +33 -0
- package/webservy.json +6 -0
package/docs/index.html
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="UTF-8">
|
5
|
+
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
6
|
+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
7
|
+
<title>Document</title>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
</body>
|
12
|
+
</html>
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@kizmann/pico-js",
|
3
|
-
"version": "0.5.
|
3
|
+
"version": "0.5.1",
|
4
4
|
"license": "MIT",
|
5
5
|
"type": "module",
|
6
6
|
"private": false,
|
@@ -8,6 +8,7 @@
|
|
8
8
|
"repository": "https://github.com/vankizmann/pico-js",
|
9
9
|
"main": "src/index.js",
|
10
10
|
"unpkg": "dist/pico-js.js",
|
11
|
+
"types": "types/index.d.ts",
|
11
12
|
"scripts": {
|
12
13
|
"build": "webpack --hide-modules --mode=production --config webpack.config.cjs",
|
13
14
|
"watch": "webpack --watch --hide-modules --mode=development --config webpack.config.cjs"
|
package/tsconfig.json
ADDED
package/types/index.d.ts
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
// types/index.d.ts
|
2
|
+
import { Arr } from "./utility/array";
|
3
|
+
import { Obj } from "./utility/object";
|
4
|
+
import { Any } from "./utility/any";
|
5
|
+
import { Num } from "./utility/number";
|
6
|
+
import { Str } from "./utility/string";
|
7
|
+
import { Now } from "./utility/now";
|
8
|
+
|
9
|
+
export declare module "@kizmann/pico-js" {
|
10
|
+
|
11
|
+
const Arr: Arr;
|
12
|
+
const Obj: Obj;
|
13
|
+
const Any: Any;
|
14
|
+
const Str: Str;
|
15
|
+
const Num: Num;
|
16
|
+
const Now: Now;
|
17
|
+
|
18
|
+
export {
|
19
|
+
Arr, Obj, Any, Str, Num, Now
|
20
|
+
};
|
21
|
+
|
22
|
+
export default {
|
23
|
+
Arr, Obj, Any, Str, Num, Now
|
24
|
+
};
|
25
|
+
}
|
@@ -0,0 +1,66 @@
|
|
1
|
+
// types/utility/any.d.ts
|
2
|
+
|
3
|
+
|
4
|
+
import { Arr } from "./array";
|
5
|
+
import { Obj } from "./object";
|
6
|
+
import { Now } from "./now";
|
7
|
+
|
8
|
+
declare class Any {
|
9
|
+
static isEmpty(val : any) : boolean;
|
10
|
+
|
11
|
+
static isNull(val : any) : boolean;
|
12
|
+
|
13
|
+
static isEqual(obj : any, val : any) : boolean;
|
14
|
+
|
15
|
+
static isString(val : any) : boolean;
|
16
|
+
|
17
|
+
static isNumber(val : any) : boolean;
|
18
|
+
|
19
|
+
static isBool(val : any) : boolean;
|
20
|
+
|
21
|
+
static isFunction(val : any) : boolean;
|
22
|
+
|
23
|
+
static isObject(val : any) : boolean;
|
24
|
+
|
25
|
+
static isPlain(val : any) : boolean;
|
26
|
+
|
27
|
+
static isArray(val : any) : boolean;
|
28
|
+
|
29
|
+
static isDate(val : any) : boolean;
|
30
|
+
|
31
|
+
static string(val : any) : string;
|
32
|
+
|
33
|
+
static convertString(val : any, empty? : string) : string;
|
34
|
+
|
35
|
+
static integer(val : any) : number;
|
36
|
+
|
37
|
+
static float(val : any) : number;
|
38
|
+
|
39
|
+
static bool(val : any) : boolean;
|
40
|
+
|
41
|
+
static boolean(val : any) : boolean;
|
42
|
+
|
43
|
+
static convertBool(val : any, yes? : string, no? : string) : string;
|
44
|
+
|
45
|
+
static convertBoolean(val : any, yes? : string, no? : string) : string;
|
46
|
+
|
47
|
+
static convertDatetime(val : any, format? : string, empty? : string) : string;
|
48
|
+
|
49
|
+
static vals(obj : any) : any[];
|
50
|
+
|
51
|
+
static keys(obj : any) : string[];
|
52
|
+
|
53
|
+
static async(callback : (...args : any[]) => void, ...args : any[]) : Any;
|
54
|
+
|
55
|
+
static delay(callback : (...args : any[]) => void, delay? : number, ...args : any[]) : Any;
|
56
|
+
|
57
|
+
static debounce(callback : (...args : any[]) => void, delay? : number, ref? : any) : (...args : any[]) => void;
|
58
|
+
|
59
|
+
static throttle(callback : (...args : any[]) => void, delay? : number, ref? : any) : (...args : any[]) => void;
|
60
|
+
|
61
|
+
static framerate(callback : (...args : any[]) => void, rate? : number, ref? : any) : (...args : any[]) => void;
|
62
|
+
|
63
|
+
static form(obj : any) : FormData;
|
64
|
+
}
|
65
|
+
|
66
|
+
export default Any;
|
@@ -0,0 +1,46 @@
|
|
1
|
+
// types/utility/array.d.ts
|
2
|
+
|
3
|
+
declare class Arr {
|
4
|
+
static make(count: number): number[];
|
5
|
+
static all<T>(arr: T | T[]): T[];
|
6
|
+
static get<T>(arr: T[], index: number, fallback?: T): T;
|
7
|
+
static set<T>(arr: T[], index: number, value: T): T;
|
8
|
+
static first<T>(arr: T[], fallback?: T): T;
|
9
|
+
static second<T>(arr: T[], fallback?: T): T;
|
10
|
+
static third<T>(arr: T[], fallback?: T): T;
|
11
|
+
static last<T>(arr: T[], fallback?: T): T;
|
12
|
+
static prepend<T>(arr: T[], val: T): T[];
|
13
|
+
static append<T>(arr: T[], val: T): T[];
|
14
|
+
static sort<T>(obj: AnyObject, key: string | ((a: T, b: T) => number)): T[];
|
15
|
+
static sortString<T>(obj: AnyObject, key: string): T[];
|
16
|
+
static filter<T>(arr: T[], filter: any): T[];
|
17
|
+
static filterIndex(arr: any[], filter: any): number[];
|
18
|
+
static find<T>(arr: T[], val: any, fallback?: T): T;
|
19
|
+
static findIndex(arr: any[], val: any, fallback?: number): number;
|
20
|
+
static has<T>(arr: T[], val: any): boolean;
|
21
|
+
static add<T>(arr: T[], val: T, finder?: any): T[];
|
22
|
+
static replace<T>(arr: T[], val: T, finder?: any): T[];
|
23
|
+
static remove<T>(arr: T[], val: any): T[];
|
24
|
+
static toggle<T>(arr: T[], val: T): T[];
|
25
|
+
static removeIndex<T>(arr: T[], val: number): T[];
|
26
|
+
static insert<T>(arr: T[], key: number, val: T): T[];
|
27
|
+
static slice<T>(arr: T[], key: number, count?: number): T[];
|
28
|
+
static splice<T>(arr: T[], key: number, count?: number): T[];
|
29
|
+
static equal<T>(arr1: T[], arr2: T[]): boolean;
|
30
|
+
static includes<T>(arr: T[], val: T): boolean;
|
31
|
+
static contains<T>(arr: T[], val: T[]): boolean;
|
32
|
+
static concat<T>(arr: T[], ...args: T[]): T[];
|
33
|
+
static clone<T>(arr: T[]): T[];
|
34
|
+
static merge<T>(arr: T[], ...args: T[]): T[];
|
35
|
+
static push<T>(arr: T[], ...args: T[]): T[];
|
36
|
+
static diff<T>(arr: T[], val: T[]): T[];
|
37
|
+
static intersect<T>(...args: T[][]): T[];
|
38
|
+
static chunk<T>(arr: T[], chunk?: number): T[][];
|
39
|
+
static reduce<T, U>(arr: T[], callback: (accumulator: U, currentValue: T, currentIndex: number, array: T[]) => U, accumulator: U): U;
|
40
|
+
static extract<T>(arr: T[], path: string): any[];
|
41
|
+
static each<T>(arr: T[], callback: (val: T, key: number | string) => any): any[];
|
42
|
+
static map<T>(arr: T[], callback: (val: T, key: number | string) => any): T[];
|
43
|
+
static recursive<T>(arr: T[], key: string, callback: (val: any, cascade: any[]) => any, cascade?: any[]): T[];
|
44
|
+
}
|
45
|
+
|
46
|
+
export default Arr;
|
@@ -0,0 +1,148 @@
|
|
1
|
+
// types/utility/now.d.ts
|
2
|
+
|
3
|
+
import { Num } from "./number";
|
4
|
+
import { Arr } from "./array";
|
5
|
+
import { Any } from "./any";
|
6
|
+
|
7
|
+
declare class Now {
|
8
|
+
initialDate : string | null;
|
9
|
+
moment : any;
|
10
|
+
|
11
|
+
constructor(date? : any, format? : string);
|
12
|
+
|
13
|
+
static make(date? : any, format? : string) : Now;
|
14
|
+
|
15
|
+
get() : any;
|
16
|
+
|
17
|
+
valid() : boolean;
|
18
|
+
|
19
|
+
clone() : Now;
|
20
|
+
|
21
|
+
code(format? : string) : number;
|
22
|
+
|
23
|
+
format(format? : string, force? : boolean) : string;
|
24
|
+
|
25
|
+
before(before? : any) : boolean;
|
26
|
+
|
27
|
+
beforeDate(before? : any) : boolean;
|
28
|
+
|
29
|
+
beforeTime(before? : any) : boolean;
|
30
|
+
|
31
|
+
after(after? : any) : boolean;
|
32
|
+
|
33
|
+
afterDate(after? : any) : boolean;
|
34
|
+
|
35
|
+
afterTime(after? : any) : boolean;
|
36
|
+
|
37
|
+
equal(equal? : any, format? : string) : boolean;
|
38
|
+
|
39
|
+
equalDate(equal? : any, format? : string) : boolean;
|
40
|
+
|
41
|
+
equalTime(equal? : any, format? : string) : boolean;
|
42
|
+
|
43
|
+
between(fromDate? : any, toDate? : any, format? : string) : boolean;
|
44
|
+
|
45
|
+
decade() : number;
|
46
|
+
|
47
|
+
prevDecade() : Now;
|
48
|
+
|
49
|
+
nextDecade() : Now;
|
50
|
+
|
51
|
+
addDecades(count? : number) : Now;
|
52
|
+
|
53
|
+
subDecades(count? : number) : Now;
|
54
|
+
|
55
|
+
year(year? : number | null) : number | Now;
|
56
|
+
|
57
|
+
prevYear() : Now;
|
58
|
+
|
59
|
+
nextYear() : Now;
|
60
|
+
|
61
|
+
addYears(count? : number) : Now;
|
62
|
+
|
63
|
+
subYears(count? : number) : Now;
|
64
|
+
|
65
|
+
month(month? : number | null) : number | Now;
|
66
|
+
|
67
|
+
addMonths(count? : number) : Now;
|
68
|
+
|
69
|
+
subMonths(count? : number) : Now;
|
70
|
+
|
71
|
+
prevMonth() : Now;
|
72
|
+
|
73
|
+
nextMonth() : Now;
|
74
|
+
|
75
|
+
date(date? : number | null) : number | Now;
|
76
|
+
|
77
|
+
addDates(count? : number) : Now;
|
78
|
+
|
79
|
+
subDates(count? : number) : Now;
|
80
|
+
|
81
|
+
prevDate() : Now;
|
82
|
+
|
83
|
+
nextDate() : Now;
|
84
|
+
|
85
|
+
lastDate() : number;
|
86
|
+
|
87
|
+
day(day? : number | null) : number | Now;
|
88
|
+
|
89
|
+
hour(hour? : number | null) : number | Now;
|
90
|
+
|
91
|
+
addHour(count? : number) : Now;
|
92
|
+
|
93
|
+
subHour(count? : number) : Now;
|
94
|
+
|
95
|
+
prevHour() : Now;
|
96
|
+
|
97
|
+
nextHour() : Now;
|
98
|
+
|
99
|
+
minute(minute? : number | null) : number | Now;
|
100
|
+
|
101
|
+
addMinute(count? : number) : Now;
|
102
|
+
|
103
|
+
subMinute(count? : number) : Now;
|
104
|
+
|
105
|
+
prevMinute() : Now;
|
106
|
+
|
107
|
+
nextMinute() : Now;
|
108
|
+
|
109
|
+
second(second? : number | null) : number | Now;
|
110
|
+
|
111
|
+
addSecond(count? : number) : Now;
|
112
|
+
|
113
|
+
subSecond(count? : number) : Now;
|
114
|
+
|
115
|
+
prevSecond() : Now;
|
116
|
+
|
117
|
+
nextSecond() : Now;
|
118
|
+
|
119
|
+
humanDay() : number;
|
120
|
+
|
121
|
+
humanMonth() : number;
|
122
|
+
|
123
|
+
getMonths() : Now[];
|
124
|
+
|
125
|
+
getYears() : Now[];
|
126
|
+
|
127
|
+
getYearsGrid(size? : number) : Now[];
|
128
|
+
|
129
|
+
getDates() : Now[];
|
130
|
+
|
131
|
+
getDatesRange(target? : any) : Now[];
|
132
|
+
|
133
|
+
getDatesGrid(start? : number, end? : number) : Now[];
|
134
|
+
|
135
|
+
getHours(interval? : number) : Now[];
|
136
|
+
|
137
|
+
getMinutes(interval? : number) : Now[];
|
138
|
+
|
139
|
+
getSeconds(interval? : number) : Now[];
|
140
|
+
|
141
|
+
resetTime() : Now;
|
142
|
+
|
143
|
+
applyDate(now : any, format? : string) : void;
|
144
|
+
|
145
|
+
applyTime(now : any, format? : string) : void;
|
146
|
+
}
|
147
|
+
|
148
|
+
export default Now;
|
@@ -0,0 +1,31 @@
|
|
1
|
+
// types/utility/number.d.ts
|
2
|
+
|
3
|
+
import { Any } from "./any";
|
4
|
+
import { Arr } from "./array";
|
5
|
+
import { Obj } from "./object";
|
6
|
+
|
7
|
+
declare class Num {
|
8
|
+
static int(num : any) : number;
|
9
|
+
|
10
|
+
static float(num : any) : number;
|
11
|
+
|
12
|
+
static ceil(num : number) : number;
|
13
|
+
|
14
|
+
static round(num : number) : number;
|
15
|
+
|
16
|
+
static floor(num : number) : number;
|
17
|
+
|
18
|
+
static fixed(num : number, fixed? : number) : string;
|
19
|
+
|
20
|
+
static random(start? : number, end? : number) : number;
|
21
|
+
|
22
|
+
static matrix(num : number, limit? : number, base? : number[]) : number[];
|
23
|
+
|
24
|
+
static combine(arr : number[]) : number;
|
25
|
+
|
26
|
+
static distance(cord1 : { lat : number; lng : number }, cord2 : { lat : number; lng : number }, miles? : boolean) : number;
|
27
|
+
|
28
|
+
static format(num : number | null, decimal? : string, thousand? : string, fixed? : number | null) : string | null;
|
29
|
+
}
|
30
|
+
|
31
|
+
export default Num;
|
@@ -0,0 +1,54 @@
|
|
1
|
+
// types/utility/object.d.ts
|
2
|
+
|
3
|
+
import { Arr } from "./array";
|
4
|
+
import { Any } from "./any";
|
5
|
+
|
6
|
+
declare class Obj {
|
7
|
+
static has(obj : any, keys : string | string[]) : boolean;
|
8
|
+
|
9
|
+
static empty(obj : any, key : string) : boolean;
|
10
|
+
|
11
|
+
static get(obj : any, keys : string | string[], fallback? : any) : any;
|
12
|
+
|
13
|
+
static set(obj : any, keys : string | string[], val : any) : any;
|
14
|
+
|
15
|
+
static unset(obj : any, keys : string | string[]) : any;
|
16
|
+
|
17
|
+
static pluck(obj : any, keys : string | string[], fallback? : any) : any;
|
18
|
+
|
19
|
+
static only(obj : any, keys : string[], assign? : any) : any;
|
20
|
+
|
21
|
+
static except(obj : any, keys : string[], assign? : any) : any;
|
22
|
+
|
23
|
+
static includes(obj : any, val : any) : boolean;
|
24
|
+
|
25
|
+
static matches(obj : any, val : any) : boolean;
|
26
|
+
|
27
|
+
static sort(obj : any, key : string | ((a : any, b : any) => number)) : any[];
|
28
|
+
|
29
|
+
static sortString(obj : any, key : string) : any[];
|
30
|
+
|
31
|
+
static filter(obj : any, filter : any) : any[];
|
32
|
+
|
33
|
+
static filterIndex(obj : any, filter : any) : string[];
|
34
|
+
|
35
|
+
static find(arr : any[], obj : any, fallback? : any) : any;
|
36
|
+
|
37
|
+
static findIndex(arr : any[], obj : any, fallback? : number) : number;
|
38
|
+
|
39
|
+
static clone(obj : any) : any;
|
40
|
+
|
41
|
+
static assign(...args : any[]) : any;
|
42
|
+
|
43
|
+
static remove(obj : any, keys : string[]) : any;
|
44
|
+
|
45
|
+
static each(obj : any, callback : (value : any, key : string) => void) : any;
|
46
|
+
|
47
|
+
static map(obj : any, callback : (value : any, key : string) => any) : any;
|
48
|
+
|
49
|
+
static values(obj : any) : any[];
|
50
|
+
|
51
|
+
static flatten(obj : any) : any;
|
52
|
+
}
|
53
|
+
|
54
|
+
export default Obj;
|
@@ -0,0 +1,33 @@
|
|
1
|
+
// types/utility/string.d.ts
|
2
|
+
|
3
|
+
declare module "@kizmann/pico-js/src/utility/string" {
|
4
|
+
import { Arr } from "@kizmann/pico-js/src/utility/array";
|
5
|
+
import { Obj } from "@kizmann/pico-js/src/utility/object";
|
6
|
+
import { Num } from "@kizmann/pico-js/src/utility/number";
|
7
|
+
import { Any } from "@kizmann/pico-js/src/utility/any";
|
8
|
+
|
9
|
+
export class Str {
|
10
|
+
static regexEscape(val: string): string;
|
11
|
+
static upper(val: string): string;
|
12
|
+
static lower(val: string): string;
|
13
|
+
static camelcase(val: string): string;
|
14
|
+
static humancase(val: string): string;
|
15
|
+
static slugify(val: string): string;
|
16
|
+
static ucfirst(val: string): string;
|
17
|
+
static lcfirst(val: string): string;
|
18
|
+
static has(val: string, search: string): boolean;
|
19
|
+
static filesize(val: number, decimals?: number): string | null;
|
20
|
+
static array(value: string, fallback?: any[]): any[];
|
21
|
+
static real(value: string): any;
|
22
|
+
static objectify(value: any, mode?: 'options' | 'params', isArray?: boolean): any;
|
23
|
+
static stringify(value: any, mode?: 'options' | 'params'): string;
|
24
|
+
static options(params: any, quota?: string | null): string;
|
25
|
+
static fromOptions(value: string, isArray?: boolean): any;
|
26
|
+
private static convertFromOptions(result: any, match: string): any;
|
27
|
+
static params(params: any, quota?: string | null): string;
|
28
|
+
static fromParams(value: string, isArray?: boolean): any;
|
29
|
+
private static convertFromParams(result: any, match: string): any;
|
30
|
+
}
|
31
|
+
|
32
|
+
export default Str;
|
33
|
+
}
|