This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var add1 = function (arr, val, n) { | |
//Callback function for the reduce method. | |
var cb = function(remaining, cur, i, arr) { | |
if(cur === val && remaining > 0) { | |
arr[i]++; | |
--remaining; | |
} | |
return remaining; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* bcd2number -> takes a nodejs buffer with a BCD and returns the corresponding number. | |
* input: nodejs buffer | |
* output: number | |
*/ | |
var bcd2number = function(bcd) | |
{ | |
var n = 0; | |
var m = 1; | |
for(var i = 0; i<bcd.length; i+=1) { |