logical-string
v1.0.3
Published
支持 & 和 | 组合的字符串,方便以字符串的形式配置逻辑组合条件
Downloads
8
Readme
logical-string
支持 & 和 | 组合的字符串,方便以字符串的形式配置逻辑组合条件
Installation
npm i -S logical-string
Usage
import { parse } from 'logical-string'
// 指定字符串中包含元音字母就返回 true
const isContainsVowel = (str) => [ 'a', 'e', 'i', 'o', 'u' ].some(k => str.includes(k))
parse('a && (b || c)', isContainsVowel) // 等介于执行 `true && (false || false)`,所以最终返回 false
Changelog
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.