Skip to content

Commit

Permalink
util: more export tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
adammw committed Feb 14, 2014
1 parent acc006f commit fe3b313
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/util.js
Expand Up @@ -15,6 +15,9 @@ var debug = require('debug')('spotify-web:util');
* Export namespaces decorator
*
* Inspired by AngularJS DI, but is in no way compatible and does not use the same syntax
*
* @param {Object} object Object to decorate
* @param {Array|Function} namespaces Namespace objects to export
* @api private
*/
exports.export = function(object, namespaces) {
Expand All @@ -26,9 +29,13 @@ exports.export = function(object, namespaces) {
object = object[1];
}

if (!Array.isArray(namespaces))
namespaces = [namespaces];

debug('exporting %d namespaces on %s', namespaces.length, objectName);

object['$exports'] = [];
if (!Array.isArray(object['$exports']))
object['$exports'] = [];

namespaces.forEach(function(namespace){
var name = namespace.name;
Expand Down

0 comments on commit fe3b313

Please sign in to comment.