@kizmann/pico-js 1.0.1 → 1.0.2
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/dist/pico-js.js +1 -1
- package/dist/pico-js.js.map +1 -1
- package/package.json +2 -1
- package/src/element/example.js +2 -2
- package/src/index.js +9 -9
- package/src/library/data.js +1 -1
- package/src/library/locale.js +1 -1
- package/src/library/map.js +14 -14
- package/src/library/route.js +2 -2
- package/src/utility/dom.js +2 -2
- package/src/utility/now.js +4 -4
- package/src/utility/object.js +1 -1
- 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/package.json
CHANGED
package/src/element/example.js
CHANGED
@@ -16,7 +16,7 @@ export default class Example extends DefaultElement
|
|
16
16
|
|
17
17
|
bind()
|
18
18
|
{
|
19
|
-
if (
|
19
|
+
if ( window.$ === undefined ) {
|
20
20
|
return console.error('Element ready function requires jquery.')
|
21
21
|
}
|
22
22
|
|
@@ -47,7 +47,7 @@ export default class Example extends DefaultElement
|
|
47
47
|
opacity: 1
|
48
48
|
});
|
49
49
|
|
50
|
-
|
50
|
+
window.$(this.el).animate({ opacity: 0 }, options);
|
51
51
|
}
|
52
52
|
|
53
53
|
getReadyClass()
|
package/src/index.js
CHANGED
@@ -70,23 +70,23 @@ export const Pico = {
|
|
70
70
|
}
|
71
71
|
|
72
72
|
/**
|
73
|
-
* @const
|
73
|
+
* @const window
|
74
74
|
*/
|
75
75
|
|
76
|
-
if ( typeof
|
77
|
-
|
76
|
+
if ( typeof window.IE === 'undefined' && window.navigator ) {
|
77
|
+
window.IE = !! window.navigator.userAgent.match(/Edge\/|Trident\/|MSIE /);
|
78
78
|
}
|
79
79
|
|
80
|
-
if ( typeof
|
81
|
-
|
80
|
+
if ( typeof window.WIN === 'undefined' && window.navigator ) {
|
81
|
+
window.WIN = !! window.navigator.userAgent.match(/Windows/);
|
82
82
|
}
|
83
83
|
|
84
|
-
if ( typeof
|
85
|
-
|
84
|
+
if ( typeof window.pi === 'undefined' && window.navigator ) {
|
85
|
+
window.pi = Pico;
|
86
86
|
}
|
87
87
|
|
88
|
-
if ( typeof
|
89
|
-
|
88
|
+
if ( typeof window.pi !== 'undefined' && window.document ) {
|
89
|
+
window.pi.Dom.ready(window.pi.Element.listen);
|
90
90
|
}
|
91
91
|
|
92
92
|
export default Pico;
|
package/src/library/data.js
CHANGED
package/src/library/locale.js
CHANGED
package/src/library/map.js
CHANGED
@@ -26,7 +26,7 @@ export default class Map
|
|
26
26
|
|
27
27
|
constructor(el, options = {})
|
28
28
|
{
|
29
|
-
if ( !
|
29
|
+
if ( ! window.google ) {
|
30
30
|
throw new Error('Google Maps is required for pi.Map');
|
31
31
|
}
|
32
32
|
|
@@ -39,7 +39,7 @@ export default class Map
|
|
39
39
|
options = Obj.assign({ gestureHandling: 'cooperative', scrollwheel: null, zoom: 12, center },
|
40
40
|
Obj.except(options, ['lat', 'lng']));
|
41
41
|
|
42
|
-
this.map = new
|
42
|
+
this.map = new window.google.maps.Map(Dom.find(el).get(0), options)
|
43
43
|
}
|
44
44
|
|
45
45
|
static setMapStyle(style = [])
|
@@ -51,7 +51,7 @@ export default class Map
|
|
51
51
|
|
52
52
|
static setMarkerStyle(key, style = {}, extra = {})
|
53
53
|
{
|
54
|
-
if ( !
|
54
|
+
if ( ! window.google ) {
|
55
55
|
throw new Error('Google Maps is required for pi.Map');
|
56
56
|
}
|
57
57
|
|
@@ -70,13 +70,13 @@ export default class Map
|
|
70
70
|
let final = {};
|
71
71
|
|
72
72
|
// Marker size
|
73
|
-
let size = new
|
73
|
+
let size = new window.google.maps.Size(style.width, style.height);
|
74
74
|
|
75
75
|
// Point position
|
76
|
-
let origin = new
|
76
|
+
let origin = new window.google.maps.Point(0, 0);
|
77
77
|
|
78
78
|
// Point position
|
79
|
-
let anchor = new
|
79
|
+
let anchor = new window.google.maps.Point(style.width / 2, style.height);
|
80
80
|
|
81
81
|
final.default = {
|
82
82
|
url: style.default, size: size, origin: origin, anchor: anchor, scaledSize: size
|
@@ -113,7 +113,7 @@ export default class Map
|
|
113
113
|
return;
|
114
114
|
}
|
115
115
|
|
116
|
-
if ( typeof
|
116
|
+
if ( typeof window.MarkerClusterer === "undefined" ) {
|
117
117
|
return console.error('Google Maps Cluster library not laoded!');
|
118
118
|
}
|
119
119
|
|
@@ -140,7 +140,7 @@ export default class Map
|
|
140
140
|
return visible && this.clusterFilter.call(this, item);
|
141
141
|
});
|
142
142
|
|
143
|
-
this.cluster = new
|
143
|
+
this.cluster = new window.MarkerClusterer(this.map, Arr.each(markers, (item) => item.marker),
|
144
144
|
this.clusterOptions = options);
|
145
145
|
}
|
146
146
|
|
@@ -383,7 +383,7 @@ export default class Map
|
|
383
383
|
item.style = options.style;
|
384
384
|
}
|
385
385
|
|
386
|
-
item.marker = new
|
386
|
+
item.marker = new window.google.maps.Marker(options);
|
387
387
|
|
388
388
|
if ( !options.visible ) {
|
389
389
|
item.marker.setVisible(false);
|
@@ -410,7 +410,7 @@ export default class Map
|
|
410
410
|
// Add marker default style
|
411
411
|
item.marker.addListener('mouseout', () => this.leaveMarker(key));
|
412
412
|
|
413
|
-
item.info = new
|
413
|
+
item.info = new window.google.maps.InfoWindow({
|
414
414
|
content: '<div class="gw-i-html">' + Obj.get(options, 'html') + '</div>'
|
415
415
|
});
|
416
416
|
|
@@ -445,7 +445,7 @@ export default class Map
|
|
445
445
|
|
446
446
|
getLocationByAddress(address, callback = null)
|
447
447
|
{
|
448
|
-
let geocoderService = new
|
448
|
+
let geocoderService = new window.google.maps.Geocoder();
|
449
449
|
|
450
450
|
let geocoderPromise = (resolve, reject) => {
|
451
451
|
|
@@ -495,7 +495,7 @@ export default class Map
|
|
495
495
|
markers = Obj.filter(this.markers, filter);
|
496
496
|
}
|
497
497
|
|
498
|
-
let boundry = new
|
498
|
+
let boundry = new window.google.maps.LatLngBounds();
|
499
499
|
|
500
500
|
Obj.each(markers, (item) => {
|
501
501
|
if ( item.marker.getVisible() ) {
|
@@ -526,10 +526,10 @@ export default class Map
|
|
526
526
|
renderDirections(options)
|
527
527
|
{
|
528
528
|
// Get directions service
|
529
|
-
let directionsService = new
|
529
|
+
let directionsService = new window.google.maps.DirectionsService();
|
530
530
|
|
531
531
|
// Get directions renderer
|
532
|
-
let directionsRenderer = new
|
532
|
+
let directionsRenderer = new window.google.maps.DirectionsRenderer();
|
533
533
|
|
534
534
|
if ( ! Obj.has(options, 'map') ) {
|
535
535
|
options.map = this.map;
|
package/src/library/route.js
CHANGED
@@ -2,7 +2,7 @@ import { Obj, Str, Any } from "../index.js";
|
|
2
2
|
|
3
3
|
export default class Route
|
4
4
|
{
|
5
|
-
static routes = Obj.get(
|
5
|
+
static routes = Obj.get(window, '_routes', {});
|
6
6
|
|
7
7
|
static set (key, value)
|
8
8
|
{
|
@@ -22,7 +22,7 @@ export default class Route
|
|
22
22
|
|
23
23
|
static goto (key, values = null, params = null)
|
24
24
|
{
|
25
|
-
|
25
|
+
window.location.href = this.get(key, values, params);
|
26
26
|
}
|
27
27
|
|
28
28
|
}
|
package/src/utility/dom.js
CHANGED
@@ -111,8 +111,8 @@ export class Dom
|
|
111
111
|
|
112
112
|
static title(text = null, glue = ' - ')
|
113
113
|
{
|
114
|
-
document.title =
|
115
|
-
text + glue +
|
114
|
+
document.title = window.baseTitle !== undefined ?
|
115
|
+
text + glue + window.baseTitle : text;
|
116
116
|
|
117
117
|
return this;
|
118
118
|
}
|
package/src/utility/now.js
CHANGED
@@ -7,7 +7,7 @@ export class Now
|
|
7
7
|
|
8
8
|
constructor(date = null, format = 'YYYY-MM-DD HH:mm:ss')
|
9
9
|
{
|
10
|
-
if ( !
|
10
|
+
if ( ! window.moment ) {
|
11
11
|
throw new Error('Moment.js is required for pi.Now');
|
12
12
|
}
|
13
13
|
|
@@ -18,14 +18,14 @@ export class Now
|
|
18
18
|
this.initialDate = date;
|
19
19
|
|
20
20
|
if ( ! Any.isString(date) ) {
|
21
|
-
this.moment =
|
21
|
+
this.moment = window.moment(date || new Date, format);
|
22
22
|
}
|
23
23
|
|
24
24
|
if ( this.moment !== null ) {
|
25
25
|
return this;
|
26
26
|
}
|
27
27
|
|
28
|
-
this.moment =
|
28
|
+
this.moment = window.moment(date.match(/^now/) ?
|
29
29
|
new Date : date, format);
|
30
30
|
|
31
31
|
let second = this.initialDate.match(/(\+|-)([0-9]+)seconds?/);
|
@@ -92,7 +92,7 @@ export class Now
|
|
92
92
|
valid()
|
93
93
|
{
|
94
94
|
return ! Any.isEmpty(this.initialDate) &&
|
95
|
-
|
95
|
+
window.moment(this.initialDate).isValid();
|
96
96
|
}
|
97
97
|
|
98
98
|
clone()
|
package/src/utility/object.js
CHANGED
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
|
+
}
|