|
4469 | 4469 | * @param {boolean} enable true to enable fetchWhenSave option. |
4470 | 4470 | */ |
4471 | 4471 | fetchWhenSave: function(enable){ |
4472 | | - if (typeof enable !== 'boolean'){ |
| 4472 | + if (!_.isBoolean(enable)) { |
4473 | 4473 | throw "Expect boolean value for fetchWhenSave"; |
4474 | 4474 | } |
4475 | 4475 | this._fetchWhenSave = enable; |
|
6908 | 6908 | if(!target){ |
6909 | 6909 | throw "Invalid target user."; |
6910 | 6910 | } |
6911 | | - var userObjectId = (typeof target === 'string') ? target: target.id; |
| 6911 | + var userObjectId = _.isString(target) ? target: target.id; |
6912 | 6912 | if(!userObjectId){ |
6913 | 6913 | throw "Invalid target user."; |
6914 | 6914 | } |
|
6932 | 6932 | if(!target){ |
6933 | 6933 | throw "Invalid target user."; |
6934 | 6934 | } |
6935 | | - var userObjectId = (typeof target === 'string') ? target: target.id; |
| 6935 | + var userObjectId = _.isString(target) ? target: target.id; |
6936 | 6936 | if(!userObjectId){ |
6937 | 6937 | throw "Invalid target user."; |
6938 | 6938 | } |
|
7188 | 7188 | * @since 0.3.0 |
7189 | 7189 | */ |
7190 | 7190 | followerQuery: function(userObjectId) { |
7191 | | - if(!userObjectId || typeof userObjectId !='string'){ |
| 7191 | + if(!userObjectId || !_.isString(userObjectId)) { |
7192 | 7192 | throw "Invalid user object id."; |
7193 | 7193 | } |
7194 | 7194 | var query = new AV.FriendShipQuery('_Follower'); |
|
7203 | 7203 | * @since 0.3.0 |
7204 | 7204 | */ |
7205 | 7205 | followeeQuery: function(userObjectId) { |
7206 | | - if(!userObjectId || typeof userObjectId !='string'){ |
| 7206 | + if(!userObjectId || !_.isString(userObjectId)) { |
7207 | 7207 | throw "Invalid user object id."; |
7208 | 7208 | } |
7209 | 7209 | var query = new AV.FriendShipQuery('_Followee'); |
|
8907 | 8907 | * of the function. |
8908 | 8908 | */ |
8909 | 8909 | requestSmsCode: function(data, options){ |
8910 | | - if(typeof data === 'string') { |
| 8910 | + if(_.isString(data)) { |
8911 | 8911 | data = { mobilePhoneNumber: data }; |
8912 | 8912 | } |
8913 | 8913 | if(!data.mobilePhoneNumber) { |
|
9010 | 9010 | this.data = {}; |
9011 | 9011 | this.inboxType = 'default'; |
9012 | 9012 | this.query = null; |
9013 | | - if(imageUrl && typeof imageUrl == 'object') { |
| 9013 | + if(imageUrl && typeof imageUrl === 'object') { |
9014 | 9014 | this.data = imageUrl; |
9015 | 9015 | } else { |
9016 | 9016 | if(imageUrl){ |
|
9194 | 9194 | if(!target){ |
9195 | 9195 | throw "Invalid target user."; |
9196 | 9196 | } |
9197 | | - var userObjectId = (typeof target === 'string') ? target: target.id; |
| 9197 | + var userObjectId = _.isString(target) ? target: target.id; |
9198 | 9198 | if(!userObjectId){ |
9199 | 9199 | throw "Invalid target user."; |
9200 | 9200 | } |
|
9238 | 9238 | throw 'Please signin an user or pass the owner objectId.'; |
9239 | 9239 | } |
9240 | 9240 | owner = owner || AV.User.current(); |
9241 | | - var options = (typeof arguments[1] !== 'string') ? arguments[1] : arguments[2]; |
9242 | | - var inboxType = (typeof arguments[1] !== 'string') ? 'default' : arguments[1]; |
| 9241 | + var options = !_.isString(arguments[1]) ? arguments[1] : arguments[2]; |
| 9242 | + var inboxType = !_.isString(arguments[1]) ? 'default' : arguments[1]; |
9243 | 9243 | var params = {}; |
9244 | 9244 | params.inboxType = AV._encode(inboxType); |
9245 | 9245 | params.owner = AV._encode(owner); |
|
0 commit comments