Comparing version 0.2.6 to 0.2.7
@@ -34,1 +34,5 @@ | ||
- [feature] 添加 requestAnimationFrame / cancelAnimationFrame | ||
0.2.7 | ||
================== | ||
- [feature] 添加 febs.utils.sleep |
@@ -44,3 +44,3 @@ { | ||
"name": "febs", | ||
"version": "0.2.6" | ||
"version": "0.2.7" | ||
} |
@@ -61,2 +61,14 @@ febs 库是一些常用的工具的合集; | ||
utils库包含了一些常用的函数, 如判断浏览器是否是手机/时间字符串格式化等. | ||
```js | ||
/** | ||
* @desc: 模拟sleep. | ||
* @return: Promise. | ||
* 在ms时间后执行. | ||
* @e.g. | ||
* febs.utils.sleep(1000).then(()=>{ | ||
//1000ms之后resolve. | ||
}); | ||
*/ | ||
febs.utils.sleep(ms) | ||
``` | ||
@@ -63,0 +75,0 @@ ```js |
@@ -9,3 +9,3 @@ 'use strict'; | ||
var promise = require('promise'); | ||
var PromiseLib = Promise; | ||
var assert = require('assert'); | ||
@@ -15,2 +15,23 @@ var BigNumber = require('bignumber.js'); | ||
/** | ||
* @desc: 模拟sleep. | ||
* @return: Promise. | ||
* 在ms时间后执行. | ||
* @e.g. | ||
* febs.utils.sleep(1000).then(()=>{ | ||
//1000ms之后resolve. | ||
}); | ||
*/ | ||
exports.sleep = function(ms) { | ||
return new PromiseLib(function (resolve, reject) { | ||
try { | ||
setTimeout(function(){ | ||
resolve(); | ||
}, ms); | ||
} catch(err) { | ||
reject(err); | ||
} | ||
}); | ||
} | ||
/** | ||
* @desc: the browser is mobile. | ||
@@ -172,3 +193,3 @@ * @param userAgent: the browser user agent string. | ||
argumentCount > 0 ? argumentCount : 0); | ||
return new Promise(function (resolve, reject) { | ||
return new PromiseLib(function (resolve, reject) { | ||
args.push(function (err, res) { | ||
@@ -175,0 +196,0 @@ if (err) reject(err); |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
323041
1749
585