-
-
Save hacknightly/9f4484263a3a7c9b582d to your computer and use it in GitHub Desktop.
This file contains 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
// Hello. I'm learning. Thank you for sharing your insights. | |
var sUtil = require('sUtils.js'); | |
var obj = { | |
a:[1,2], | |
b:[3,4], | |
} | |
Object.keys(obj).forEach(function(key) { | |
if (Array.isArray(obj[key])) { | |
obj[key] = sUtil.bitmaskArrayToDecimal(obj[key]); | |
} | |
}); | |
This file contains 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 bitmaskArrayToDecimal = export = function (arr) { | |
var result = 0; | |
for (var i = 0; i < arr.length; i++) { | |
result = result | (1 << arr[i] - 1); | |
}; | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment