Upgrade to Pro — share decks privately, control downloads, hide ads and more …

seamless-immutableのすすめ / Introduction of seamless-immutable

5f533aeab28ed4f70c26e336e71296f7?s=47 tipo159
October 27, 2017

seamless-immutableのすすめ / Introduction of seamless-immutable

Immutable.js, Moriとの比較
seamless-immutableをすすめる理由
seamless-immutableの概要
ベンチマーク(JavaScript, Immutable.js, Mori, seamless-Immutable)

5f533aeab28ed4f70c26e336e71296f7?s=128

tipo159

October 27, 2017
Tweet

More Decks by tipo159

Other Decks in Programming

Transcript

  1. seamlesss-immutabeͷ͢͢Ί Meguro.es #12 2017.10.27 tipo159

  2. Immutable DataϥΠϒϥϦͷछྨ 2 छྨ ໊শ ֓ཁ (JU)VCελʔ਺ ઐ༻σʔλܕ *NNVUBCMFKT -JTU

    4UBDL .BQ 0SEFSFE.BQ  4FU 0SEFSFE4FU 3FDPSEΛఏڙ   .PSJ MJTU WFDUPS IBTI.BQ TFU  TPSUFE4FU SBOHF RVFVFΛఏڙ   طଘσʔλܕ ֦ு TFBNMFTT JNNVUBCMF "SSBZͱ0CKFDUͱޙํޓ׵ੑͷ͋ Δ*NNVUBCMF%BUBΛఏڙ  
  3. seamless-immutableΛ͢͢ΊΔཧ༝ • ίʔυΛେ͖͘มߋͤͣʹImmutable DataΛಋೖՄೳ • Immutable DataΛࢀর͢Δίʔυ͸มߋෆཁ • ྫ͑͹ɼReactΛ࢖ͬͨϓϩδΣΫτʹImmutable.jsΛ్த ͔Βಋೖ͢Δ͜ͱ͸ࠔ೉ʢImmutable.jsͷσʔλܕΛੜ͔͢

    Α͏σʔλߏ଄Λઃܭ͠௚͢ඞཁ͕͋Δʣ • ͜ͷΑ͏ͳέʔεͰ͸ɼߏ଄ͷڞ༗ʹΑΔޮ཰Խ͸Ͱ͖ͳ ͍͕ɼϏϡʔߋ৽ཁ൱൑அͷޮ཰Խ͕Ͱ͖Δseamless- immutableΛ࢖ͬͯΈͯ͸! 3
  4. seamless-immutableͷྫ Immutable([3, 1, 4]).sort() // ImmutableError sort()͕immutableͳϝιουͰ͸ͳ͍ͨΊ Immutable([1, 2, 3]).concat([10,

    9 , 8]).sort() // ImmutableError concat()͕immutableͳϝιουͰ͸ͳ͍ͨΊ [1, 2, 3].concat(Immutable([6, 5, 4])).sort() // [1, 2, 3, 4, 5, 6] // concat()͕mutableͳArrayΛฦͨ͢Ί var obj = Immutable({all: “your base”, are: {belong: “to them”}}); Immutable.merge(obj, {are: {belong: “to us”}}) // Immutable({all: “your base”, are: {belong: “to us”}}) 4
  5. Immutable.from • JavaScriptͷσʔλΛImmutableʹม׵ Immutable.from([1, 2, 3]); ͸ҎԼͱಉ͡ Immutable([1, 2, 3]);

    5
  6. Immutable Array • ҎԼͷϝιουΛ௥Ճ • flatMap • asObject • asMutable

    • isImmutable 6
  7. Immutable Object • ҎԼͷϝιουΛ௥Ճ • merge • replace • set

    • setIn • getIn • update • updateIn • without • asMutable 7
  8. ϕϯνϚʔΫ݁Ռ঺հ • https://github.com/MrCheater/immutable- benchmarks merge • githubʹొ࿥͞ΕͨίʔυͰ͸ɼseamless-immutable ͕6.1.0͕ͩͬͨɼ7.1.2ʹߋ৽࣮ͯ͠ࢪ 8

  9. ϕϯνϚʔΫ݁Ռ(Array get) 9 ࣮ߦ࣌ؒ NT     

    ܁Γฦ͠ճ਺         +4 *NNVUBCMFKT .PSJ TFBNMFTTJNNVUBCMF
  10. ϕϯνϚʔΫ݁Ռ(Object get) 10 ࣮ߦ࣌ؒ NT     

    ܁Γฦ͠ճ਺         +4 *NNVUBCMFKT .PSJ TFBNMFTTJNNVUBCMF
  11. ϕϯνϚʔΫ݁Ռ(Array set) 11 ࣮ߦ࣌ؒ NT     

    ܁Γฦ͠ճ਺         +4 *NNVUBCMFKT .PSJ TFBNMFTTJNNVUBCMF
  12. ϕϯνϚʔΫ݁Ռ(Object set) 12 ࣮ߦ࣌ؒ NT     

    ܁Γฦ͠ճ਺         +4 *NNVUBCMFKT .PSJ TFBNMFTTJNNVUBCMF