UNPKG

ndn-js-contrib

Version:

Reusable 'Classes' for Named Data Networking: NameTree, PIT, FIB, ContentStore, Interfaces, and Transports

1 lines 720 B
function compareArrays(a,b,c){if(c>=0||(c=-1),c>=0||a.length==b.length){if(c++,b[c]>a[c])return 1;if(b[c]<a[c])return-1;if(a[c]==b[c])return c<a.length-1?compareArrays(a,b,c):0}else{if(b.length>a.length)return 1;if(b.length<a.length)return-1}}var binaryIndexOfPrefix=function(a,b,c){"use strict";if(0==a.length)return-1;var d,e,f,g,h=0,i=a.length-1;for(b="prefix"==c?b.getValue().buffer:"nonce"==c?b.nonce:"faceID"==c?b.faceID:b;i>=h;)if(f=d=(h+i)/2|0,e="prefix"==c?a[d].prefix.get(-1).getValue().buffer:"nonce"==c?a[d].nonce:"faceID"==c?a[d].faceID:a[d],g="number"!=typeof b?compareArrays(b,e):function(){return b>e?-1:e>b?1:0}(),1==g)i=d-1;else{if(-1!=g)return d;h=d+1}return~(i+1)};module.exports=binaryIndexOfPrefix;