OLD | NEW |
(Empty) | |
| 1 The `boolean_selector` package defines a simple and flexible syntax for boolean |
| 2 expressions. It can be used for filtering based on user-defined expressions. For |
| 3 example, the [`test`][test] package uses boolean selectors to allow users to |
| 4 define what platforms their tests support. |
| 5 |
| 6 [test]: http://github.com/dart-lang/test |
| 7 |
| 8 The boolean selector syntax is based on a simplified version of Dart's |
| 9 expression syntax. Selectors can contain identifiers, parentheses, and boolean |
| 10 operators, including `||`, `&&`, `!`, and `? :`. Any valid Dart identifier is |
| 11 allowed, and identifiers may also contain hyphens. For example, `chrome`, |
| 12 `chrome || content-shell`, and `js || (vm && linux)` are all valid boolean |
| 13 selectors. |
| 14 |
| 15 A boolean selector is parsed from a string using |
| 16 [`new BooleanSelector.parse()`][parse], and evaluated against a set of variables |
| 17 using [`BooleanSelector.evaluate()`][evaluate]. The variables may be supplied as |
| 18 a list of strings, or as a function that takes a variable name and returns its |
| 19 value. For example: |
| 20 |
| 21 [parse]: https://www.dartdocs.org/documentation/boolean_selector/latest/boolean_
selector/BooleanSelector/BooleanSelector.parse.html |
| 22 |
| 23 [evaluate]: https://www.dartdocs.org/documentation/boolean_selector/latest/boole
an_selector/BooleanSelector/evaluate.html |
| 24 |
| 25 ```dart |
| 26 import 'package:boolean_selector/boolean_selector.dart'; |
| 27 |
| 28 void main(List<String> args) { |
| 29 var selector = new BooleanSelector.parse("(x && y) || z"); |
| 30 print(selector.evaluate((variable) => args.contains(variable))); |
| 31 } |
| 32 ``` |
| 33 |
| 34 ## Versioning |
| 35 |
| 36 If this package adds new features to the boolean selector syntax, it will |
| 37 increment its major version number. This ensures that packages that expose the |
| 38 syntax to their users will be able to update their own minor versions, so their |
| 39 users can indicate that they rely on the new syntax. |
OLD | NEW |