turbo-javascript
AcollectioofcommadsadES6-readysippetsforoptimizigJavascriptadTypescriptdevelopmetproductivity.
CommadsUsethefollowigkeymapstospeedupyourdevelopmet.Youcaquicklytermiatelieswithsemicolosormaipulateblocksofcodewithease.
EdLieCTRL-;Termiatesthecurretliewithasemicolo.
EdLiewithacommaCTRL-,Termiatesthecurretliewithacomma(greatforobjectliterals).
EdNewLieCTRL-ENTERTermiatesthecurretliewithacoloorsemicolo,followedwithaewlie.Acommaisisertedwhethecursorisisideaobjectliteral,otherwiseasemicoloisiserted.
EasyBlocksCTRL-BCreatesastatemetblock{...}withtheselectedtextplacedisideadproperlyideted.Iftheselectioisalreadywrappedwithablock,theblockisremovedaditscotetisuideted.
SippetsSippetsareoptimizedtobeshortadeasytoremember.Somesippetsare"chaiable"adrederdifferetlywheprecededbya".".
Forexample,.feredersachai-friedlyversioofthe"forEach"sippet,whileferedersafullcodeblock.
Declaratiosv⇥varstatemetvar${1:ame}v=⇥varassigmetvar${1:ame}=${2:value}l⇥letstatemetlet${1:ame}l=⇥letassigmetlet${1:ame}=${2:value}co⇥coststatemetcost${1:ame}co=⇥costassigmetcost${1:ame}=${2:value}FlowCotrolif⇥ifstatemetif(${1:coditio}){${0}}el⇥elsestatemetelse{${0}}ife⇥elsestatemetif(${1:coditio}){${0}}else{}ei⇥elseifstatemetelseif(${1:coditio}){${0}}fl⇥forloopfor(let${1:i}=0,${2:le}=${3:iterable}.legth;${1:i}<${2:le};${1:i}++){${0}}fi⇥foriloopfor(let${1:key}i${2:source}){if(${2:source}.hasOwProperty(${1:key})){${0}}}fo⇥forofloop(ES6)for(let${1:key}of${2:source}){${0}}wl⇥whileloopwhile(${1:coditio}){${0}}tc⇥try/catchtry{${0}}catch(${1:err}){}tf⇥try/fiallytry{${0}}fially{}tcf⇥try/catch/fiallytry{${0}}catch(${1:err}){}fially{}sw⇥switchcaseswitch(${1:expr}){case${2:value}:retur$0;default:retur;}Fuctiosf⇥aoymousfuctiofuctio(${1:argumets}){${0}}f⇥amedfuctiofuctio${1:ame}(${2:argumets}){${0}}iife⇥immediately-ivokedfuctioexpressio(IIFE)(fuctio(${1:argumets}){${0}})(${2});fa⇥fuctioapply${1:f}.apply(${2:this},${3:argumets})fc⇥fuctiocall${1:f}.call(${2:this},${3:argumets})fb⇥fuctiobid${1:f}.bid(${2:this},${3:argumets})af⇥arrowfuctio(ES6)(${1:argumets})=>${2:statemet}afb⇥arrowfuctiowithbody(ES6)(${1:argumets})=>{\t${0}}gf⇥geeratorfuctio(ES6)fuctio*(${1:argumets}){${0}}gf⇥amedgeeratorfuctio(ES6)fuctio*${1:ame}(${1:argumets}){${0}}Iterablesseq⇥sequeceof0..[...Array(${1:legth}).keys()]${0}fe⇥forEachloop(chaiable)${1:iterable}.forEach((${2:item})=>{${0}});map⇥mapfuctio(chaiable)${1:iterable}.map((${2:item})=>{${0}});reduce⇥reducefuctio(chaiable)${1:iterable}.reduce((${2:previous},${3:curret})=>{${0}}${4:,iitial});filter⇥filterfuctio(chaiable)${1:iterable}.filter((${2:item})=>{${0}});fid⇥ES6fidfuctio(chaiable)${1:iterable}.fid((${2:item})=>{${0}});Objectsadclassesc⇥class(ES6)class${1:ame}{costructor(${2:argumets}){${0}}}cex⇥childclass(ES6)class${1:ame}exteds${2:base}{costructor(${2:argumets}){super(${2:argumets});${0}}}ctorclasscostructor(ES6)costructor(${1:argumets}){super(${1:argumets});${0}}:⇥key/valuepairJavascript:
${1:key}:${2:'value'}JSON:
"${1:key}":${2:"value"}m⇥method(ES6sytax)${1:method}(${2:argumets}){${0}}get⇥getter(ES6sytax)get${1:property}(){${0}}
评论