Skip to content

Commit

Permalink
Merge pull request #276 from blueflag/feature/action-indexes
Browse files Browse the repository at this point in the history
Feature/action indexes
  • Loading branch information
dxinteractive committed Jan 15, 2020
2 parents f7d31b7 + 92a87ef commit 2a49513
Show file tree
Hide file tree
Showing 23 changed files with 138 additions and 586 deletions.
14 changes: 7 additions & 7 deletions packages/dataparcels/.size-limit.json
@@ -1,6 +1,6 @@
[
{
"limit": "10.5 KB",
"limit": "10.3 KB",
"path": "lib/index.js"
},
{
Expand All @@ -12,35 +12,35 @@
"path": "cancel.js"
},
{
"limit": "7.5 KB",
"limit": "7.3 KB",
"path": "ChangeRequest.js"
},
{
"limit": "0.1 KB",
"path": "deleted.js"
},
{
"limit": "5.9 KB",
"limit": "5.8 KB",
"path": "ParcelNode.js"
},
{
"limit": "6 KB",
"limit": "6.2 KB",
"path": "asNode.js"
},
{
"limit": "6 KB",
"limit": "6.2 KB",
"path": "asChildNodes.js"
},
{
"limit": "0.1 KB",
"path": "asRaw.js"
},
{
"limit": "6.1 KB",
"limit": "6.3 KB",
"path": "translate.js"
},
{
"limit": "5.2 KB",
"limit": "5.4 KB",
"path": "validation.js"
}
]
2 changes: 1 addition & 1 deletion packages/dataparcels/package.json
Expand Up @@ -39,7 +39,7 @@
},
"dependencies": {
"@babel/runtime": "^7.1.5",
"unmutable": "^0.46.1"
"unmutable": "^0.47.1"
},
"devDependencies": {
"@babel/cli": "^7.1.2",
Expand Down
9 changes: 4 additions & 5 deletions packages/dataparcels/src/change/Action.js
@@ -1,20 +1,19 @@
// @flow
import type {ActionStep} from '../types/Types';
import type {Index} from '../types/Types';
import type {Key} from '../types/Types';

type ActionData = {
type?: string,
payload?: any,
keyPath?: Array<Key|Index>,
steps?: Array<ActionStep>
keyPath?: Key[],
steps?: ActionStep[]
};

export default class Action {
type: string = "";
payload: any;
keyPath: Array<Key|Index> = [];
steps: Array<ActionStep> = [];
keyPath: Key[] = [];
steps: ActionStep[] = [];

constructor({type, payload = this.payload, keyPath, steps}: ActionData = {}) {
this.type = type || this.type;
Expand Down
6 changes: 0 additions & 6 deletions packages/dataparcels/src/change/ChangeRequestReducer.js
Expand Up @@ -13,12 +13,9 @@ import del from '../parcelData/delete';
import deleteSelfWithMarker from '../parcelData/deleteSelfWithMarker';
import insertAfter from '../parcelData/insertAfter';
import insertBefore from '../parcelData/insertBefore';
import map from '../parcelData/map';
import pop from '../parcelData/pop';
import push from '../parcelData/push';
import setMeta from '../parcelData/setMeta';
import setSelf from '../parcelData/setSelf';
import shift from '../parcelData/shift';
import swap from '../parcelData/swap';
import swapNext from '../parcelData/swapNext';
import swapPrev from '../parcelData/swapPrev';
Expand All @@ -29,13 +26,10 @@ const actionMap = {
delete: del, //: (lastKey) => del(lastKey),
insertAfter, //: (lastKey, value) => insertAfter(lastKey, value),
insertBefore, //: (lastKey, value) => insertBefore(lastKey, value),
map: (lastKey, updater) => map(updater),
pop, //: () => pop(),
push: (lastKey, values) => push(...values),
setData: (lastKey, parcelData) => () => parcelData,
setMeta: (lastKey, meta) => setMeta(meta),
set: (lastKey, value) => setSelf(value),
shift, //: () => shift(),
swap, //: (lastKey, swapKey) => swap(lastKey, swapKey),
swapNext, //: (lastKey) => swapNext(lastKey),
swapPrev, //: (lastKey) => swapPrev(lastKey),
Expand Down
Expand Up @@ -25,23 +25,12 @@ const ActionCreators = {
payload: value
});
},
map: (updater): Action => {
return new Action({
type: "map",
payload: updater
});
},
push: (...values): Action => {
return new Action({
type: "push",
payload: values
});
},
pop: (): Action => {
return new Action({
type: "pop"
});
},
setData: (parcelData): Action => {
return new Action({
type: "setData",
Expand All @@ -60,11 +49,6 @@ const ActionCreators = {
payload: value
});
},
shift: (): Action => {
return new Action({
type: "shift"
});
},
swap: (keyA, keyB): Action => {
return new Action({
type: "swap",
Expand Down

0 comments on commit 2a49513

Please sign in to comment.