A brief background, I use closure compiler in a project and and trying to exclude some properties of a object from being renamed. I used externs
along with type based optimization to exclude properties only from a particular object from being renamed. However, closure compiler then excludes all the properties with same name in all the objects, regardless of type annotation. Related discussions are here and here.
Hence I decide to manually convert dot notation to array notation in Javascript files just before compilation. I can still use dot notation while developing but convert before feeding to CC, like
this.myobject.test
to this.myobject['test']
this.myobject.swift.cc
to this.myobject['swift']['cc']
I am using sed
. I could do it for one dot. However, I need help with multiple dots. Can someone help me with regular expression to convert dot notations up to depth level 4 to array notation.