Skip to content

Instantly share code, notes, and snippets.

@hacknightly
Forked from superherointj/app.js
Last active November 16, 2015 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hacknightly/9f4484263a3a7c9b582d to your computer and use it in GitHub Desktop.
Save hacknightly/9f4484263a3a7c9b582d to your computer and use it in GitHub Desktop.
// 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]);
}
});
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