fingerprint-container-node-sdk
Advanced tools
Comparing version 0.1.9 to 0.1.10
@@ -9,2 +9,6 @@ var util = require('util'); | ||
Service.apply(this, arguments); | ||
// if run rpc request frequently, | ||
// should let this array to like-array object | ||
// but now, i dont know her | ||
this.rpcs = []; | ||
@@ -28,4 +32,11 @@ } | ||
var askId = msg.askId; | ||
var rpcInfo = _.findWhere(_me.rpcs, {askId: askId}); | ||
_me.rpcs.splice(rpcInfo.index, 1); | ||
var index = _.findIndex(_me.rpcs, _.matches({askId: askId})); | ||
// in reality, 'index' should be always unequal to -1 | ||
// but in case, we judge it for keeping away from error | ||
if(index == -1){ | ||
return; | ||
} | ||
_me.rpcs.splice(index, 1); | ||
hasErrorFn && error({ | ||
@@ -45,4 +56,3 @@ error: new Error('timeout'), | ||
error: error, | ||
timer: timer, | ||
index: this.rpcs.length | ||
timer: timer | ||
}); | ||
@@ -65,5 +75,11 @@ }; | ||
var askId = msg.askId; | ||
var rpcInfo = _.findWhere(this.rpcs, {askId: askId}); | ||
if (rpcInfo == null) { | ||
// underscore version > 1.7+, it has findIndex method | ||
// _.matches is already deprecated, but underscore source code still use it | ||
var index = _.findIndex(this.rpcs, _.matches({askId: askId})); | ||
var rpcInfo = null; | ||
if (index == -1) { | ||
return; | ||
}else{ | ||
rpcInfo = this.rpcs.splice(index, 1)[0]; | ||
} | ||
@@ -83,3 +99,2 @@ | ||
} | ||
this.rpcs.splice(rpcInfo.index, 1); | ||
} | ||
@@ -86,0 +101,0 @@ }; |
{ | ||
"name": "fingerprint-container-node-sdk", | ||
"version": "0.1.9", | ||
"version": "0.1.10", | ||
"description": "fingerprint container's sdk", | ||
@@ -5,0 +5,0 @@ "main": "fpc.js", |
41477
1026