axj-ab_ 1.0.6 → 1.0.7

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.
Files changed (4) hide show
  1. package/dtsmake.sh +4 -0
  2. package/index.d.ts +209 -184
  3. package/index.js +83 -10
  4. package/package.json +6 -3
package/dtsmake.sh ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env bash
2
+ cd `dirname $0`
3
+
4
+ dtsmake -s index.js
package/index.d.ts CHANGED
@@ -1,168 +1,166 @@
1
- // Type definitions for assets/script/libs/abom.js
1
+ // Type definitions for index.js
2
2
  // Project: [LIBRARY_URL_HERE]
3
3
  // Definitions by: [YOUR_NAME_HERE] <[YOUR_URL_HERE]>
4
4
  // Definitions: https://github.com/borisyankov/DefinitelyTyped
5
- export default ab_
6
-
7
- declare namespace ab_ {
5
+ declare namespace ab_{
8
6
  // ab_.route.!ret
9
-
7
+
10
8
  /**
11
9
  *
12
10
  */
13
11
  interface RouteRet {
14
-
12
+
15
13
  /**
16
14
  *
17
15
  */
18
- hash: string;
19
-
16
+ hash : string;
17
+
20
18
  /**
21
19
  *
22
20
  */
23
- search: {
21
+ search : {
24
22
  }
25
-
23
+
26
24
  /**
27
25
  *
28
26
  */
29
- path: /* ab_.$route.path */ any;
27
+ path : /* ab_.$route.path */ any;
30
28
  }
31
29
  }
32
- declare namespace ab_ {
30
+ declare namespace ab_{
33
31
  // ab_.reqJs.!2
34
32
  type ReqJs2 = (() => void);
35
33
  }
36
- declare namespace ab_ {
34
+ declare namespace ab_{
37
35
  // ab_.reqModule.!ret
38
- type ReqModuleRet = ((call: any) => void);
36
+ type ReqModuleRet = ((call : any) => void);
39
37
  }
40
- declare namespace ab_ {
38
+ declare namespace ab_{
41
39
  // ab_.args.!0
42
40
  type Args0 = Array<any>;
43
41
  }
44
- declare namespace ab_ {
42
+ declare namespace ab_{
45
43
  // ab_.swap.!0
46
-
44
+
47
45
  /**
48
46
  *
49
47
  */
50
48
  interface Swap0 {
51
49
  }
52
50
  }
53
- declare namespace ab_ {
51
+ declare namespace ab_{
54
52
  // ab_.newReady.!ret
55
-
53
+
56
54
  /**
57
55
  *
58
56
  */
59
57
  interface NewReadyRet {
60
-
58
+
61
59
  /**
62
60
  *
63
61
  */
64
62
  start(): void;
65
-
63
+
66
64
  /**
67
65
  *
68
66
  * @param back
69
67
  */
70
- (back: any): void;
68
+ (back : any): void;
71
69
  }
72
70
  }
73
- declare namespace ab_ {
71
+ declare namespace ab_{
74
72
  // ab_.newStart.!ret
75
-
73
+
76
74
  /**
77
75
  *
78
76
  */
79
77
  interface NewStartRet {
80
-
78
+
81
79
  /**
82
80
  *
83
81
  */
84
82
  waite(): void;
85
-
83
+
86
84
  /**
87
85
  *
88
86
  * @param inited
89
87
  */
90
- (inited: any): void;
88
+ (inited : any): void;
91
89
  }
92
90
  }
93
- declare namespace ab_ {
91
+ declare namespace ab_{
94
92
  // ab_.cssSetRest.!1
95
93
  type CssSetRest1 = Array<string>;
96
94
  }
97
- declare namespace ab_ {
95
+ declare namespace ab_{
98
96
  // ab_.cssSetRest.!ret
99
-
97
+
100
98
  /**
101
99
  *
102
100
  */
103
101
  interface CssSetRestRet {
104
-
102
+
105
103
  /**
106
104
  *
107
105
  * @param vals
108
106
  */
109
- set(vals: ab_.CssSetRestRet.Set0): void;
110
-
107
+ set(vals : ab_.CssSetRestRet.Set0): void;
108
+
111
109
  /**
112
110
  *
113
111
  */
114
112
  reset(): void;
115
113
  }
116
114
  }
117
- declare namespace ab_.CssSetRestRet {
115
+ declare namespace ab_.CssSetRestRet{
118
116
  // ab_.cssSetRest.!ret.set.!0
119
117
  type Set0 = Array<string>;
120
118
  }
121
- declare namespace ab_ {
119
+ declare namespace ab_{
122
120
  // ab_.setPaths.!0
123
-
121
+
124
122
  /**
125
123
  *
126
124
  */
127
125
  interface SetPaths0 {
128
126
  }
129
127
  }
130
- declare namespace ab_ {
128
+ declare namespace ab_{
131
129
  // ab_.fullScreen.!ret
132
130
  type FullScreenRet = (() => void);
133
131
  }
134
- declare namespace ab_ {
132
+ declare namespace ab_{
135
133
  // ab_.funTimer.!ret
136
-
134
+
137
135
  /**
138
136
  *
139
137
  */
140
138
  interface FunTimerRet {
141
-
139
+
142
140
  /**
143
141
  *
144
142
  * @param interval
145
143
  */
146
- start(interval: any): void;
147
-
144
+ start(interval : any): void;
145
+
148
146
  /**
149
147
  *
150
148
  */
151
149
  stop(): void;
152
150
  }
153
151
  }
154
- declare namespace ab_ {
152
+ declare namespace ab_{
155
153
  // ab_.loadState.!2
156
-
154
+
157
155
  /**
158
156
  *
159
157
  */
160
158
  interface LoadState2 {
161
159
  }
162
160
  }
163
- declare namespace ab_ {
161
+ declare namespace ab_{
164
162
  // ab_.saveState.!0
165
-
163
+
166
164
  /**
167
165
  *
168
166
  */
@@ -173,77 +171,87 @@ declare namespace ab_ {
173
171
  /**
174
172
  *
175
173
  */
176
- declare namespace ab_ {
174
+ export declare var _nextT : number;
177
175
 
176
+ /**
177
+ *
178
+ */
179
+ declare namespace ab_{
180
+
178
181
  /**
179
182
  *
180
183
  */
181
- export var _ver: boolean;
182
-
184
+ export var _ver : boolean;
185
+
183
186
  /**
184
187
  *
185
188
  */
186
- export var local: boolean;
187
-
189
+ export var local : boolean;
190
+
191
+ /**
192
+ *
193
+ */
194
+ export var https : boolean;
195
+
188
196
  /**
189
197
  *
190
198
  * @param fn
191
199
  */
192
- function fn(fn: any): void;
193
-
200
+ function fn(fn : any): void;
201
+
194
202
  /**
195
203
  *
196
204
  */
197
205
  function header(): void;
198
-
206
+
199
207
  /**
200
208
  *
201
209
  */
202
210
  function back(): void;
203
-
211
+
204
212
  /**
205
213
  *
206
214
  * @param uri
207
215
  * @param title
208
216
  */
209
- function push(uri: any, title: any): void;
210
-
217
+ function push(uri : any, title : any): void;
218
+
211
219
  /**
212
220
  *
213
221
  * @param uri
214
222
  * @param title
215
223
  */
216
- function replace(uri: any, title: any): void;
217
-
224
+ function replace(uri : any, title : any): void;
225
+
218
226
  /**
219
227
  *
220
228
  * @param uri
221
229
  * @param title
222
230
  * @param alone
223
231
  */
224
- function open(uri: any, title: any, alone: any): void;
225
-
232
+ function open(uri : any, title : any, alone : any): void;
233
+
226
234
  /**
227
235
  *
228
236
  * @param name
229
237
  */
230
- function get(name: any): void;
231
-
238
+ function get(name : any): void;
239
+
232
240
  /**
233
241
  *
234
242
  * @param o
235
243
  * @return
236
244
  */
237
- function empty(o: any): boolean;
238
-
245
+ function empty(o : any): boolean;
246
+
239
247
  /**
240
248
  *
241
249
  * @param url
242
250
  * @param para
243
251
  * @return
244
252
  */
245
- function urlRm(url: any, para: any): any;
246
-
253
+ function urlRm(url : any, para : any): any;
254
+
247
255
  /**
248
256
  *
249
257
  * @param url
@@ -251,21 +259,21 @@ declare namespace ab_ {
251
259
  * @param force
252
260
  * @return
253
261
  */
254
- function urlParas(url: any, paras: string, force: any): string;
255
-
262
+ function urlParas(url : any, paras : string, force : any): string;
263
+
256
264
  /**
257
265
  *
258
266
  * @return
259
267
  */
260
268
  function urlPath(): string;
261
-
269
+
262
270
  /**
263
271
  *
264
272
  * @param path
265
273
  * @return
266
274
  */
267
- function pathDir(path: any): string;
268
-
275
+ function pathDir(path : any): string;
276
+
269
277
  /**
270
278
  *
271
279
  * @param anch
@@ -273,43 +281,57 @@ declare namespace ab_ {
273
281
  * @param set
274
282
  * @return
275
283
  */
276
- function route(anch: any, url: any, set: any): ab_.RouteRet;
277
-
284
+ function route(anch : any, url : any, set : any): ab_.RouteRet;
285
+
278
286
  /**
279
287
  *
280
288
  * @param el
281
289
  * @return
282
290
  */
283
- function el(el: number): number;
284
-
291
+ function el(el : number): number;
292
+
285
293
  /**
286
294
  *
287
295
  * @param url
288
296
  * @return
289
297
  */
290
- function ver(url: string): string;
291
-
298
+ function ver(url : string): string;
299
+
292
300
  /**
293
301
  *
294
302
  * @param href
295
303
  * @param el
296
304
  * @param media
297
305
  */
298
- function reqCss(href: any, el: any, media: any): void;
299
-
306
+ function reqCss(href : any, el : any, media : any): void;
307
+
300
308
  /**
301
309
  *
302
310
  */
303
311
  function call(): void;
304
-
312
+
313
+ /**
314
+ *
315
+ * @param requires
316
+ * @param fun
317
+ */
318
+ function requires(requires : any, fun : any): void;
319
+
320
+ /**
321
+ *
322
+ * @return
323
+ */
324
+ function nextT(): number;
325
+
305
326
  /**
306
327
  *
307
328
  * @param js
308
329
  * @param el
309
- * @param call
330
+ * @param onload
331
+ * @param onerror
310
332
  */
311
- function reqJs(js: string, el: number, call: ab_.ReqJs2): void;
312
-
333
+ function reqJs(js : string, el : number, onload : ab_.ReqJs2, onerror : any): void;
334
+
313
335
  /**
314
336
  *
315
337
  * @param name
@@ -317,8 +339,8 @@ declare namespace ab_ {
317
339
  * @param csses
318
340
  * @return
319
341
  */
320
- function reqModule(name: any, jses: any, csses: any): ab_.ReqModuleRet;
321
-
342
+ function reqModule(name : any, jses : any, csses : any): ab_.ReqModuleRet;
343
+
322
344
  /**
323
345
  *
324
346
  * @param exp
@@ -326,8 +348,13 @@ declare namespace ab_ {
326
348
  * @param $this
327
349
  * @param res
328
350
  */
329
- function eval(exp: any, $page: any, $this: any, res: any): void;
330
-
351
+ function eval(exp : any, $page : any, $this : any, res : any): void;
352
+
353
+ /**
354
+ *
355
+ */
356
+ export var $center : /*no type*/{};
357
+
331
358
  /**
332
359
  *
333
360
  * @param args
@@ -335,8 +362,8 @@ declare namespace ab_ {
335
362
  * @param len
336
363
  * @return
337
364
  */
338
- function args(args: ab_.Args0, off: number, len: number): Array</*!0.<i>*/ any>;
339
-
365
+ function args(args : ab_.Args0, off : number, len : number): Array</*!0.<i>*/ any>;
366
+
340
367
  /**
341
368
  *
342
369
  * @param ary
@@ -344,8 +371,8 @@ declare namespace ab_ {
344
371
  * @param to
345
372
  * @return
346
373
  */
347
- function swap(ary: ab_.Swap0, from: any, to: any): ab_.Swap0;
348
-
374
+ function swap(ary : ab_.Swap0, from : any, to : any): ab_.Swap0;
375
+
349
376
  /**
350
377
  *
351
378
  * @param ary
@@ -353,105 +380,106 @@ declare namespace ab_ {
353
380
  * @param to
354
381
  * @return
355
382
  */
356
- function reSort(ary: any, from: any, to: any): any;
357
-
383
+ function reSort(ary : any, from : any, to : any): any;
384
+
358
385
  /**
359
386
  *
360
387
  * @param children
361
388
  * @param fromI
362
389
  * @param toI
363
390
  */
364
- function resetEl(children: any, fromI: any, toI: any): void;
365
-
391
+ function resetEl(children : any, fromI : any, toI : any): void;
392
+
366
393
  /**
367
394
  *
368
395
  * @param from
369
396
  * @param to
370
397
  */
371
- function swapEl(from: any, to: any): void;
372
-
398
+ function swapEl(from : any, to : any): void;
399
+
373
400
  /**
374
401
  *
375
402
  * @param name
376
403
  */
377
- function post(name: any): void;
378
-
404
+ function post(name : any): void;
405
+
379
406
  /**
380
407
  *
381
408
  * @param data
382
409
  * @param i
410
+ * @param from
383
411
  */
384
- function posts(data: any, i: number, from: any): void;
385
-
412
+ function posts(data : any, i : number, from : any): void;
413
+
386
414
  /**
387
415
  *
388
416
  */
389
- export var langs: /*no type*/{};
390
-
417
+ export var langs : /*no type*/{};
418
+
391
419
  /**
392
420
  *
393
421
  * @param lang
394
422
  * @param call
395
423
  */
396
- function langChange(lang: any, call: any): void;
397
-
424
+ function langChange(lang : any, call : any): void;
425
+
398
426
  /**
399
427
  *
400
428
  * @param key
401
429
  * @param lang
402
430
  */
403
- function lang(key: any, lang: any): void;
404
-
431
+ function lang(key : any, lang : any): void;
432
+
405
433
  /**
406
434
  *
407
435
  * @param key
408
436
  * @param par
409
437
  * @return
410
438
  */
411
- function i18n(key: any, par: any): any;
412
-
439
+ function i18n(key : any, par : any): any;
440
+
413
441
  /**
414
442
  *
415
443
  * @return
416
444
  */
417
445
  function time(): number;
418
-
446
+
419
447
  /**
420
448
  *
421
449
  * @param time
422
450
  * @param max
423
451
  * @return
424
452
  */
425
- function humTime(time: any, max: any): string;
426
-
453
+ function humTime(time : any, max : any): string;
454
+
427
455
  /**
428
456
  *
429
457
  * @param size
430
458
  * @return
431
459
  */
432
- function humSize(size: any): string;
433
-
460
+ function humSize(size : any): string;
461
+
434
462
  /**
435
463
  *
436
464
  * @param json
437
465
  * @return
438
466
  */
439
- function parseJson(json: any): any;
440
-
467
+ function parseJson(json : any): any;
468
+
441
469
  /**
442
470
  *
443
471
  * @param obj
444
472
  * @return
445
473
  */
446
- function toJson(obj: any): string;
447
-
474
+ function toJson(obj : any): string;
475
+
448
476
  /**
449
477
  *
450
478
  * @param tpl
451
479
  * @param render
452
480
  */
453
- function tplRender(tpl: any, render: any): void;
454
-
481
+ function tplRender(tpl : any, render : any): void;
482
+
455
483
  /**
456
484
  * 支持formData file var form = new FormData();form.append("file", fileObj);
457
485
  * @param loading
@@ -461,8 +489,8 @@ declare namespace ab_ {
461
489
  * @param callback
462
490
  * @param init
463
491
  */
464
- function xhrReq(loading: any, headers: any, url: any, posts: any, callback: any, init: any): void;
465
-
492
+ function xhrReq(loading : any, headers : any, url : any, posts : any, callback : any, init : any): void;
493
+
466
494
  /**
467
495
  *
468
496
  * @param loading
@@ -473,49 +501,49 @@ declare namespace ab_ {
473
501
  * @param callback
474
502
  * @param init
475
503
  */
476
- function uniReq(loading: any, headers: any, url: any, posts: any, files: any, callback: any, init: any): void;
477
-
504
+ function uniReq(loading : any, headers : any, url : any, posts : any, files : any, callback : any, init : any): void;
505
+
478
506
  /**
479
507
  *
480
508
  * @param last
481
509
  * @return
482
510
  */
483
- function newReady(last: any): ab_.NewReadyRet;
484
-
511
+ function newReady(last : any): ab_.NewReadyRet;
512
+
485
513
  /**
486
514
  *
487
515
  * @param run
488
516
  * @return
489
517
  */
490
- function newStart(run: any): ab_.NewStartRet;
491
-
518
+ function newStart(run : any): ab_.NewStartRet;
519
+
492
520
  /**
493
521
  *
494
522
  */
495
523
  function vConsole(): void;
496
-
524
+
497
525
  /**
498
526
  *
499
527
  * @param $el
500
528
  * @param name
501
529
  */
502
- function getStyle($el: any, name: string): void;
503
-
530
+ function getStyle($el : any, name : string): void;
531
+
504
532
  /**
505
533
  *
506
534
  * @param $el
507
535
  * @param names
508
536
  * @return
509
537
  */
510
- function cssSetRest($el: any, names: ab_.CssSetRest1): ab_.CssSetRestRet;
511
-
538
+ function cssSetRest($el : any, names : ab_.CssSetRest1): ab_.CssSetRestRet;
539
+
512
540
  /**
513
541
  *
514
542
  * @param el
515
543
  * @param tag
516
544
  */
517
- function cloneElement(el: any, tag: any): void;
518
-
545
+ function cloneElement(el : any, tag : any): void;
546
+
519
547
  /**
520
548
  *
521
549
  * @param to
@@ -523,29 +551,29 @@ declare namespace ab_ {
523
551
  * @param depth
524
552
  * @return
525
553
  */
526
- function objectMerge(to: any, from: any, depth: number): any;
527
-
554
+ function objectMerge(to : any, from : any, depth : number): any;
555
+
528
556
  /**
529
557
  *
530
558
  * @param inst
531
559
  * @return
532
560
  */
533
- function keepAlive(inst: any): any;
534
-
561
+ function keepAlive(inst : any): any;
562
+
535
563
  /**
536
564
  *
537
565
  * @param key
538
566
  */
539
- function keepAliveClose(key: any): void;
540
-
567
+ function keepAliveClose(key : any): void;
568
+
541
569
  /**
542
570
  *
543
571
  * @param $keepAlive
544
572
  * @param key
545
573
  * @param cKey
546
574
  */
547
- function keepAliveDel($keepAlive: any, key: any, cKey: any): void;
548
-
575
+ function keepAliveDel($keepAlive : any, key : any, cKey : any): void;
576
+
549
577
  /**
550
578
  *
551
579
  * @param model
@@ -553,8 +581,8 @@ declare namespace ab_ {
553
581
  * @param fromI
554
582
  * @return
555
583
  */
556
- function getPaths(model: any, paths: any, fromI: number): /* error */ any;
557
-
584
+ function getPaths(model : any, paths : any, fromI : number): /* error */ any;
585
+
558
586
  /**
559
587
  *
560
588
  * @param model
@@ -562,42 +590,37 @@ declare namespace ab_ {
562
590
  * @param paths
563
591
  * @param fromI
564
592
  */
565
- function setPaths(model: ab_.SetPaths0, val: any, paths: any, fromI: number): void;
566
-
593
+ function setPaths(model : ab_.SetPaths0, val : any, paths : any, fromI : number): void;
594
+
567
595
  /**
568
596
  *
569
597
  * @param time
570
598
  * @return
571
599
  */
572
- function date(time: any): Date;
573
-
600
+ function date(time : any): Date;
601
+
574
602
  /**
575
603
  *
576
604
  * @param time
577
605
  * @param fmt
578
606
  */
579
- function formatTime(time: any, fmt: any): void;
580
-
607
+ function formatTime(time : any, fmt : any): void;
608
+
581
609
  /**
582
610
  *
583
611
  * @param date
584
612
  * @param fmt
585
613
  * @return
586
614
  */
587
- function formatDate(date: Date, fmt: string): string;
588
-
589
- /**
590
- *
591
- */
592
- function xhrOntimeout(): void;
593
-
615
+ function formatDate(date : Date, fmt : string): string;
616
+
594
617
  /**
595
618
  *
596
619
  * @param name
597
620
  * @return
598
621
  */
599
- function aName(name: any): string;
600
-
622
+ function aName(name : any): string;
623
+
601
624
  /**
602
625
  *
603
626
  * @param a
@@ -605,8 +628,8 @@ declare namespace ab_ {
605
628
  * @param underline
606
629
  * @return
607
630
  */
608
- function aNameC(a: any, name: any, underline: any): any;
609
-
631
+ function aNameC(a : any, name : any, underline : any): any;
632
+
610
633
  /**
611
634
  *
612
635
  * @param $this
@@ -614,30 +637,32 @@ declare namespace ab_ {
614
637
  * @param fun
615
638
  * @return
616
639
  */
617
- function fullScreen($this: any, $el: any, fun: any): ab_.FullScreenRet;
618
-
640
+ function fullScreen($this : any, $el : any, fun : any): ab_.FullScreenRet;
641
+
619
642
  /**
620
643
  *
621
644
  * @param val
645
+ * @param cHead
646
+ * @param cEnd
622
647
  * @return
623
648
  */
624
- function cvsVal(val: string): string;
625
-
649
+ function cvsVal(val : string, cHead : any, cEnd : any): string;
650
+
626
651
  /**
627
652
  *
628
653
  * @param txt
629
654
  * @param name
630
655
  * @param bom
631
656
  */
632
- function downloadTxt(txt: string, name: any, bom: any): void;
633
-
657
+ function downloadTxt(txt : string, name : any, bom : any): void;
658
+
634
659
  /**
635
660
  *
636
661
  * @param fun
637
662
  * @return
638
663
  */
639
- function funTimer(fun: any): ab_.FunTimerRet;
640
-
664
+ function funTimer(fun : any): ab_.FunTimerRet;
665
+
641
666
  /**
642
667
  *
643
668
  * @param bind
@@ -646,8 +671,8 @@ declare namespace ab_ {
646
671
  * @param props
647
672
  * @return
648
673
  */
649
- function loadState(bind: any, path: any, target: ab_.LoadState2, props: any): boolean;
650
-
674
+ function loadState(bind : any, path : any, target : ab_.LoadState2, props : any): boolean;
675
+
651
676
  /**
652
677
  *
653
678
  * @param bind
@@ -655,32 +680,32 @@ declare namespace ab_ {
655
680
  * @param target
656
681
  * @param props
657
682
  */
658
- function saveState(bind: ab_.SaveState0, path: any, target: any, props: any): void;
659
-
683
+ function saveState(bind : ab_.SaveState0, path : any, target : any, props : any): void;
684
+
660
685
  /**
661
686
  *
662
687
  */
663
- namespace $route {
664
-
688
+ namespace $route{
689
+
665
690
  /**
666
691
  *
667
692
  */
668
- export var hash: string;
669
-
693
+ export var hash : string;
694
+
670
695
  /**
671
696
  *
672
697
  */
673
- export var path: Array</* [? */ any> | /* string] */ any;
674
-
698
+ export var path : Array</* [? */ any> | /* string] */ any;
699
+
675
700
  /**
676
701
  *
677
702
  */
678
- var search: {
703
+ var search : {
679
704
  }
680
705
  }
681
-
706
+
682
707
  /**
683
708
  *
684
709
  */
685
- export var vconsoled: boolean;
710
+ export var vconsoled : boolean;
686
711
  }
package/index.js CHANGED
@@ -1,3 +1,5 @@
1
+ let _nextT = 0
2
+
1
3
  var ab_ = {
2
4
 
3
5
  _ver: false,
@@ -233,15 +235,61 @@ var ab_ = {
233
235
  }
234
236
  },
235
237
 
236
- reqJs(js, el, call) {
238
+ requires(requires, fun) {
239
+ if (!requires) {
240
+ return
241
+ }
242
+
243
+ if (requires && requires.webpack) {
244
+ requires.keys().forEach(key => {
245
+ fun(key, requires(key))
246
+ })
247
+
248
+ } else {
249
+ for (let key in requires) {
250
+ fun(key, requires[key])
251
+ }
252
+ }
253
+ },
254
+
255
+ nextT() {
256
+ var t = ab_.time()
257
+ if (t < _nextT) {
258
+ t = ++_nextT
259
+
260
+ } else {
261
+ _nextT = t
262
+ }
263
+
264
+ return t
265
+ },
266
+
267
+ reqJs(js, el, onload, onerror) {
237
268
  var script = document.createElement('script')
238
269
  script.type = 'text/javascript'
239
270
  if (call) {
240
- if (script.readyState) { //IE
241
- script.onreadystatechange = call
271
+ if (script.readyState !== undefined) {
272
+ //IE
273
+ if (onload || onerror) {
274
+ script.onreadystatechange = function () {
275
+ let state = script.readyState
276
+ if (state && typeof (state) === 'string') {
277
+ if (state === 'loaded') {
278
+ onload && onload()
279
+
280
+ } else if (state.indexOf('err') >= 0 || state.indexOf('fail') >= 0) {
281
+ onerror && onerror()
282
+ }
283
+
284
+ } else {
285
+ onload && onload()
286
+ }
287
+ }
288
+ }
242
289
 
243
290
  } else { //Other
244
- script.onload = call
291
+ onload && (script.onload = call)
292
+ onerror && (script.onerror = onerror)
245
293
  }
246
294
  }
247
295
 
@@ -594,6 +642,10 @@ var ab_ = {
594
642
  })
595
643
  },
596
644
 
645
+ // xhrOntimeout() {
646
+ // // console.log('请求超时。。')
647
+ // },
648
+
597
649
  // 支持formData file var form = new FormData();form.append("file", fileObj);
598
650
  xhrReq(loading, headers, url, posts, callback, init) {
599
651
  var xhr = new XMLHttpRequest()
@@ -1029,10 +1081,6 @@ var ab_ = {
1029
1081
  return fmt
1030
1082
  },
1031
1083
 
1032
- xhrOntimeout() {
1033
- // console.log('请求超时。。')
1034
- },
1035
-
1036
1084
  aName(name) {
1037
1085
  if (typeof (name) !== 'string') {
1038
1086
  return ''
@@ -1137,9 +1185,32 @@ var ab_ = {
1137
1185
  }
1138
1186
  },
1139
1187
 
1140
- cvsVal(val) {
1188
+ cvsVal(val, cHead, cEnd) {
1189
+ if (cHead || cEnd) {
1190
+ var head = 0
1191
+ var last = val.length - 1
1192
+ var cLast = last
1193
+ for (; head <= last; head++) {
1194
+ let c = val[head]
1195
+ if (c !== '\r' && c !== '\n') {
1196
+ break
1197
+ }
1198
+ }
1199
+
1200
+ for (; cLast > head; cLast--) {
1201
+ let c = val[cLast]
1202
+ if (c !== '\r' && c !== '\n') {
1203
+ break
1204
+ }
1205
+ }
1206
+
1207
+ if (head > 0 || cLast < last) {
1208
+ val = val.substr(head, cLast + 1 - cHead)
1209
+ }
1210
+ }
1211
+
1141
1212
  if (typeof (val) === 'string') {
1142
- if (val.indexOf(',') >= 0 || val.indexOf('"') >= 0) {
1213
+ if (val.indexOf(',') >= 0 || val.indexOf('"') >= 0 || val.indexOf('\r') >= 0 || val.indexOf('\n') >= 0) {
1143
1214
  val = '"' + val.replace('"', '""') + '"'
1144
1215
  }
1145
1216
  }
@@ -1195,6 +1266,7 @@ var ab_ = {
1195
1266
 
1196
1267
  return self
1197
1268
  },
1269
+
1198
1270
  loadState(bind, path, target, props) {
1199
1271
  var state = bind && bind['_$$state$$' + path]
1200
1272
  if (state && target) {
@@ -1207,6 +1279,7 @@ var ab_ = {
1207
1279
  return true
1208
1280
  }
1209
1281
  },
1282
+
1210
1283
  saveState(bind, path, target, props) {
1211
1284
  if (bind && target) {
1212
1285
  var state = {}
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "axj-ab_",
3
3
  "type": "commonjs",
4
- "version": "1.0.6",
4
+ "version": "1.0.7",
5
5
  "description": "",
6
6
  "main": "index.js",
7
7
  "scripts": {
8
8
  "test": "echo \"Error: no test specified\" && exit 1"
9
9
  },
10
10
  "author": "",
11
- "license": "ISC"
12
- }
11
+ "license": "ISC",
12
+ "devDependencies": {
13
+ "tern": "^0.24.3"
14
+ }
15
+ }