function createPropertyMap(node, defaultKey) {

	let result;

	if ( node != null ) {

		// if, instead of an object literal only a literal is given and there is a defaultKey, then wrap the literal in a map
		if ( node.type === Syntax.Literal && defaultKey != null ) {
			result = {};
			result[defaultKey] = { type: Syntax.Property, value: node };
			return result;
		}

		if ( node.type != Syntax.ObjectExpression ) {
			// something went wrong, it's not an object literal
			warning(`not an object literal: ${node.type}: ${node.value}`);
			// console.log(node.toSource());
			return undefined;
		}

		// invariant: node.type == Syntax.ObjectExpression
		result = {};
		for (let i = 0; i < node.properties.length; i++) {
			const prop = node.properties[i];
			//console.log("objectproperty " + prop.type);
			const name = getPropertyKey(prop);
			//console.log("objectproperty " + prop.type + ":" + name);
			result[name] = prop;
		}
	}
	return result;
}
/**
 * Creates a map of property values from an AST 'object literal' node.
 *
 * The values in the map are again AST 'property' nodes (representing key/value pairs).
 * It would be more convenient to just return the values, but the property node is needed
 * to find the corresponding (preceding) documentation comment.
 *
 * If a <code>defaultKey</code> is given and if the <code>node</code> is not an object literal
 * but another simple type literal, the value is treated as a shortcut for
 * <pre>
 *   {
 *     [defaultKey]: node.value
 *   }
 * </pre>
 * This is used in ManagedObjectMetadata to allow a simpler declaration of properties by
 * specifying a type name only.
 *
 * @param {ASTNode} node AST node for an object literal or simple literal
 * @param {string} [defaultKey=undefined] A default key to use for simple values
 * @returns {Map<string,Property>} Map of AST nodes of type 'Property', keyed by their property name
 */
Creates a map of property values from an AST 'object literal' node.
The values in the map are again AST 'property' nodes (representing key/value pairs).
It would be more convenient to just return the values, but the property node is needed
to find the corresponding (preceding) documentation comment.

If a defaultKey is given and if the node is not an object literal
but another simple type literal, the value is treated as a shortcut for

{
[defaultKey]: node.value
}

This is used in ManagedObjectMetadata to allow a simpler declaration of properties by
specifying a type name only.

@param {ASTNode} node AST node for an object literal or simple literal
@param {string} [defaultKey=undefined] A default key to use for simple values
@returns {Map} Map of AST nodes of type 'Property', keyed by their property name
Creates a map of property values from an AST ' object literal ' node . The values in the map are again AST ' property ' nodes ( representing key / value pairs ) . It would be more convenient to just return the values but the property node is needed to find the corresponding ( preceding ) documentation comment . If a defaultKey is given and if the node is not an object literal but another simple type literal the value is treated as a shortcut for { [ defaultKey ] : node . value } This is used in ManagedObjectMetadata to allow a simpler declaration of properties by specifying a type name only . @param { ASTNode } node AST node for an object literal or simple literal @param { string } [ defaultKey = undefined ] A default key to use for simple values @returns { Map } Map of AST nodes of type ' Property ' keyed by their property name
function createPropertyMap(node, defaultKey) {
	let result;
	if ( node != null ) {
		if ( node.type === Syntax.Literal && defaultKey != null ) {
			result = {};
			result[defaultKey] = { type: Syntax.Property, value: node };
			return result;
		}
		if ( node.type != Syntax.ObjectExpression ) {
			warning(`not an object literal: ${node.type}: ${node.value}`);
			return undefined;
		}
		result = {};
		for (let i = 0; i < node.properties.length; i++) {
			const prop = node.properties[i];
			const name = getPropertyKey(prop);
			result[name] = prop;
		}
	}
	return result;
}
function createPropertyMap ( node , defaultKey ) { let result ; if ( node != null ) { if ( node . type === Syntax . Literal && defaultKey != null ) { result = { } ; result [ defaultKey ] = { type : Syntax . Property , value : node } ; return result ; } if ( node . type != Syntax . ObjectExpression ) { warning ( ` ${ node . type } ${ node . value } ` ) ; return undefined ; } result = { } ; for ( let i = 0 ; i < node . properties . length ; i ++ ) { const prop = node . properties [ i ] ; const name = getPropertyKey ( prop ) ; result [ name ] = prop ; } } return result ; }
Creates a map of property values from an AST 'object literal' node.
Creates a map of property values from an AST ' object literal ' node .
// if, instead of an object literal only a literal is given and there is a defaultKey, then wrap the literal in a map // something went wrong, it's not an object literal // console.log(node.toSource()); // invariant: node.type == Syntax.ObjectExpression //console.log("objectproperty " + prop.type); //console.log("objectproperty " + prop.type + ":" + name);