diff --git a/src/example-2-rebase.ts b/src/example-2-rebase.ts index 61c1b02..e474278 100644 --- a/src/example-2-rebase.ts +++ b/src/example-2-rebase.ts @@ -1,99 +1,31 @@ -import { featureFlag, f1, f2 } from './common' - -const context = { - featureFlag: true, - fflag: { - featureFlag: true - }, - data: { - fflag: { - featureFlag: true - } - } -} +import { f1, f2 } from './common' // If feature flag is true (f1) -if (featureFlag) { - f1() -} else { - f2() -} - +f1() // If feature flag is false (f2) -if (!featureFlag) { - f1() -} else { - f2() -} - +f2() // If conditional doesn't have a block wrapper (f1) -if (featureFlag) f1() -else { - f2() -} +f1() // If else conditional doesn't have a block wrapper (f2) -if (!featureFlag) f1() -else f2() +f2() // If there are multiple statements inside the block (f1, f2, f3) -if (featureFlag) { - f1() - f2() - f1() -} else { - f2() - f1() -} - +f1() +f2() +f1() // If there are multiple statements inside the block (inverse) (f2, f1) -if (!featureFlag) { - f1() - f2() - f1() -} else { - f2() - f1() -} - +f2() +f1() // If feature flag within context (f1) -if (context.featureFlag) { - f1() -} else { - f2() -} - +f1() // If feature flag within multiple context (f1) -if (context.fflag.featureFlag) { - f1() -} else { - f2() -} - +f1() // If feature flag within context (inverse) (f2) -if (!context.featureFlag) { - f1() -} else { - f2() -} - +f2() // If feature flag within multiple context (inverse) (f2) -if (!context.fflag.featureFlag) { - f1() -} else { - f2() -} - +f2() // If feature flag within multiple context (f1) -if (context.data.fflag.featureFlag) { - f1() -} else { - f2() -} - +f1() // If feature flag within multiple context (f2) -if (!context.data.fflag.featureFlag) { - f1() -} else { - f2() -} +f2() diff --git a/src/index.ts b/src/index.ts index 00b03e2..8b13789 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,9 +1 @@ -const context = { - featureFlag: false -} -if (context.featureFlag) { - console.log('Show the exciting new feature') -} else { - console.log('Show the old feature') -} diff --git a/src/remove-simple-if-flags.ts b/src/remove-simple-if-flags.ts index 61c1b02..e474278 100644 --- a/src/remove-simple-if-flags.ts +++ b/src/remove-simple-if-flags.ts @@ -1,99 +1,31 @@ -import { featureFlag, f1, f2 } from './common' - -const context = { - featureFlag: true, - fflag: { - featureFlag: true - }, - data: { - fflag: { - featureFlag: true - } - } -} +import { f1, f2 } from './common' // If feature flag is true (f1) -if (featureFlag) { - f1() -} else { - f2() -} - +f1() // If feature flag is false (f2) -if (!featureFlag) { - f1() -} else { - f2() -} - +f2() // If conditional doesn't have a block wrapper (f1) -if (featureFlag) f1() -else { - f2() -} +f1() // If else conditional doesn't have a block wrapper (f2) -if (!featureFlag) f1() -else f2() +f2() // If there are multiple statements inside the block (f1, f2, f3) -if (featureFlag) { - f1() - f2() - f1() -} else { - f2() - f1() -} - +f1() +f2() +f1() // If there are multiple statements inside the block (inverse) (f2, f1) -if (!featureFlag) { - f1() - f2() - f1() -} else { - f2() - f1() -} - +f2() +f1() // If feature flag within context (f1) -if (context.featureFlag) { - f1() -} else { - f2() -} - +f1() // If feature flag within multiple context (f1) -if (context.fflag.featureFlag) { - f1() -} else { - f2() -} - +f1() // If feature flag within context (inverse) (f2) -if (!context.featureFlag) { - f1() -} else { - f2() -} - +f2() // If feature flag within multiple context (inverse) (f2) -if (!context.fflag.featureFlag) { - f1() -} else { - f2() -} - +f2() // If feature flag within multiple context (f1) -if (context.data.fflag.featureFlag) { - f1() -} else { - f2() -} - +f1() // If feature flag within multiple context (f2) -if (!context.data.fflag.featureFlag) { - f1() -} else { - f2() -} +f2()