From 2a73de5f6905b77c1a4ef35687d0d4e34cb244da Mon Sep 17 00:00:00 2001 From: Vitaly Puzrin Date: Mon, 3 Feb 2014 22:56:46 +0400 Subject: [PATCH] Added package main file --- index.js | 7 +++++++ lib/zlib/utils.js | 25 +++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 062a58a..189f577 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,14 @@ +// Top level file is just a mixin of submodules & constants 'use strict'; +var assign = require('./lib/zlib/utils').assign; + +var deflate = require('./lib/deflate'); +var inflate = require('./lib/inflate'); +var constants = require('./lib/zlib/constants'); var pako = {}; +assign(pako, deflate, inflate, constants); module.exports = pako; \ No newline at end of file diff --git a/lib/zlib/utils.js b/lib/zlib/utils.js index f037e8f..6ea97d7 100644 --- a/lib/zlib/utils.js +++ b/lib/zlib/utils.js @@ -1,12 +1,33 @@ 'use strict'; -exports.arraySet = function(dest, src, src_offs, len, dest_offs) { +exports.assign = function(obj /*from1, from2, from3, ...*/) { + var sources = Array.prototype.slice.call(arguments, 1); + while (sources.length) { + var source = sources.shift(); + if (!source) { continue } + + if (typeof(source) !== 'object') { + throw new TypeError(source + 'must be non-object'); + } + + for (var p in source) { + if (source.hasOwnProperty(p)) { + obj[p] = source[p]; + } + } + } + + return obj; +}; + + +exports.arraySet = function(dest, src, src_offs, len, dest_offs) { for(var i=0; i