How to use the can/util/can.makeArray function in can

To help you get started, we’ve selected a few can examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github canjs / canjs / util / deferred.js View on Github external
can.when = Deferred.when = function () {
	var args = can.makeArray(arguments);
	if (args.length < 2) {
		var obj = args[0];
		if (obj && (can.isFunction(obj.isResolved) && can.isFunction(obj.isRejected))) {
			return obj;
		} else {
			return Deferred()
				.resolve(obj);
		}
	} else {
		var df = Deferred(),
			done = 0,
			// Resolve params -- params of each resolve, we need to track them down
			// to be able to pass them in the correct order if the master
			// needs to be resolved.
			rp = [];
		can.each(args, function (arg, j) {
github canjs / canjs / util / yui / yui.js View on Github external
can.map = function (arr, fn) {
	return Y.Array.map(can.makeArray(arr || []), fn);
};
// Map object helpers.
github canjs / canjs / util / zepto / zepto.js View on Github external
Zepto.fn[name] = function () {
		var elems,
			args = can.makeArray(arguments);

		if (args[0] != null) {
			// documentFragment
			if (typeof args[0] === "string") {
				args[0] = $.zepto.fragment(args[0]);
			}
			if (args[0].nodeType === 11) {
				elems = can.makeArray(args[0].childNodes);
			} else if(args[0] instanceof Zepto.fn.constructor) {
				elems = can.makeArray(args[0]);
			} else {
				elems = [args[0]];
			}
		}

		var ret = original.apply(this, args);

		can.inserted(elems);

		return ret;
	};
});
github canjs / canjs / util / zepto / zepto.js View on Github external
Zepto.fn[name] = function () {
		var elems,
			args = can.makeArray(arguments);

		if (args[0] != null) {
			// documentFragment
			if (typeof args[0] === "string") {
				args[0] = $.zepto.fragment(args[0]);
			}
			if (args[0].nodeType === 11) {
				elems = can.makeArray(args[0].childNodes);
			} else if(args[0] instanceof Zepto.fn.constructor) {
				elems = can.makeArray(args[0]);
			} else {
				elems = [args[0]];
			}
		}

		var ret = original.apply(this, args);

		can.inserted(elems);

		return ret;
	};
});
github canjs / canjs / util / mootools / mootools.js View on Github external
}
			// If we are bubbling, get parent node.
			if (bubble && item.parentNode && item.parentNode.nodeType !== 11) {
				item = item.parentNode;
			} else {
				item = null;
			}
		}
	} else {
		if (typeof event === 'string') {
			event = {
				type: event
			};
		}
		event.target = event.target || item;
		can.dispatch.call(item, event, can.makeArray(args));
	}
};
can.delegate = function (selector, ev, cb) {
github canjs / canjs / util / zepto / zepto.js View on Github external
this.each(function () {
		if (this.getElementsByTagName) {
			$.cleanData([this].concat(can.makeArray(this.getElementsByTagName('*'))));
		}
	});
	return $_remove.call(this);
github canjs / canjs / util / mootools / mootools.js View on Github external
grab: function (el) {
		var elems;
		if (el && el.nodeType === 11) {
			elems = can.makeArray(el.childNodes);
		} else {
			elems = [el];
		}
		var ret = grab.apply(this, arguments);
		can.inserted(elems);
		return ret;
	},
	set: function (attrName, value) {
github canjs / canjs / util / zepto / zepto.js View on Github external
if (bubble === false) {
			$([obj])
				.triggerHandler(event, args);
		} else {
			$([obj])
				.trigger(event, args);
		}

	} else {
		if (typeof event === "string") {
			event = {
				type: event
			};
		}
		event.target = event.target || obj;
		can.dispatch.call(obj, event, can.makeArray(args));
	}

};
github canjs / canjs / util / yui / yui.js View on Github external
on: function () {
		var args = can.makeArray(arguments);
		return Y.Event._attach(args, {
			facade: false
		});
	}
};
github canjs / canjs / util / yui / yui.js View on Github external
Y.DOM.addHTML = function (node, content, where) {
		if (typeof content === "string" || typeof content === "number") {
			content = can.buildFragment(content, node.ownerDocument || node.getDOMNode().ownerDocument);
		}
		var elems;
		if (content.nodeType === 11) {
			elems = can.makeArray(content.childNodes);
		} else {
			elems = [content];
		}
		var ret = addHTML.call(this, node, content, where);

		can.inserted(elems);

		return ret;
	};