Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

deeds

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deeds - npm Package Compare versions

Comparing version 2.0.1 to 3.0.0

21

bin/deeds.d.ts

@@ -8,11 +8,24 @@ import { ActionDeed, Reducer } from "./base";

}
declare type ActionCreator<M, K extends keyof M> = (...args: ActionReducerArgs<M[K]>) => ActionDeed<K, ActionReducerArgs<M[K]>>;
export declare type ActionMap<M extends {}> = {
[K in keyof M]: (...args: ActionReducerArgs<M[K]>) => ActionDeed<K, ActionReducerArgs<M[K]>>;
[K in keyof M]: ActionCreator<M, K>;
};
/**
* Creates an object of action creators. Each property of the result will match a property of the
* passed reducers object and will be a function that takes the arguments the reducer property uses.
* Creates an object of action creators. You must specify the generic type as the type of your
* reducers object, typically as `actionCreators<typeof reducers>()`. The type of each property of
* the returned object will match a property of the reducers object and will be a function that
* takes the arguments the reducer property uses excluding the initial store state argument and
* returns an action that can be dispatched to the store.
*/
export declare function actionCreators<M extends ActionReducerMap>(reducers: M): ActionMap<M>;
export declare function actionCreators<M extends ActionReducerMap>(): ActionMap<M>;
/**
* Creates a reducer function that accepts the store's state and an action and passes it to the
* appropriate reducer function property of the passed reducers object.
*/
export declare function baseReducer<S>(reducers: ActionReducerMap<S>): Reducer<S>;
/**
* Creates a reducer function that accepts the store's state and an action. If the state is
* undefined then an exception is thrown, otherwise the actiion is passed to the appropriate reducer
* function property of the passed reducers object.
*/
export declare function reducer<S>(reducers: ActionReducerMap<S>): Reducer<S | undefined, S>;

37

bin/deeds.js

@@ -6,18 +6,26 @@ "use strict";

/**
* Creates an object of action creators. Each property of the result will match a property of the
* passed reducers object and will be a function that takes the arguments the reducer property uses.
* Creates an object of action creators. You must specify the generic type as the type of your
* reducers object, typically as `actionCreators<typeof reducers>()`. The type of each property of
* the returned object will match a property of the reducers object and will be a function that
* takes the arguments the reducer property uses excluding the initial store state argument and
* returns an action that can be dispatched to the store.
*/
function actionCreators(reducers) {
let actions = {};
for (let key of Object.keys(reducers)) {
actions[key] = (...args) => {
return {
type: key,
payload: args,
function actionCreators() {
let creators = new Proxy({}, {
get: function (_target, prop) {
return (...args) => {
return {
type: prop,
payload: args,
};
};
};
}
return actions;
},
});
return creators;
}
exports.actionCreators = actionCreators;
/**
* Creates a reducer function that accepts the store's state and an action and passes it to the
* appropriate reducer function property of the passed reducers object.
*/
function baseReducer(reducers) {

@@ -32,2 +40,7 @@ return (state, action) => {

exports.baseReducer = baseReducer;
/**
* Creates a reducer function that accepts the store's state and an action. If the state is
* undefined then an exception is thrown, otherwise the actiion is passed to the appropriate reducer
* function property of the passed reducers object.
*/
function reducer(reducers) {

@@ -34,0 +47,0 @@ return base_1.makeReducer(reducers, baseReducer);

@@ -9,3 +9,12 @@ import { Immutable } from "immer";

}
/**
* Creates a reducer function that accepts the store's state and an action and passes it to the
* appropriate reducer function property of the passed reducers object.
*/
export declare function baseReducer<S>(reducers: DraftActionReducerMap<S>): Reducer<Immutable<S>>;
/**
* Creates a reducer function that accepts the store's state and an action. If the state is
* undefined then an exception is thrown, otherwise the actiion is passed to the appropriate reducer
* function property of the passed reducers object.
*/
export declare function reducer<S>(reducers: DraftActionReducerMap<S>): Reducer<Immutable<S> | undefined, Immutable<S>>;

@@ -16,2 +16,6 @@ "use strict";

}
/**
* Creates a reducer function that accepts the store's state and an action and passes it to the
* appropriate reducer function property of the passed reducers object.
*/
function baseReducer(reducers) {

@@ -22,2 +26,7 @@ let newReducers = immutableReducers(reducers);

exports.baseReducer = baseReducer;
/**
* Creates a reducer function that accepts the store's state and an action. If the state is
* undefined then an exception is thrown, otherwise the actiion is passed to the appropriate reducer
* function property of the passed reducers object.
*/
function reducer(reducers) {

@@ -24,0 +33,0 @@ return base_1.makeReducer(reducers, baseReducer);

{
"name": "deeds",
"version": "2.0.1",
"version": "3.0.0",
"description": "A tool to generate typed action creators given a set of reducers.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -33,3 +33,3 @@ # Deeds

const store = createStore(reducer(reducers), 1);
const actions = actionCreators(reducers);
const actions = actionCreators<typeof reducers>();

@@ -72,3 +72,3 @@ store.dispatch(actions.add(5));

const store = createStore(reducer(reducers), { value: 1 });
const actions = actionCreators(reducers);
const actions = actionCreators<typeof reducers>();

@@ -126,3 +126,3 @@ store.dispatch(actions.add(5));

});
const actions = actionCreators(reducers);
const actions = actionCreators<typeof reducers>();
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc