Created
August 26, 2015 04:13
-
-
Save seoh/5aff82d4d6f0603ff7d7 to your computer and use it in GitHub Desktop.
kinds of chaining-indentation
This file contains hidden or 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
/** | |
* so many type of chaining | |
*/ | |
//// about dot-indentation. | |
// type 1-1. align with dot. | |
const ret = obj.method1() | |
.method2() | |
.method3() | |
.value(); | |
// type 1-2. just indent | |
const ret = obj.method1() | |
.method2() | |
.method3() | |
.value(); | |
// type 1-3. align with subjective obj. | |
const ret = obj.method1() | |
.method2() | |
.method3() | |
.value(); | |
//// about assign indentation | |
// type 2. = isn't mine. | |
const ret = | |
obj.method1() | |
.method2() | |
.method3() | |
.value(); | |
//// about block indentation | |
// type 3-1. | |
const ret = obj.method1(arg => { | |
// do something | |
}) | |
.method2(arg => { | |
// do something | |
}) | |
.value() | |
// type 3-2. saving lines. | |
const ret = obj.method1(arg => { | |
// do something | |
}).method2(arg => { | |
// do something | |
}).value() |
haruair
commented
Aug 26, 2015
// align by semantics such as in d3.
const ret = obj.method1()
.method2()
.style1()
.style2()
.method3();
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment