Skip to content
This repository was archived by the owner on Nov 28, 2020. It is now read-only.

Commit c4eb4ac

Browse files
committed
Main: Update code and add features
1 parent c4d2cef commit c4eb4ac

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/peb.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,22 @@
88

99
;(function ( global, factory ) {
1010
'use strict';
11+
12+
let Peb = factory( global )
13+
1114
if ( global.module ) {
12-
moudule.export = factory( global );
15+
// Node.js
16+
moudule.export = Peb;
1317
} else if ( global.window ) {
14-
window.peb = factory( global );
18+
// Browser
19+
window.peb = Peb;
20+
}
21+
22+
// AMD
23+
if ( typeof define === 'function' && define.amd ) {
24+
define( "peb", [], function () {
25+
return Peb;
26+
});
1527
}
1628
})( this, function ( window ) {
1729
'use strict';
@@ -482,19 +494,21 @@
482494
/**
483495
* Return a boolean of is obj a number
484496
* Contains `123` `"123"` `1.23` `"1.23"` `.23` `".23"`
485-
* @param {any} obj
497+
* @param {string | number} obj
486498
*/
487499
peb.isdigit = function (obj) {
488500
return !isNaN(obj)
489501
}
490502

491503
/**
492-
* Sleep time but `await` required
504+
* Sleep time
505+
* `peb.sleep(time).then(Fn)` = setTimeOut
506+
* `await sleep(time)` is normal sleep time
493507
* @param {number} time
494508
*/
495509
peb.sleep = async function (time) {
496510
return new Promise(resolve => {
497-
setTimeout(() => resolve(), time);
511+
setTimeout( resolve, time );
498512
});
499513
}
500514

0 commit comments

Comments
 (0)