1 import { jQuery } from "../core.js";
2 import { toType } from "../core/toType.js";
4 // Multifunctional method to get and set values of a collection
5 // The value/s can optionally be executed if it's a function
6 export function access( elems, fn, key, value, chainable, emptyGet, raw ) {
12 if ( toType( key ) === "object" ) {
15 access( elems, fn, i, key[ i ], true, emptyGet, raw );
19 } else if ( value !== undefined ) {
22 if ( typeof value !== "function" ) {
28 // Bulk operations run against the entire set
30 fn.call( elems, value );
33 // ...except when executing function values
36 fn = function( elem, _key, value ) {
37 return bulk.call( jQuery( elem ), value );
43 for ( ; i < len; i++ ) {
45 elems[ i ], key, raw ?
47 value.call( elems[ i ], i, fn( elems[ i ], key ) )
59 return fn.call( elems );
62 return len ? fn( elems[ 0 ], key ) : emptyGet;