Created
August 15, 2015 18:08
-
-
Save dmsnell/e2c0e437cce57c36c457 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Immutable = require( 'immutable' ); | |
var initialData, | |
updatedData, | |
partialData; | |
initialData = { | |
status: 200, | |
image: { | |
height: 64, | |
width: 64, | |
url: null | |
} | |
}; | |
updatedData = { | |
status: 200, | |
image: { | |
height: 32, | |
width: 64, | |
url: 'https://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=32' | |
} | |
}; | |
partialData = { | |
image: { | |
height: 32, | |
url: 'https://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=32', | |
comment: 'Lucky shot!' | |
} | |
} | |
var settings = Immutable.fromJS( initialData ); | |
console.log( settings ); | |
updatedSettings = settings.mergeDeep( updatedData ); | |
console.log( updatedSettings ); | |
partialSettings = updatedSettings.mergeDeep( partialData ); | |
console.log( partialSettings ); | |
console.log( updatedSettings === partialSettings ); | |
setInSettings = settings.setIn( ['status'], 500 ); | |
noSetSettings = settings.setIn( ['status'], 200 ); | |
console.log( setInSettings ); | |
console.log( setInSettings === settings ); | |
console.log( noSetSettings ); | |
console.log( noSetSettings === settings ); | |
newSettings = settings.mergeDeep( { message: 'Hello, World!' } ); | |
console.log( newSettings ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run with
node ImmutableTest.js