lib/amd/slim.js
function(args) {
			var result = { id: null, factory: null, dependencies: [] };

			switch (args.length) {
				// define(factory);
				case 1:
					result.factory = getFactory(args[0]);
					break;

				// define(id || dependencies, factory);
				case 2:
					if (this.isNamed(args)) {
						assign(result, {
							id: args[0],
							factory: getFactory(args[1])
						});
					} else {
						assign(result, {
							dependencies: args[0],
							factory: getFactory(args[1])
						});
					}
					break;

				// define(id, dependencies, factory);
				case 3:
					assign(result, {
						id: args[0],
						dependencies: args[1],
						factory: getFactory(args[2])
					});
					break;

				default:
					throw new Error("Invalid `define` function signature");
			}

			// set the `isCjsWrapper` flag
			result.isCjsWrapper =
				n.ArrayExpression.check(result.dependencies) &&
				result.dependencies.elements.length
					? this.usesCjsRequireExports(result.dependencies)
					: this.isCjsSimplifiedWrapper(result.factory);

			return result;
		}
function(args) {
			var result = { id: null, factory: null, dependencies: [] };

			switch (args.length) {
				// define(factory);
				case 1:
					result.factory = getFactory(args[0]);
					break;

				// define(id || dependencies, factory);
				case 2:
					if (this.isNamed(args)) {
						assign(result, {
							id: args[0],
							factory: getFactory(args[1])
						});
					} else {
						assign(result, {
							dependencies: args[0],
							factory: getFactory(args[1])
						});
					}
					break;

				// define(id, dependencies, factory);
				case 3:
					assign(result, {
						id: args[0],
						dependencies: args[1],
						factory: getFactory(args[2])
					});
					break;

				default:
					throw new Error("Invalid `define` function signature");
			}

			// set the `isCjsWrapper` flag
			result.isCjsWrapper =
				n.ArrayExpression.check(result.dependencies) &&
				result.dependencies.elements.length
					? this.usesCjsRequireExports(result.dependencies)
					: this.isCjsSimplifiedWrapper(result.factory);

			return result;
		}
function ( args ) { var result = { id : null , factory : null , dependencies : [ ] } ; switch ( args . length ) { // define(factory); case 1 : result . factory = getFactory ( args [ 0 ] ) ; break ; // define(id || dependencies, factory); case 2 : if ( this . isNamed ( args ) ) { assign ( result , { id : args [ 0 ] , factory : getFactory ( args [ 1 ] ) } ) ; } else { assign ( result , { dependencies : args [ 0 ] , factory : getFactory ( args [ 1 ] ) } ) ; } break ; // define(id, dependencies, factory); case 3 : assign ( result , { id : args [ 0 ] , dependencies : args [ 1 ] , factory : getFactory ( args [ 2 ] ) } ) ; break ; default : throw new Error ( "Invalid `define` function signature" ) ; } // set the `isCjsWrapper` flag result . isCjsWrapper = n . ArrayExpression . check ( result . dependencies ) && result . dependencies . elements . length ? this . usesCjsRequireExports ( result . dependencies ) : this . isCjsSimplifiedWrapper ( result . factory ) ; return result ; }
The AMD define arguments AST nodes as an object
@typedef {Object} DefineArguments
@property {?string} id - The module if of the module being defined
@property {Array.<string>} dependencies - Array of modules ids dependencies
@property {!Function} factory - Module's factory function
@property {boolean} isCjsWrapper - Whether factory function is AMD's
simplified CommonJS wrapping.
 
Returns an object with the arguments of the define function
@param {Array} args - The AST node of the `define` call arguments
@return {DefineArguments} An object with AMD's define function arguments
The AMD define arguments AST nodes as an object