From a0e5d3f3394ad94168da268384cb11d2a974a231 Mon Sep 17 00:00:00 2001 From: gcanti Date: Wed, 21 Jun 2017 11:20:33 +0200 Subject: [PATCH] `Array.snoc` returns wrong results with nested arrays, fix #133 --- CHANGELOG.md | 5 +++++ package.json | 2 +- src/Array.ts | 2 +- test/Array.ts | 2 ++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f52fdd6c..2e24c8a21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,11 @@ **Note**: Gaps between patch versions are faulty/broken releases. **Note**: A feature tagged as Experimental is in a high state of flux, you're at risk of it changing without notice. +# 0.3.4 + +- **Bug Fix** + - `Array.snoc` returns wrong results with nested arrays, fix #133 (@gcanti) + # 0.3.3 - **New Feature** diff --git a/package.json b/package.json index 82279aa07..18fe6c4c5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fp-ts", - "version": "0.3.3", + "version": "0.3.4", "description": "Functional programming in TypeScript", "files": [ "lib" diff --git a/src/Array.ts b/src/Array.ts index 57e422429..c1ca029be 100644 --- a/src/Array.ts +++ b/src/Array.ts @@ -119,7 +119,7 @@ export function cons(a: A, as: Array): Array { } export function snoc(as: Array, a: A): Array { - return as.concat(a) + return as.concat([a]) } export function head(as: Array): Option { diff --git a/test/Array.ts b/test/Array.ts index 37aac7e81..9f6bf2085 100644 --- a/test/Array.ts +++ b/test/Array.ts @@ -41,10 +41,12 @@ describe('Array', () => { it('cons', () => { assert.deepEqual(array.cons(0, as), [0, 1, 2, 3]) + assert.deepEqual(array.cons([1], [[2]]), [[1], [2]]) }) it('snoc', () => { assert.deepEqual(array.snoc(as, 4), [1, 2, 3, 4]) + assert.deepEqual(array.snoc([[1]], [2]), [[1], [2]]) }) it('curriedSnoc', () => {