swannodette/mori — pull request #108 by tgriesser (2014-08-17 18:32:13+00:00)
Title: Basic protocol support for vanilla JS objects via mori.extend

Adds basic support for extending several protocols to vanilla JS objects via `mori.extend`

The protocols included thusfar: `IAssociative`, `ICloneable`, `ICollection`, `ICounted`, `IEncodeClojure`, `IEncodeJS`, `IEquiv`, `IHash`, `IKVReduce`, `ILookup`, `IMap`, `ISeq`, `ISeqable`

Real world use case: https://github.com/tgriesser/mori-cursors

Currently, adding a protocol looks something like:

```js
mori.extend("IAssociative", Cursor.prototype, {
contains_key: Cursor.prototype.contains_key,
assoc: Cursor.prototype.assoc
})
```

However I'm wondering whether it'd be more concise to assume the object provided as the second arg to `extend` implements specific protocol functions, so you could just say:

```
mori.extend("IAssociative", MapCursor.prototype, 'contains_key', 'assoc')
```

or just

```
mori.extend("IAssociative", MapCursor.prototype)
```

Also, the `IEncodeClojure` is currently pretty useless, but would become useful with the proposed change here (or similar): http://dev.clojure.org/jira/browse/CLJS-842