velitsunt
Version:
Well known symbols used to detail how to operate on different objects
28 lines (21 loc) • 955 B
Markdown
{function(Object, ArrayLike)} can-symbol/symbols/apply can.apply
can-symbol/symbols/call
How to apply a List-like as the arguments to a call of the function.
`@.apply( obj, args )`
The `can.apply` symbol points to a Function or callable object's apply function, which converts an ArrayLike of arguments into the positional parameters and calls the function with them.
{Function} a function or callable
{Object} obj the object to call the function on as the bound element
{ArrayLike} args The list of arguments to pass to the function
```
function func(c) {
return c.process();
};
// Handle non-native lists or even non-list-likes being passed in
obj[canSymbol.for('can.apply')] = function(ctx, list) {
list = list.serialize ? list.serialize() : list;
if(!list[canSymbol.for('can.isListLike')]) {
list = [list];
}
return Function.prototype.apply.call(this, ctx, list);
};
```