Giter VIP home page Giter VIP logo

boolean_selector's Introduction

Dart Pub Package package publisher

The boolean_selector package defines a simple and flexible syntax for boolean expressions. It can be used for filtering based on user-defined expressions. For example, the test package uses boolean selectors to allow users to define what platforms their tests support.

The boolean selector syntax is based on a simplified version of Dart's expression syntax. Selectors can contain identifiers, parentheses, and boolean operators, including ||, &&, !, and ? :. Any valid Dart identifier is allowed, and identifiers may also contain hyphens. For example, chrome, chrome || content-shell, and js || (vm && linux) are all valid boolean selectors.

A boolean selector is parsed from a string using BooleanSelector.parse(), and evaluated against a set of variables using BooleanSelector.evaluate(). The variables are supplied as a function that takes a variable name and returns its value. For example:

import 'package:boolean_selector/boolean_selector.dart';

void main(List<String> args) {
  var selector = BooleanSelector.parse("(x && y) || z");
  print(selector.evaluate((variable) => args.contains(variable)));
}

Versioning

If this package adds new features to the boolean selector syntax, it will increment its major version number. This ensures that packages that expose the syntax to their users will be able to update their own minor versions, so their users can indicate that they rely on the new syntax.

boolean_selector's People

Contributors

a-siva avatar athomas avatar bcko avatar dependabot[bot] avatar devoncarew avatar franklinyow avatar jakemac53 avatar keertip avatar kevmoo avatar mit-mit avatar natebosch avatar nex3 avatar pq avatar srawlins avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

boolean_selector's Issues

Dart 2 runtime failures in test

type '(dynamic) => dynamic' is not a subtype of type '(String) => bool' in type cast
dart:core Object._as
package:boolean_selector/src/evaluator.dart 21:25 new Evaluator
package:boolean_selector/src/impl.dart 33:52 BooleanSelectorImpl.evaluate
../../dart/boolean_selector/test/evaluate_test.dart 58:19 _eval

The library has no documentation

It would be helpful if the contents of this package's README could be duplicated as dartdocs for the library itself. That way it would appear e.g. in Flutter's docs for boolean_selector.

Support for `async` evaluations

I'd like to use this library, but in some cases, depending on the variable, I must make an asynchronous call to determine the value to return.

Would you be open to changing the typedef from:

bool Function(String variable)

to something like:

FutureOr<bool> Function(String variable)

This would enable the following contrived example usage:

selector.evaluate((variable) async {
  bool result = false;
  if (variable == 'special') {
    result = await someService.getValue();
  }
  return result;
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.