Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,22 @@ npm install can-derive --save
Use `require` in Node/Browserify workflows to import the `can-derive` plugin
like:

```
```js
require('can-derive');
```

Use `define`, `require`, or `import` in [StealJS](http://stealjs.com/) workflows
to import the `can-derive` plugin like:

```
```js
import 'can-derive';
```

Once you've imported `can-derive` into your project, simply use
`can.List.dFilter` to generate a derived list based on a `predicate` function.
The following example derives a list of completed items from a todo list:

```
```js
var sourceList = new can.List([
{ name: 'Hop', complete: true },
{ name: 'Skip', complete: false },
Expand All @@ -74,7 +74,7 @@ var completed = sourceList.filter(function(todo) {
Any changes to `sourceList` will automatically update the derived `completed`
list:

```
```js
completed.bind('add', function(ev, newItems) {
console.log(newItems.length, 'item(s) added');
});
Expand All @@ -89,7 +89,7 @@ If you're using the [can.Map.define
plugin](http://canjs.com/docs/can.Map.prototype.define.html), you can define a
derived list like so:

```
```js
{
define: {
todos: {
Expand All @@ -116,13 +116,13 @@ when calling `.filter()`.
Unlike `can.List` and `Array`, indexes of a `FilteredList` **cannot** be
accessed using bracket notation:

```
```js
filteredList[1]; //-> undefined
```

To access a `FilteredList`'s values, use [`.attr()`](https://github.com/canjs/can-binarytree#attr):

```
```js
filteredList.attr(); //-> ["a", "b", "c"]
filteredList.attr(0); //-> "a"
filteredList.attr(1); //-> "b"
Expand Down