Skip to content

Commit

Permalink
convert _.extend to PHET_CORE/merge, phetsims/phet-core#71
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Oct 17, 2019
1 parent 814784a commit dede4ef
Show file tree
Hide file tree
Showing 22 changed files with 50 additions and 28 deletions.
3 changes: 2 additions & 1 deletion js/common/model/Reaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ define( require => {
// modules
const DevStringUtils = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/dev/DevStringUtils' );
const inherit = require( 'PHET_CORE/inherit' );
const merge = require( 'PHET_CORE/merge' );
const reactantsProductsAndLeftovers = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/reactantsProductsAndLeftovers' );
const Substance = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/common/model/Substance' );

Expand All @@ -27,7 +28,7 @@ define( require => {
assert && assert( reactants.length > 1, 'a reaction requires at least 2 reactants' );
assert && assert( products.length > 0, 'a reaction requires at least 1 product' );

options = _.extend( {
options = merge( {
name: null // {string|null} optional name, suitable for display to the user
}, options );

Expand Down
7 changes: 4 additions & 3 deletions js/common/view/BeforeAfterNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ define( require => {
const Dimension2 = require( 'DOT/Dimension2' );
const inherit = require( 'PHET_CORE/inherit' );
const LayoutBox = require( 'SCENERY/nodes/LayoutBox' );
const merge = require( 'PHET_CORE/merge' );
const Node = require( 'SCENERY/nodes/Node' );
const QuantitiesNode = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/common/view/QuantitiesNode' );
const reactantsProductsAndLeftovers = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/reactantsProductsAndLeftovers' );
Expand All @@ -43,7 +44,7 @@ define( require => {
*/
function BeforeAfterNode( reaction, beforeExpandedProperty, afterExpandedProperty, options ) {

options = _.extend( {
options = merge( {
contentSize: new Dimension2( 100, 100 ), // {Dimension2} size of the 'Before' and 'After' boxes
quantityRange: RPALConstants.QUANTITY_RANGE, // {Range} range of the quantity values
showSymbols: true, // {boolean} whether to show symbols (eg, H2O) for the substances in the reactions
Expand All @@ -65,14 +66,14 @@ define( require => {
const afterXOffsets = QuantitiesNode.createXOffsets( products.length + leftovers.length, options.contentSize.width );

// @private 'Before Reaction' box, with stacks of reactants
this.beforeBox = new StacksAccordionBox( reactants, beforeXOffsets, _.extend( {
this.beforeBox = new StacksAccordionBox( reactants, beforeXOffsets, merge( {
expandedProperty: beforeExpandedProperty,
titleNode: new Text( options.beforeTitle, TITLE_OPTIONS ),
maxQuantity: options.quantityRange.max
}, options ) );

// @private 'After Reaction' box, with stacks of products and leftovers
this.afterBox = new StacksAccordionBox( products.concat( leftovers ), afterXOffsets, _.extend( {
this.afterBox = new StacksAccordionBox( products.concat( leftovers ), afterXOffsets, merge( {
expandedProperty: afterExpandedProperty,
titleNode: new Text( options.afterTitle, TITLE_OPTIONS ),
maxQuantity: options.quantityRange.max
Expand Down
3 changes: 2 additions & 1 deletion js/common/view/HideBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ define( require => {
const Dimension2 = require( 'DOT/Dimension2' );
const FontAwesomeNode = require( 'SUN/FontAwesomeNode' );
const inherit = require( 'PHET_CORE/inherit' );
const merge = require( 'PHET_CORE/merge' );
const Node = require( 'SCENERY/nodes/Node' );
const reactantsProductsAndLeftovers = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/reactantsProductsAndLeftovers' );
const Rectangle = require( 'SCENERY/nodes/Rectangle' );
Expand All @@ -23,7 +24,7 @@ define( require => {
*/
function HideBox( options ) {

options = _.extend( {
options = merge( {
boxSize: new Dimension2( 100, 100 ),
iconHeight: 35,
cornerRadius: 0
Expand Down
3 changes: 2 additions & 1 deletion js/common/view/MoleculesEquationNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ define( require => {

// modules
const inherit = require( 'PHET_CORE/inherit' );
const merge = require( 'PHET_CORE/merge' );
const Node = require( 'SCENERY/nodes/Node' );
const PlusNode = require( 'SCENERY_PHET/PlusNode' );
const reactantsProductsAndLeftovers = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/reactantsProductsAndLeftovers' );
Expand All @@ -25,7 +26,7 @@ define( require => {
*/
function MoleculesEquationNode( reaction, options ) {

options = _.extend( {
options = merge( {
fill: 'white',
font: new RPALFont( 28 ),
coefficientXSpacing: 8, // space between coefficient and node to its right
Expand Down
3 changes: 2 additions & 1 deletion js/common/view/NumberNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ define( require => {

// modules
const inherit = require( 'PHET_CORE/inherit' );
const merge = require( 'PHET_CORE/merge' );
const reactantsProductsAndLeftovers = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/reactantsProductsAndLeftovers' );
const Text = require( 'SCENERY/nodes/Text' );
const Util = require( 'DOT/Util' );
Expand All @@ -21,7 +22,7 @@ define( require => {
*/
function NumberNode( numberProperty, options ) {

options = _.extend( {
options = merge( {
decimalPlaces: 0 // number of decimal places to be displayed
}, options );

Expand Down
9 changes: 5 additions & 4 deletions js/common/view/QuantitiesNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ define( require => {
const Dimension2 = require( 'DOT/Dimension2' );
const HideBox = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/common/view/HideBox' );
const inherit = require( 'PHET_CORE/inherit' );
const merge = require( 'PHET_CORE/merge' );
const Node = require( 'SCENERY/nodes/Node' );
const NumberNode = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/common/view/NumberNode' );
const NumberSpinner = require( 'SUN/NumberSpinner' );
Expand Down Expand Up @@ -66,7 +67,7 @@ define( require => {
assert && assert( reactants.length === beforeXOffsets.length );
assert && assert( products.length + leftovers.length === afterXOffsets.length );

options = _.extend( {
options = merge( {
interactiveBox: BoxType.BEFORE, // {BoxType} interactiveBox which box is interactive
boxWidth: 100, // {number} width of the Before and After boxes
afterBoxXOffset: 200, // {number} x-offset of left of After box, relative to left of Before box
Expand Down Expand Up @@ -112,7 +113,7 @@ define( require => {
if ( this.interactiveBox === BoxType.BEFORE ) {
// spinner
spinnerNode = new NumberSpinner( reactant.quantityProperty, new Property( options.quantityRange ),
_.extend( {}, SPINNER_OPTIONS, { centerX: centerX } ) );
merge( {}, SPINNER_OPTIONS, { centerX: centerX } ) );
this.reactantsParent.addChild( spinnerNode );
this.spinnerNodes.push( spinnerNode );
}
Expand Down Expand Up @@ -147,7 +148,7 @@ define( require => {
if ( this.interactiveBox === BoxType.AFTER ) {
// spinner
spinnerNode = new NumberSpinner( product.quantityProperty, new Property( options.quantityRange ),
_.extend( {}, SPINNER_OPTIONS, { centerX: centerX } ) );
merge( {}, SPINNER_OPTIONS, { centerX: centerX } ) );
this.productsParent.addChild( spinnerNode );
this.spinnerNodes.push( spinnerNode );
}
Expand Down Expand Up @@ -182,7 +183,7 @@ define( require => {
if ( this.interactiveBox === BoxType.AFTER ) {
// spinner
spinnerNode = new NumberSpinner( leftover.quantityProperty, new Property( options.quantityRange ),
_.extend( {}, SPINNER_OPTIONS, { centerX: centerX } ) );
merge( {}, SPINNER_OPTIONS, { centerX: centerX } ) );
this.leftoversParent.addChild( spinnerNode );
this.spinnerNodes.push( spinnerNode );
}
Expand Down
3 changes: 2 additions & 1 deletion js/common/view/RPALFont.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ define( require => {

// modules
const inherit = require( 'PHET_CORE/inherit' );
const merge = require( 'PHET_CORE/merge' );
const PhetFont = require( 'SCENERY_PHET/PhetFont' );
const reactantsProductsAndLeftovers = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/reactantsProductsAndLeftovers' );

Expand All @@ -26,7 +27,7 @@ define( require => {
}

// font attributes, as specified in the design document
options = _.extend( {
options = merge( {
family: 'Arial'
}, options );

Expand Down
3 changes: 2 additions & 1 deletion js/common/view/ReactionBarNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ define( require => {

// modules
const inherit = require( 'PHET_CORE/inherit' );
const merge = require( 'PHET_CORE/merge' );
const Node = require( 'SCENERY/nodes/Node' );
const reactantsProductsAndLeftovers = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/reactantsProductsAndLeftovers' );
const ReactionRadioButtons = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/common/view/ReactionRadioButtons' );
Expand All @@ -27,7 +28,7 @@ define( require => {
*/
function ReactionBarNode( reactionProperty, reactions, createEquationNode, options ) {

options = _.extend( {
options = merge( {
screenWidth: 1000, // width of the screen's safe area
xMargin: 20,
yMargin: 10,
Expand Down
3 changes: 2 additions & 1 deletion js/common/view/ReactionRadioButtons.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ define( require => {
const AquaRadioButton = require( 'SUN/AquaRadioButton' );
const inherit = require( 'PHET_CORE/inherit' );
const LayoutBox = require( 'SCENERY/nodes/LayoutBox' );
const merge = require( 'PHET_CORE/merge' );
const reactantsProductsAndLeftovers = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/reactantsProductsAndLeftovers' );
const RPALFont = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/common/view/RPALFont' );
const Text = require( 'SCENERY/nodes/Text' );
Expand All @@ -28,7 +29,7 @@ define( require => {
*/
function ReactionRadioButtons( reactionProperty, choices, options ) {

options = _.extend( {
options = merge( {
spacing: 10,
orientation: 'vertical',
align: 'left'
Expand Down
3 changes: 2 additions & 1 deletion js/common/view/RightArrowNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ define( require => {
// modules
const ArrowNode = require( 'SCENERY_PHET/ArrowNode' );
const inherit = require( 'PHET_CORE/inherit' );
const merge = require( 'PHET_CORE/merge' );
const reactantsProductsAndLeftovers = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/reactantsProductsAndLeftovers' );

/**
Expand All @@ -19,7 +20,7 @@ define( require => {
*/
function RightArrowNode( options ) {

options = _.extend( {
options = merge( {
length: 70,
tailWidth: 15,
headWidth: 35,
Expand Down
3 changes: 2 additions & 1 deletion js/common/view/StacksAccordionBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ define( require => {
const AccordionBox = require( 'SUN/AccordionBox' );
const Dimension2 = require( 'DOT/Dimension2' );
const inherit = require( 'PHET_CORE/inherit' );
const merge = require( 'PHET_CORE/merge' );
const Node = require( 'SCENERY/nodes/Node' );
const reactantsProductsAndLeftovers = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/reactantsProductsAndLeftovers' );
const Rectangle = require( 'SCENERY/nodes/Rectangle' );
Expand All @@ -31,7 +32,7 @@ define( require => {

assert && assert( substances.length === xOffsets.length );

options = _.extend( {
options = merge( {

// AccordionBox options
fill: RPALColors.BOX_FILL,
Expand Down
3 changes: 2 additions & 1 deletion js/dev/DevGameControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ define( require => {
// modules
const inherit = require( 'PHET_CORE/inherit' );
const LayoutBox = require( 'SCENERY/nodes/LayoutBox' );
const merge = require( 'PHET_CORE/merge' );
const reactantsProductsAndLeftovers = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/reactantsProductsAndLeftovers' );
const RPALFont = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/common/view/RPALFont' );
const TextPushButton = require( 'SUN/buttons/TextPushButton' );
Expand All @@ -29,7 +30,7 @@ define( require => {
*/
function DevGameControls( model, options ) {

options = _.extend( {
options = merge( {
orientation: 'horizontal',
spacing: 5
}, options );
Expand Down
3 changes: 2 additions & 1 deletion js/game/model/Challenge.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ define( require => {
// modules
const GameGuess = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/game/model/GameGuess' );
const inherit = require( 'PHET_CORE/inherit' );
const merge = require( 'PHET_CORE/merge' );
const reactantsProductsAndLeftovers = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/reactantsProductsAndLeftovers' );

/**
Expand All @@ -23,7 +24,7 @@ define( require => {
*/
function Challenge( reaction, interactiveBox, options ) {

options = _.extend( {
options = merge( {
moleculesVisible: true, // {boolean} are molecules visible when playing the challenge?
numbersVisible: true // {boolean} are numbers visible when playing the challenge?
}, options );
Expand Down
5 changes: 3 additions & 2 deletions js/game/model/GameModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ define( require => {
const GamePhase = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/game/model/GamePhase' );
const GameTimer = require( 'VEGAS/GameTimer' );
const inherit = require( 'PHET_CORE/inherit' );
const PlayState = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/game/model/PlayState' );
const merge = require( 'PHET_CORE/merge' );
const NumberProperty = require( 'AXON/NumberProperty' );
const PlayState = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/game/model/PlayState' );
const Property = require( 'AXON/Property' );
const reactantsProductsAndLeftovers = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/reactantsProductsAndLeftovers' );
const RPALConstants = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/common/RPALConstants' );
Expand All @@ -31,7 +32,7 @@ define( require => {
*/
function GameModel( options ) {

options = _.extend( {
options = merge( {
level: 0, // the current level in the game, numbered starting with zero
numberOfLevels: 3, // number of levels in the game
maxQuantity: RPALConstants.QUANTITY_RANGE.max // maximum quantity of any substance in a reaction
Expand Down
3 changes: 2 additions & 1 deletion js/game/view/ChallengeNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ define( require => {
const GameButtons = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/game/view/GameButtons' );
const HideBox = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/common/view/HideBox' );
const inherit = require( 'PHET_CORE/inherit' );
const merge = require( 'PHET_CORE/merge' );
const MoleculesEquationNode = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/common/view/MoleculesEquationNode' );
const Node = require( 'SCENERY/nodes/Node' );
const PlayState = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/game/model/PlayState' );
Expand Down Expand Up @@ -45,7 +46,7 @@ define( require => {
*/
function ChallengeNode( model, challenge, challengeBounds, audioPlayer, options ) {

options = _.extend( {
options = merge( {
boxSize: RPALConstants.GAME_BEFORE_AFTER_BOX_SIZE, // {Dimension2} size of the 'Before' and 'After' boxes
quantityRange: RPALConstants.QUANTITY_RANGE, // {Range} range of the quantity values
minIconSize: new Dimension2( 0, 0 ) // {Dimension2} minimum amount of layout space reserved for Substance icons
Expand Down
3 changes: 2 additions & 1 deletion js/game/view/RandomBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ define( require => {
// modules
const Dimension2 = require( 'DOT/Dimension2' );
const inherit = require( 'PHET_CORE/inherit' );
const merge = require( 'PHET_CORE/merge' );
const Node = require( 'SCENERY/nodes/Node' );
const reactantsProductsAndLeftovers = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/reactantsProductsAndLeftovers' );
const Rectangle = require( 'SCENERY/nodes/Rectangle' );
Expand All @@ -31,7 +32,7 @@ define( require => {
*/
function RandomBox( substances, options ) {

options = _.extend( {
options = merge( {
boxSize: new Dimension2( 100, 100 ),
maxQuantity: 4, // the maximum quantity of each substance in the box
cornerRadius: 3,
Expand Down
3 changes: 2 additions & 1 deletion js/game/view/VisibilityRadioButtons.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ define( require => {
const H2ONode = require( 'NITROGLYCERIN/nodes/H2ONode' );
const inherit = require( 'PHET_CORE/inherit' );
const LayoutBox = require( 'SCENERY/nodes/LayoutBox' );
const merge = require( 'PHET_CORE/merge' );
const Node = require( 'SCENERY/nodes/Node' );
const Panel = require( 'SUN/Panel' );
const reactantsProductsAndLeftovers = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/reactantsProductsAndLeftovers' );
Expand Down Expand Up @@ -43,7 +44,7 @@ define( require => {
*/
function VisibilityRadioButtons( moleculesVisibleProperty, numbersVisibleProperty, options ) {

options = _.extend( {
options = merge( {
xMargin: 15,
yMargin: 10,
fill: 'rgb( 235, 245, 255 )',
Expand Down
3 changes: 2 additions & 1 deletion js/molecules/MoleculesScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ define( require => {
// modules
const H2ONode = require( 'NITROGLYCERIN/nodes/H2ONode' );
const inherit = require( 'PHET_CORE/inherit' );
const merge = require( 'PHET_CORE/merge' );
const MoleculesModel = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/molecules/model/MoleculesModel' );
const MoleculesScreenView = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/molecules/view/MoleculesScreenView' );
const Node = require( 'SCENERY/nodes/Node' );
Expand Down Expand Up @@ -55,7 +56,7 @@ define( require => {
*/
var createIcon = function( options ) {

options = _.extend( {
options = merge( {
moleculeLineWidth: 1 // lineWidth used to stroke the molecule icon
}, options );

Expand Down
3 changes: 2 additions & 1 deletion js/molecules/view/MoleculesScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ define( require => {
const BeforeAfterNode = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/common/view/BeforeAfterNode' );
const Dimension2 = require( 'DOT/Dimension2' );
const inherit = require( 'PHET_CORE/inherit' );
const merge = require( 'PHET_CORE/merge' );
const MoleculesEquationNode = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/common/view/MoleculesEquationNode' );
const reactantsProductsAndLeftovers = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/reactantsProductsAndLeftovers' );
const RPALConstants = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/common/RPALConstants' );
Expand Down Expand Up @@ -42,7 +43,7 @@ define( require => {
*/
function( reaction, beforeExpandedProperty, afterExpandedProperty, options ) {
return new BeforeAfterNode( reaction, beforeExpandedProperty, afterExpandedProperty,
_.extend( {}, options, {
merge( {}, options, {
contentSize: RPALConstants.MOLECULES_BEFORE_AFTER_BOX_SIZE,
minIconSize: new Dimension2( 30, 25 ) // eyeballed
} ) );
Expand Down
3 changes: 2 additions & 1 deletion js/sandwiches/model/SandwichRecipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ define( require => {

// modules
const inherit = require( 'PHET_CORE/inherit' );
const merge = require( 'PHET_CORE/merge' );
const reactantsProductsAndLeftovers = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/reactantsProductsAndLeftovers' );
const Reaction = require( 'REACTANTS_PRODUCTS_AND_LEFTOVERS/common/model/Reaction' );
const Rectangle = require( 'SCENERY/nodes/Rectangle' );
Expand All @@ -39,7 +40,7 @@ define( require => {

assert && assert( breadCount >= 0 && meatCount >= 0 && cheeseCount >= 0 );

options = _.extend( {
options = merge( {
coefficientsMutable: false // {boolean} can coefficients of the ingredients can be changed?
}, options );

Expand Down
Loading

0 comments on commit dede4ef

Please sign in to comment.