Skip to content

Commit 05fa3cb

Browse files
committed
Merge branch 'develop' into feature/program-testing
2 parents 44b0f50 + 1432fef commit 05fa3cb

17 files changed

Lines changed: 879 additions & 119 deletions

.circleci/config.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
version: 2
2+
3+
defaults: &defaults
4+
working_directory: ~/repo
5+
docker:
6+
- image: circleci/node:erbium
7+
8+
jobs:
9+
build:
10+
<<: *defaults
11+
12+
steps:
13+
- checkout
14+
- run: ./build.sh
15+
- persist_to_workspace:
16+
root: ~/repo
17+
paths: .
18+
19+
deploy:
20+
<<: *defaults
21+
steps:
22+
- attach_workspace:
23+
at: ~/repo
24+
- run:
25+
name: Authenticate with registry
26+
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/repo/.npmrc
27+
- run: ./deploy.sh
28+
29+
workflows:
30+
version: 2
31+
build-deploy:
32+
jobs:
33+
- build:
34+
filters:
35+
tags:
36+
only: /\d+\.\d+\.\d+/
37+
- deploy:
38+
requires:
39+
- build
40+
filters:
41+
tags:
42+
only: /\d+\.\d+\.\d+/
43+
branches:
44+
ignore: /.*/
45+

.travis.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
# Changelog
22

3+
## v1.5.2 (14/12/2020)
4+
*No changelog for this release.*
5+
6+
---
7+
8+
## v1.5.1 (14/12/2020)
9+
10+
#### closed
11+
12+
- [**closed**] fix mapObject, create new object for every call [#51](https://github.com/vankeisb/react-tea-cup/pull/51)
13+
14+
#### dependencies
15+
16+
- [**dependencies**] Bump ini from 1.3.5 to 1.3.8 [#52](https://github.com/vankeisb/react-tea-cup/pull/52)
17+
18+
---
19+
20+
## v1.5.0 (11/12/2020)
21+
22+
#### closed
23+
24+
- [**closed**] document events [#47](https://github.com/vankeisb/react-tea-cup/pull/47)
25+
26+
---
27+
328
## v1.4.0 (01/12/2020)
429

530
#### closed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
[![Build Status](https://travis-ci.org/vankeisb/react-tea-cup.svg?branch=develop)](https://travis-ci.org/vankeisb/react-tea-cup) ![](https://img.shields.io/github/tag/vankeisb/react-tea-cup.svg?label=latest&style=flat)
2-
31
Want some TEA in your React ?
42

53
`react-tea-cup` is a very thin library that helps following The Elm Architecture, in React.

core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tea-cup-core",
3-
"version": "1.4.0",
3+
"version": "1.5.2",
44
"description": "react-tea-cup core classes and utilities (Maybe etc)",
55
"author": "Rémi Van Keisbelck <remi@rvkb.com>",
66
"license": "MIT",

core/src/TeaCup/Decode.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,31 @@ describe('mapObject', () => {
243243
const value = { foo: 'a foo', toto: true }
244244
expect(Decode.mapObject<MyType2>(decoder).decodeValue(value)).toEqual(ok(expected));
245245
})
246+
247+
it('decode array of mapObject', () => {
248+
type MyItem = { gnu: number; foo: string };
249+
250+
const MyItemDecoder: Decoder<MyItem> = Decode.mapObject(
251+
Decode.mapRequiredFields({
252+
gnu: Decode.num,
253+
foo: Decode.str,
254+
}),
255+
);
256+
257+
const payload: MyItem[] = [
258+
{
259+
gnu: 1,
260+
foo: 'a',
261+
},
262+
{
263+
gnu: 2,
264+
foo: 'b',
265+
},
266+
];
267+
268+
const r = Decode.array(MyItemDecoder).decodeValue(payload);
269+
expect(r).toEqual(ok(payload));
270+
});
246271
})
247272

248273
describe('mapArray', () => {

core/src/TeaCup/Decode.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -450,14 +450,16 @@ export class Decode {
450450
*/
451451
static mapObject<T>(dobject: DecoderObject<T>): Decoder<T> {
452452
const keys = Object.keys(dobject) as Array<keyof typeof dobject>
453-
const partialDecoder: Decoder<Partial<T>> = keys.reduce((dacc, key) => Decode.andThen(object => {
454-
const propertyDecoder = getProperty(dobject, key);
455-
return Decode.map(property => {
456-
object[key] = property;
457-
return object;
458-
}, propertyDecoder);
459-
}, dacc), Decode.succeed({} as Partial<T>))
460-
return Decode.map(v => v as T, partialDecoder);
453+
return new Decoder((value: any) =>
454+
keys.reduce((acc, key) => {
455+
const propertyDecoder = getProperty(dobject, key);
456+
const v = propertyDecoder.decodeValue(value);
457+
return v.andThen(v => acc.map(acc => {
458+
acc[key] = v;
459+
return acc;
460+
}))
461+
}, ok<string, T>({} as T))
462+
);
461463
}
462464

463465
/**

package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
{
22
"name": "tea-cup-parent",
33
"private": true,
4-
"workspaces": ["core", "tea-cup", "samples"],
4+
"workspaces": [
5+
"core",
6+
"tea-cup",
7+
"samples"
8+
],
59
"devDependencies": {
10+
"github-release-notes": "0.17.2",
611
"jest": "24.9.0",
712
"prettier": "2.0.5",
813
"rimraf": "^2.6.3",
914
"ts-jest": "24.0.2",
10-
"typescript": "~3.8.3",
11-
"github-release-notes": "0.17.2"
15+
"typescript": "~3.9.7"
1216
},
1317
"scripts": {
1418
"release:gh": "gren release",
1519
"release:changelog": "gren changelog --tags all --generate --override"
1620
}
17-
}
21+
}

samples/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"react": "^16.7.0",
1212
"react-dom": "^16.7.0",
1313
"react-scripts": "3.4.3",
14-
"react-tea-cup": "1.4.0"
14+
"react-tea-cup": "1.5.2"
1515
},
1616
"scripts": {
1717
"start": "react-scripts start",

0 commit comments

Comments
 (0)