YUI~oop Class
The following methods are added to the YUI instance
input\code\oop\oop.js:9
Methods
aggregate
aggregate
(
-
r
-
s
-
ov
-
wl
)
Object
Applies object properties from the supplier to the receiver. If the target has the property, and the property is an object, the target object will be augmented with the supplier's value. If the property is an array, the suppliers value will be appended to the target.
Parameters:
name | type | flag | description |
---|---|---|---|
r
| Function | the object to receive the augmentation. | |
s
| Function | the object that supplies the properties to augment. | |
ov
| Boolean | if true, properties already on the receiver will be overwritten if found on the supplier. | |
wl
| String | a whitelist. If supplied, only properties in this list will be applied to the receiver. |
Returns:
the extended object.
augment
augment
(
-
r
-
s
-
ov
-
wl
-
args
)
Object
Applies prototype properties from the supplier to the receiver. The receiver can be a constructor or an instance.
Parameters:
name | type | flag | description |
---|---|---|---|
r
| Function | the object to receive the augmentation. | |
s
| Function | the object that supplies the properties to augment. | |
ov
| Boolean | if true, properties already on the receiver will be overwritten if found on the supplier. | |
wl
| String | a whitelist. If supplied, only properties in this list will be applied to the receiver. | |
args
| Array | Any | arg or arguments to apply to the supplier constructor when initializing. |
Returns:
the augmented object.
bind
bind
(
-
f
-
c
-
args
)
Function
Returns a function that will execute the supplied function in the supplied object's context, optionally adding any additional supplied parameters to the beginning of the arguments collection the supplied to the function.
Parameters:
name | type | flag | description |
---|---|---|---|
f
| Function | String | the function to bind, or a function name to execute on the context object. | |
c
| Object | the execution context. | |
args
| Any | multiple | 0..n arguments to include before the arguments the function is executed with. |
Returns:
the wrapped function.
clone
clone
(
-
o
-
safe
-
f
-
c
-
owner
-
cloned
)
Array | Object
Deep obj/array copy. Function clones are actually wrappers around the original function. Array-like objects are treated as arrays. Primitives are returned untouched. Optionally, a function can be provided to handle other data types, filter keys, validate values, etc.
Parameters:
name | type | flag | description |
---|---|---|---|
o
| Object | what to clone. | |
safe
| Boolean | if true, objects will not have prototype items from the source. If false, they will. In this case, the original is initially protected, but the clone is not completely immune from changes to the source object prototype. Also, cloned prototype items that are deleted from the clone will result in the value of the source prototype being exposed. If operating on a non-safe clone, items should be nulled out rather than deleted. | |
f
| Function | optional function to apply to each item in a collection; it will be executed prior to applying the value to the new object. Return false to prevent the copy. | |
c
| Object | optional execution context for f. | |
owner
| Object | Owner object passed when clone is iterating an object. Used to set up context for cloned functions. | |
cloned
| Object | hash of previously cloned objects to avoid multiple clones. |
Returns:
the cloned object.
each
each
(
-
o
-
f
-
c
-
proto
)
YUI
Executes the supplied function for each item in a collection. Supports arrays, objects, and Y.NodeLists
Parameters:
name | type | flag | description |
---|---|---|---|
o
| Object | the object to iterate. | |
f
| Function | the function to execute. This function receives the value, key, and object as parameters. | |
c
| Object | the execution context for the function. | |
proto
| Boolean | if true, prototype properties are iterated on objects. |
Returns:
the YUI instance.
extend
extend
(
-
r
-
s
-
px
-
sx
)
Object
Utility to set up the prototype, constructor and superclass properties to support an inheritance strategy that can chain constructors and methods. Static members will not be inherited.
Parameters:
name | type | flag | description |
---|---|---|---|
r
| Function | the object to modify. | |
s
| Function | the object to inherit. | |
px
| Object | prototype properties to add/override. | |
sx
| Object | static properties to add/override. |
Returns:
the extended object.
rbind
rbind
(
-
f
-
c
-
args
)
Function
Returns a function that will execute the supplied function in the supplied object's context, optionally adding any additional supplied parameters to the end of the arguments the function is executed with.
Parameters:
name | type | flag | description |
---|---|---|---|
f
| Function | String | the function to bind, or a function name to execute on the context object. | |
c
| Object | the execution context. | |
args
| Any | multiple | 0..n arguments to append to the end of arguments collection supplied to the function. |
Returns:
the wrapped function.
some
some
(
-
o
-
f
-
c
-
proto
)
Boolean
Executes the supplied function for each item in a collection. The operation stops if the function returns true. Supports arrays, objects, and Y.NodeLists.
Parameters:
name | type | flag | description |
---|---|---|---|
o
| Object | the object to iterate. | |
f
| Function | the function to execute. This function receives the value, key, and object as parameters. | |
c
| Object | the execution context for the function. | |
proto
| Boolean | if true, prototype properties are iterated on objects. |
Returns:
true if the function ever returns true, false otherwise.