Skip to content

Commit

Permalink
Linking to docs.md in README
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Albon committed Sep 22, 2014
1 parent 975b650 commit 87d61bf
Showing 1 changed file with 5 additions and 33 deletions.
38 changes: 5 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ dependencies, like so:
angular.module('your.app', ['hm.lib.predicate']);
```

API
---

[API](docs.md)

Usage
-----

Expand Down Expand Up @@ -66,39 +71,6 @@ angular.module('your.app').factory('your.app.YourService', [
]);
```

### Filtering

Assuming you're using Underscore.js or Lo-Dash in your project:

```javascript
function yourService(p) {
return {
/**
* Return all widgets where widget.status == 'CONFIRMED'
*/
getConfirmedWidgets: function (widgets) {
return _.filter(widgets, _.compose(p.equals('CONFIRMED'), _.property('status')));
},

/**
* Get all valid widgets (name is a 3+ character string, colour is either red or blue)
*/
getValidWidgets: function (widgets) {
var nameIsValid = _.compose(p.and(_.isString, p.isLongEnough(3)), _.property('name')),
colourIsValid = _.compose(p.isOneOf(['red', 'blue']), _.property('colour')),
widgetIsValid = p.and(nameIsValid, colourIsValid);

return _.filter(widgets, widgetIsValid);
},
};
}

angular.module('your.app').factory('your.app.YourService', [
'hm.lib.predicate.Predicate',
yourService
]);
```

Contributing
------------

Expand Down

0 comments on commit 87d61bf

Please sign in to comment.