Example #1
0
	it("intersection", function() {
		var stooges = ['moe', 'curly', 'larry'],
			leaders = ['moe', 'groucho'];
		var result;
		assert.deepEqual(util.intersection(stooges, leaders), ['moe']);
		var theSixStooges = ['moe', 'moe', 'curly', 'curly', 'larry', 'larry'];
		assert.deepEqual(util.intersection(theSixStooges, leaders), ['moe']);
		result = util.intersection([2, 4, 3, 1], [1, 2, 3]);
		assert.deepEqual(result, [2, 3, 1]);
		result = util.intersection(null, [1, 2, 3]);
		assert.equal(Object.prototype.toString.call(result), '[object Array]');
		assert.equal(result.length, 0);
	});
Example #2
0
			r = depends.every(function(m) {
				var cfg = appManage.getconfig(m);
				if (cfg.root) {
					errorinfo = {
						error: "depends [" + m + "] app is rootapp!"
					};
					return false;
				}

				if (!cfg.roots || !roots) return true;

				//depends内的app的根app必须和自己的根app有交集
				if (!util.intersection(cfg.roots, roots).length) {
					errorinfo = {
						error: "depends [" + m + "] rootapp is difference!"
					};
					return false;
				};
			});