Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
roobie committed Jul 12, 2016
1 parent 773603e commit 24ac74d
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 21 deletions.
23 changes: 2 additions & 21 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,2 @@
The MIT License (MIT)

Copyright (c) 2016 Björn Roberg

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Eclipse Public License 1.0
https://spdx.org/licenses/EPL-1.0.html
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# mori-fluent

mixins for the prototype

#### example

```js
const mori = require('./mori-fluent')(require('mori'));

const vec = mori.vector;

const v1 = vec(1, 2);
const v2 = v1.assoc(0, 10);

console.log(v2.equals(vec(10 ,2)));
```
30 changes: 30 additions & 0 deletions mori-fluent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
Mixes in mori-ext into the prototypes of all of the collections
that mori exposes.
This is kind of bad, since it goes against one of the fundamental
dogmas in mori, but it makes for a different coding style, which
may appeal to some.
*/
const ext = require('mori-ext');


module.exports = function (mori) {
const protos = [
mori.list(),
mori.vector(),
mori.hashMap(),
mori.set(),
mori.sortedSet(),
mori.range(),
mori.queue()
].map(coll => coll.constructor.prototype);

protos.forEach(proto => {
Object.keys(ext).forEach(k => {
proto[k] = ext[k];
});
});

return mori;
};
29 changes: 29 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "mori-fluent",
"version": "0.0.1",
"description": " like mori-ext, but mixes in the functions from mori-ext into the prototypes of mori's collections",
"main": "mori-fluent.js",
"scripts": {
"test": "babel-tap spec.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/roobie/mori-fluent.git"
},
"keywords": [
"fluent",
"mori"
],
"author": "[email protected]",
"license": "EPL-1.0",
"bugs": {
"url": "https://github.com/roobie/mori-fluent/issues"
},
"homepage": "https://github.com/roobie/mori-fluent#readme",
"dependencies": {
"mori-ext": "https://github.com/roobie/mori-ext/archive/v0.3.0.tar.gz"
},
"devDependencies": {
"babel-tap": "^5.0.0"
}
}
12 changes: 12 additions & 0 deletions spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

const tap = require('tap');
const test = tap.test;

const mori = require('./mori-fluent')(require('mori'));

test('vector prototype should have assoc and equals', t => {
t.plan(1);

const vec = mori.vector;
t.ok(vec(1, 2).assoc(0, 10).equals(vec(10, 2)));
});

0 comments on commit 24ac74d

Please sign in to comment.