A nice conditional statement
v1.0.0 이전까지는 github 패키지 사용 예정
# npm login --scope=@divlook --registry=https://npm.pkg.github.com
npm install @divlook/ifjs
# yarn npm login --scope=@divlook --registry=https://npm.pkg.github.com
yarn add @divlook/ifjs
import { Condition } from '@divlook/ifjs'
const condition = new Condition()
condition.and(() => false)
condition.or(() => false)
await condition.is.false() // true
import { Condition } from '@divlook/ifjs'
await new Condition(() => true)
.and(() => 0 === '0')
.or(() => 1 === 2)
.is.true() // false
import { Condition } from '@divlook/ifjs'
const condition = new Condition()
.and(sub => {
const subCondition = sub()
return subCondition
.and(() => false)
.or(() => false)
.is.true()
})
.or(sub => {
return sub(() => true)
.or(() => false)
.is.true()
})
condition.and(() => false)
await condition.is.false()
import { Condition } from '@divlook/ifjs'
const condition = new Condition(() => {
return new Promise((resolve) => {
setTimeout(() => {
resolve(true)
}, 2000)
})
})
await condition.is.true()