Comparing version 0.3.7 to 0.3.8
@@ -246,3 +246,3 @@ var UTIL = require('util'), | ||
* @param {String|Object} id Node (ID or node object). | ||
* @returns {Array} Children IDs. | ||
* @returns {String[]} Children IDs. | ||
*/ | ||
@@ -261,3 +261,3 @@ getChildren: function(id) { | ||
* @param {String|Object} id Node (ID or node object). | ||
* @returns {Array} Parent IDs. | ||
* @returns {String[]} Parent IDs. | ||
*/ | ||
@@ -264,0 +264,0 @@ getParents: function(id) { |
@@ -106,3 +106,3 @@ /** | ||
exports.idTypeIsString = function(id, err) { | ||
if (typeof id !== 'string') throwError(err? err : 'Type of id(' + id + ') is not string.'); | ||
if (typeof id !== 'string') throwError(err? err : 'Type of id(' + id + ') is ' + typeof id + ', not string.'); | ||
}; | ||
@@ -109,0 +109,0 @@ |
@@ -1,3 +0,2 @@ | ||
var UTIL = require('util'), | ||
INHERIT = require('inherit'), | ||
var INHERIT = require('inherit'), | ||
ASSERTS = require('./asserts'), | ||
@@ -47,7 +46,6 @@ U = require('./util'), | ||
init: function(targets) { | ||
var ids = this._getIDs(U.toArray(targets)); | ||
for (var id in ids) { | ||
this.link(id); | ||
this._gatherIDs(id); | ||
} | ||
Object.keys(this._getIDs(U.toArray(targets))) | ||
.forEach(function(id) { | ||
this.link(id); | ||
}, this); | ||
return this; | ||
@@ -57,16 +55,2 @@ }, | ||
/** | ||
* Gather child IDs and link them to provided parent node ID. | ||
* | ||
* @param {String} id Node ID to gather children for. | ||
*/ | ||
_gatherIDs: function(id) { | ||
var children = this.arch.children[id] || []; | ||
for (var i = 0; i < children.length; i++) { | ||
this.link(children[i], id); | ||
this._gatherIDs(children[i]); | ||
} | ||
}, | ||
/** | ||
* Convert array of IDs to object with unique IDs as keys. | ||
@@ -157,3 +141,3 @@ * | ||
* | ||
* @returns {boolean} True if operable, otherwise false. | ||
* @returns {Boolean} True if operable, otherwise false. | ||
*/ | ||
@@ -168,3 +152,3 @@ isOperable: function() { | ||
* @param {Object} excludeJobs Jobs IDs to skip. | ||
* @returns {boolean} True if operable, otherwise false. | ||
* @returns {String|undefined} Job ID or undefined. | ||
*/ | ||
@@ -244,3 +228,3 @@ getOtherJob: function(excludeJobs) { | ||
* @param {String} root Node ID to start from. | ||
* @returns {Object} Leaves IDs as keys. | ||
* @returns {String[]} Leaves IDs as keys. | ||
*/ | ||
@@ -323,3 +307,3 @@ collectLeaves: function(root) { | ||
* @param {String[]|String} children IDs of child nodes. | ||
* @param {String[]|String} parents IDs of parent nodes. | ||
* @param {String[]|String} [parents] IDs of parent nodes. | ||
* @returns {Plan} Chainable API. | ||
@@ -689,2 +673,3 @@ */ | ||
* @param {String} id Node ID to dump. | ||
* @param {Object} [done] | ||
*/ | ||
@@ -691,0 +676,0 @@ nodeToGraphviz: function(id, done) { |
@@ -1,3 +0,1 @@ | ||
var UTIL = require('util'); | ||
/** | ||
@@ -9,3 +7,5 @@ * Wrap object in array if it is not array already. | ||
*/ | ||
var toArray = exports.toArray = function(o) { return Array.isArray(o) ? o : [o] }; | ||
var toArray = exports.toArray = function(o) { | ||
return Array.isArray(o) ? o : [o]; | ||
}; | ||
@@ -142,81 +142,5 @@ /** | ||
/** | ||
* Adopted from jquery's extend method. Under the terms of MIT License. | ||
* | ||
* http://code.jquery.com/jquery-1.4.2.js | ||
* | ||
* Modified by mscdex to use Array.isArray instead of the custom isArray method | ||
*/ | ||
exports.extend = function() { | ||
// copy reference to target object | ||
var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy; | ||
// Use ported jQuery.extend() from `node.extend` module | ||
exports.extend = require('node.extend'); | ||
// Handle a deep copy situation | ||
if (typeof target === 'boolean') { | ||
deep = target; | ||
target = arguments[1] || {}; | ||
// skip the boolean and the target | ||
i = 2; | ||
} | ||
// Handle case when target is a string or something (possible in deep copy) | ||
if (typeof target !== 'object' && !typeof target === 'function') | ||
target = {}; | ||
var isPlainObject = function(obj) { | ||
// Must be an Object. | ||
// Because of IE, we also have to check the presence of the constructor property. | ||
// Make sure that DOM nodes and window objects don't pass through, as well | ||
if (!obj || toString.call(obj) !== '[object Object]' || obj.nodeType || obj.setInterval) | ||
return false; | ||
var has_own_constructor = hasOwnProperty.call(obj, 'constructor'); | ||
var has_is_property_of_method = hasOwnProperty.call(obj.constructor.prototype, 'isPrototypeOf'); | ||
// Not own constructor property must be Object | ||
if (obj.constructor && !has_own_constructor && !has_is_property_of_method) | ||
return false; | ||
// Own properties are enumerated firstly, so to speed up, | ||
// if last one is own, then all properties are own. | ||
var key, last_key; | ||
for (key in obj) | ||
last_key = key; | ||
return typeof last_key === 'undefined' || hasOwnProperty.call(obj, last_key); | ||
}; | ||
for (; i < length; i++) { | ||
// Only deal with non-null/undefined values | ||
if ((options = arguments[i]) !== null) { | ||
// Extend the base object | ||
for (name in options) { | ||
if (!options.hasOwnProperty(name)) | ||
continue; | ||
src = target[name]; | ||
copy = options[name]; | ||
// Prevent never-ending loop | ||
if (target === copy) | ||
continue; | ||
// Recurse if we're merging object literal values or arrays | ||
if (deep && copy && (isPlainObject(copy) || Array.isArray(copy))) { | ||
var clone = src && (isPlainObject(src) || Array.isArray(src)) ? src : Array.isArray(copy) ? [] : {}; | ||
// Never move original objects, clone them | ||
target[name] = extend(deep, clone, copy); | ||
// Don't bring in undefined values | ||
} else if (typeof copy !== 'undefined') | ||
target[name] = copy; | ||
} | ||
} | ||
} | ||
// Return the modified object | ||
return target; | ||
}; | ||
/** | ||
@@ -230,5 +154,6 @@ * Returns arch in the JSON form used by the arch visualization feature. | ||
exports.toJson = function(arch, nodes, children) { | ||
var nodes = nodes || arch.nodes, | ||
children = children || arch.children, | ||
nodesIds = Object.keys(nodes), | ||
nodes = nodes || arch.nodes; | ||
children = children || arch.children; | ||
var nodesIds = Object.keys(nodes), | ||
links = []; | ||
@@ -261,2 +186,2 @@ | ||
}); | ||
} | ||
}; |
{ | ||
"name": "apw", | ||
"version": "0.3.7", | ||
"version": "0.3.8", | ||
"homepage": "http://github.com/bem/apw", | ||
@@ -30,3 +30,4 @@ "author": "Sergey Kryzhanovsky <skryzhanovsky@ya.ru> (http://github.com/afelix)", | ||
"coa": "0.3.x", | ||
"inherit": "1" | ||
"inherit": "1", | ||
"node.extend": "1" | ||
}, | ||
@@ -33,0 +34,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
90681
4
2350
+ Addednode.extend@1
+ Addedhas@1.0.4(transitive)
+ Addedis@3.3.0(transitive)
+ Addednode.extend@1.1.8(transitive)