Skip to content

Commit

Permalink
Merge branch 'release/0.8.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Myers committed Dec 15, 2014
2 parents ca15fe4 + 34dba02 commit 9cf7247
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "monet",
"version": "0.8.3",
"version": "0.8.4",
"main": ["src/main/javascript/monet.js","src/main/javascript/monet-pimp.js"],
"ignore": [
"**/.*",
Expand Down
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "monet",
"version": "0.8.3",
"version": "0.8.4",
"scripts": [
"src/main/javascript/monet.js",
"src/main/javascript/monet-pimp.js"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "Chris Myers",
"name": "monet",
"description": "Monadic types library for JavaScript",
"version": "0.8.3",
"version": "0.8.4",
"homepage": "https://github.com/cwmyers/monet.js",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion src/main/javascript/monet-pimp.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// monet-pimp.js 0.8.3
// monet-pimp.js 0.8.4

// This file needs to be included after monet.js

Expand Down
5 changes: 4 additions & 1 deletion src/main/javascript/monet.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Monet.js 0.8.3
// Monet.js 0.8.4

// (c) 2012-2014 Chris Myers
// Monet.js may be freely distributed under the MIT license.
Expand Down Expand Up @@ -354,6 +354,9 @@
foldLeft: function (initialValue) {
return this.toList().foldLeft(initialValue)
},
foldRight: function (initialValue) {
return this.toList().foldRight(initialValue)
},
filter: function (fn) {
return listFilter(this.toList(), fn)
},
Expand Down
12 changes: 12 additions & 0 deletions src/test/javascript/list_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ describe("An immutable list", function () {
})).toEqual(10)
})

it("can be reversed using foldLeft and cons", function () {
expect(list.foldLeft(Nil)(function (acc, e) {
return acc.cons(e)
}).toArray()).toEqual([4,3,2,1])
})

it("can not be reversed using foldRight and cons", function () {
expect(list.foldRight(Nil)(function (e, acc) {
return acc.cons(e)
}).toArray()).toEqual([1,2,3,4])
})

it("will have cons available on objects", function () {
expect("fun".cons(list).toArray()).toEqual(["fun", 1, 2, 3, 4])
})
Expand Down
12 changes: 12 additions & 0 deletions src/test/javascript/nel_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,17 @@ describe("A Non-Empty immutable list", function () {

})

it("can be reversed using foldLeft and cons", function () {
expect(nonEmptyList.foldLeft(Nil)(function (acc, e) {
return acc.cons(e)
}).toArray()).toEqual([4,3,2,1])
})

it("can not be reversed using foldRight and cons", function () {
expect(nonEmptyList.foldRight(Nil)(function (e, acc) {
return acc.cons(e)
}).toArray()).toEqual([1,2,3,4])
})

})

0 comments on commit 9cf7247

Please sign in to comment.