lib/utils/filterExpression.js
function createFilter(filterExpression) {
  if (typeof filterExpression === 'undefined') {
    throw new Error('Filter expression should be defined');
  }

  if (isSimpleType(filterExpression)) {
    return simpleTypeFilter(filterExpression);
  } else if (isCustomPredicate(filterExpression)) {
    return customPredicateFilter(filterExpression);
  } else if (isArray(filterExpression)) {
    return arrayFilter(filterExpression);
  }

  return customObjectFilter(filterExpression);
}
function createFilter(filterExpression) {
  if (typeof filterExpression === 'undefined') {
    throw new Error('Filter expression should be defined');
  }

  if (isSimpleType(filterExpression)) {
    return simpleTypeFilter(filterExpression);
  } else if (isCustomPredicate(filterExpression)) {
    return customPredicateFilter(filterExpression);
  } else if (isArray(filterExpression)) {
    return arrayFilter(filterExpression);
  }

  return customObjectFilter(filterExpression);
}
function createFilter ( filterExpression ) { if ( typeof filterExpression === 'undefined' ) { throw new Error ( 'Filter expression should be defined' ) ; } if ( isSimpleType ( filterExpression ) ) { return simpleTypeFilter ( filterExpression ) ; } else if ( isCustomPredicate ( filterExpression ) ) { return customPredicateFilter ( filterExpression ) ; } else if ( isArray ( filterExpression ) ) { return arrayFilter ( filterExpression ) ; } return customObjectFilter ( filterExpression ) ; }
This method creates custom filter predicate based on `filterExpression`
value.

When `filterExpression` is a simple type (Number, String or Boolean), then
returned predicate compares `data` property directly with that value:

```
var match42 = createFilter(42);
// this will print true:
console.log(match42({data: 42}));
```

You might be wondering why it compares against `data` property, not object
directly (`match42(42)`)? It is thank to the fact, that data for each vertex or
edge of [VivaGraph](https://github.com/anvaka/VivaGraphJS)/[ngraph](https://github.com/anvaka/ngraph.graph)
is stored within `xxx.data` property.

If you want to filter against direct object attributes, you can pass custom
`filterExpression` as a `function`:

```
var match42 = createFiliter(function (obj) {
return obj === 42;
});
// Now this will print true:
console.log(match42(42));
```

When `filterExpression` is an array, then `data` property should also be
an array (or array-like) object, with the same elements:

```
var matchArray = createFilter([40, 2]);
// prints true:
console.log(matchArray({ data: [40, 2] });
```

Finally you can pass `filterExpression` as an `object`, in which case
`data` attribute should have all properties of `filterExpression`
and they all should be equal to values of your `filterExpression`:

```
var matchJohnSmith = createFilter({
firstName: 'John',
lastName: 'Smith'
});

// true:
matchJohnSmith({
data: { firstName: 'John', lastName: 'Smith' }
});

// false (missing lastName):
matchJohnSmith({
data: { firstName: 'John' }
});
```
This method creates custom filter predicate based on filterExpression value .