diff --git a/lib/hash.js b/lib/hash.js index 0a054b3..73be18d 100644 --- a/lib/hash.js +++ b/lib/hash.js @@ -1,7 +1,18 @@ module.exports = Hash; var Traverse = require('traverse'); -function Hash (hash, extra) { +function Hash (hash, xs) { + if (Array.isArray(hash) && Array.isArray(xs)) { + var to = Math.min(hash.length, xs.length); + var acc = {}; + for (var i = 0; i < to; i++) { + acc[hash[i]] = xs[i]; + } + return Hash(acc); + } + + if (hash === undefined) return Hash({}); + var self = { map : function (f) { var acc = { __proto__ : hash.__proto__ }; @@ -139,3 +150,6 @@ Hash.concat = function (xs) { return hash.items; }; +Hash.zip = function (xs, ys) { + return Hash(xs, ys).items; +};