Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | 378x 4x 4x 374x 374x 374x 374x 374x 374x 374x 374x 374x 374x 378x 57x 55x 103x 62x 30x 30x 30x 27x 3x 22x 22x 6x 6x 7x 7x 21x 21x | import {logger} from './logger'
export default class Flag {
constructor(flag, delegate) {
if (typeof flag === 'string') {
this._isWild = true
this.flagName = flag
} else {
// These along with flag.flagType and flag.flagStatus
// should always be present
this.hashKey = flag.hashKey
this.flag = flag
this.codename = flag.codename
// Pass through fields
this.isPaused = flag.isPaused
this.offTreatment = flag.offTreatment
this.treatments = flag.treatments
this.treatmentsMap = flag.treatmentsMap
this.overrides = flag.overrides
this.populations = flag.populations
this.splits = flag.splits
}
this.delegate = delegate
}
isUncategorized() {
return Boolean(this._isWild) || this.flag.flagType === 'uncategorized'
}
isWild() {
return Boolean(this._isWild)
}
isArchived() {
return this.flag.flagStatus === 'archived'
}
setDelegate(delegate) {
this.delegate = delegate
}
getType() {
Iif (this._isWild) {
logger(
`Encountered uncategorized flag "${
this.flagName
}". Visit Airship web app to convert it to a real flag`
)
return 'uncategorized'
}
const flagType = this.flag.flagType
switch (flagType) {
case 'basic':
return 'basic'
case 'experiment':
return 'experiment'
case 'uncategorized':
return 'uncategorized'
default:
logger('Unexpected flag type encountered')
return null
}
}
getTreatment(obj) {
Iif (!this.delegate) {
throw 'Delegate not provided to flag'
}
return this.delegate.getTreatment(this, obj)
}
getPayload(obj) {
Iif (!this.delegate) {
throw 'Delegate not provided to flag'
}
return this.delegate.getPayload(this, obj)
}
isEligible(obj) {
Iif (!this.delegate) {
throw 'Delegate not provided to flag'
}
return this.delegate.isEligible(this, obj)
}
isEnabled(obj) {
Iif (!this.delegate) {
throw 'Delegate not provided to flag'
}
return this.delegate.isEnabled(this, obj)
}
}
|