redux-fluent
Advanced tools
Comparing version 0.26.0 to 0.26.1
@@ -1,5 +0,74 @@ | ||
# Change Log | ||
# Changelog | ||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. | ||
### [0.26.1](https://github.com/Code-Y/redux-fluent/compare/v0.9.8...v0.26.1) (2019-12-20) | ||
### Bug Fixes | ||
* export typescript definitions ([9373d20](https://github.com/Code-Y/redux-fluent/commit/9373d20)) | ||
### [0.9.5](https://github.com/Code-Y/redux-fluent/compare/v0.9.4...v0.9.5) (2019-06-20) | ||
### Bug Fixes | ||
* rfa implementation ([7bbd5a0](https://github.com/Code-Y/redux-fluent/commit/7bbd5a0)) | ||
# [0.9.0](https://github.com/Code-Y/redux-fluent/compare/v0.8.11...v0.9.0) (2019-03-23) | ||
### Features | ||
* **action:** add typesafe Error ([058955a](https://github.com/Code-Y/redux-fluent/commit/058955a)), closes [#33](https://github.com/Code-Y/redux-fluent/issues/33) | ||
## [0.8.5](https://github.com/Code-Y/redux-fluent/compare/v0.8.4...v0.8.5) (2019-03-10) | ||
### Bug Fixes | ||
* **typings:** add action.error field ([11aace0](https://github.com/Code-Y/redux-fluent/commit/11aace0)) | ||
### Reverts | ||
* don't include action.error if no payload ([523d069](https://github.com/Code-Y/redux-fluent/commit/523d069)) | ||
# [0.8.0](https://github.com/Code-Y/redux-fluent/compare/v0.6.2...v0.8.0) (2019-03-10) | ||
### Features | ||
* **api:** export createCombinableReducers ([be77848](https://github.com/Code-Y/redux-fluent/commit/be77848)) | ||
# [0.7.0](https://github.com/Code-Y/redux-fluent/compare/v0.6.2...v0.7.0) (2019-03-09) | ||
### Features | ||
* **api:** export createCombinableReducers ([be77848](https://github.com/Code-Y/redux-fluent/commit/be77848)) | ||
<a name="0.27.1"></a> | ||
## [0.27.1](https://github.com/Code-Y/redux-fluent/compare/v0.27.0...v0.27.1) (2018-05-22) | ||
### Bug Fixes | ||
* **Action:** redux isPlainObject doesn't accept bare objects ([#18](https://github.com/Code-Y/redux-fluent/issues/18)) ([5ad16c5](https://github.com/Code-Y/redux-fluent/commit/5ad16c5)) | ||
<a name="0.26.0"></a> | ||
@@ -15,22 +84,20 @@ # [0.26.0](https://github.com/Code-Y/redux-fluent/compare/v0.25.5...v0.26.0) (2018-02-18) | ||
<a name="0.24.4"></a> | ||
## [0.24.4](https://github.com/Code-Y/redux-fluent/compare/v0.24.3...v0.24.4) (2018-01-27) | ||
<a name="0.25.5"></a> | ||
## [0.25.5](https://github.com/Code-Y/redux-fluent/compare/v0.25.4...v0.25.5) (2018-02-16) | ||
### Bug Fixes | ||
<a name="0.24.3"></a> | ||
## [0.24.3](https://github.com/Code-Y/redux-fluent/compare/v0.24.2...v0.24.3) (2018-01-26) | ||
* **webpack:** export Testing Utilities ([d8dfd66](https://github.com/Code-Y/redux-fluent/commit/d8dfd66)) | ||
<a name="0.24.2"></a> | ||
## [0.24.2](https://github.com/Code-Y/redux-fluent/compare/v0.24.1...v0.24.2) (2018-01-26) | ||
<a name="0.25.4"></a> | ||
## [0.25.4](https://github.com/Code-Y/redux-fluent/compare/v0.24.4...v0.25.4) (2018-02-16) | ||
### Features | ||
<a name="0.24.1"></a> | ||
## [0.24.1](https://github.com/Code-Y/redux-fluent/compare/v0.24.0...v0.24.1) (2018-01-26) | ||
* **Testing:** add createFakeStore(...reducers) ([#16](https://github.com/Code-Y/redux-fluent/issues/16)) ([55ccabf](https://github.com/Code-Y/redux-fluent/commit/55ccabf)) | ||
<a name="0.24.0"></a> | ||
@@ -63,12 +130,2 @@ # [0.24.0](https://github.com/Code-Y/redux-fluent/compare/v0.22.2...v0.24.0) (2018-01-26) | ||
<a name="0.22.2"></a> | ||
## [0.22.2](https://github.com/Code-Y/redux-fluent/compare/v0.22.1...v0.22.2) (2018-01-24) | ||
<a name="0.22.1"></a> | ||
## [0.22.1](https://github.com/Code-Y/redux-fluent/compare/v0.22.0...v0.22.1) (2018-01-24) | ||
<a name="0.22.0"></a> | ||
@@ -75,0 +132,0 @@ # [0.22.0](https://github.com/Code-Y/redux-fluent/compare/v0.21.4...v0.22.0) (2018-01-24) |
133
index.d.ts
@@ -1,131 +0,2 @@ | ||
declare module 'redux-fluent' { | ||
export function createReducer< | ||
S extends object = {}, | ||
C extends object = object, | ||
D extends string = string | ||
>(domain: D): { | ||
default: I.Default<D, S, C>; | ||
case: I.Case<D, S, C>; | ||
config<CC extends C>(config: CC): { | ||
default: I.Default<D, S, CC>; | ||
case: I.Case<D, S, CC> | ||
} | ||
}; | ||
export function createAction< | ||
P extends object = object, | ||
M extends object = object, | ||
T extends string = string | ||
>(type: T, payloadCreator?: (p: any) => P, metaCreator?: (m: any) => M): I.ActionCreator<P, M, T>; | ||
export function createCombinableReducers< | ||
R extends { domain: string } | ||
>(...reducers: R[]): { | ||
[domain: string]: R | ||
} | ||
} | ||
declare namespace /* Interfaces */ I { | ||
export interface Action { | ||
type: string; | ||
error: boolean; | ||
payload: object | null; | ||
meta: object | null; | ||
} | ||
export interface ActionError< | ||
T extends string, | ||
E extends Error, | ||
M extends object | null | ||
> extends Action { | ||
type: T; | ||
error: true; | ||
payload: E; | ||
meta: M; | ||
} | ||
export interface ActionSuccess< | ||
T extends string, | ||
P extends object | null, | ||
M extends object | null | ||
> extends Action { | ||
type: T; | ||
error: false; | ||
payload: P; | ||
meta: M; | ||
} | ||
interface Case<D, S, C> { | ||
(actionType: string): { | ||
case: Case<D, S, C>; | ||
do: Do<D, S, C>; | ||
then: Then<D, S, C>; | ||
catch: Catch<D, S, C>; | ||
}; | ||
(action: Action): { | ||
case: Case<D, S, C>; | ||
do: Do<D, S, C>; | ||
then: Then<D, S, C>; | ||
catch: Catch<D, S, C>; | ||
}; | ||
(anyToString: { toString(): string }): { | ||
case: Case<D, S, C>; | ||
do: Do<D, S, C>; | ||
then: Then<D, S, C>; | ||
catch: Catch<D, S, C>; | ||
}; | ||
} | ||
interface Do<D, S, C> { | ||
<A extends Action>(reducer: (state: S, action: A, config: C) => S): { | ||
default: Default<D, S, C>; | ||
case: Case<D, S, C>; | ||
do: Do<D, S, C>; | ||
then: Then<D, S, C>; | ||
catch: Catch<D, S, C>; | ||
}; | ||
} | ||
interface Default<D, S, C> { | ||
(state?: S): { | ||
readonly domain: D; | ||
toString(): D; | ||
<A extends Action>(state: S, action: A): S; | ||
}; | ||
<A extends Action>(arg: (state: S, action: A, config: C) => S): { | ||
domain: D; | ||
toString(): D; | ||
<A extends Action>(state: S, action: A): S; | ||
}; | ||
} | ||
interface Then<D, S, C> { | ||
<A extends ActionSuccess, AE extends ActionError>( | ||
success: (s: S, a: A, c: C) => S, error?: (s: S, a: AE, c: C) => S | ||
): Do<D, S, C> | ||
} | ||
interface Catch<D, S, C> { | ||
<AE extends ActionError>(error: (s: S, a: AE, c: C) => S): Do<D, S, C> | ||
} | ||
interface ActionCreator< | ||
P extends object = object, | ||
M extends object = object, | ||
T extends string = string | ||
> { | ||
readonly type: string; | ||
toString(): string; | ||
<E extends Error, EM extends M>(payload: E, meta: EM): Readonly<ActionError<T, E, EM>>; | ||
<E extends Error>(payload: E): Readonly<ActionError<T, E, null>>; | ||
<PS extends P, MS extends M>(payload: PS, meta: MS): Readonly<ActionSuccess<T, PS, MS>>; | ||
<PS extends P>(payload: PS): Readonly<ActionSuccess<T, PS, null>>; | ||
<MS extends M>(payload: null | undefined, meta: MS): Readonly<ActionSuccess<T, null, MS>>; | ||
(): Readonly<ActionSuccess<T, null, null>>; | ||
} | ||
} | ||
// eslint-disable-next-line import/no-unresolved | ||
export * from './dist/redux-fluent'; |
13
index.js
@@ -1,10 +0,7 @@ | ||
/* eslint-disable spaced-comment, strict, global-require */ | ||
// eslint-disable-next-line spaced-comment | ||
/// <reference path="./index.d.ts" /> | ||
'use strict'; | ||
if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('./build/redux-fluent.production.js'); | ||
} else { | ||
module.exports = require('./build/redux-fluent.development.js'); | ||
} | ||
// eslint-disable-next-line import/no-dynamic-require | ||
module.exports = require( | ||
`./dist/redux-fluent.${process.env.NODE_ENV === 'production' ? 'production' : 'development'}.js`, | ||
); |
122
package.json
{ | ||
"name": "redux-fluent", | ||
"license": "MIT", | ||
"version": "0.26.0", | ||
"version": "0.26.1", | ||
"homepage": "https://github.com/Code-Y/redux-fluent#readme", | ||
"description": "Tiny and eloquent way to manage a redux-like state manager", | ||
"author": "Code-Y (https://github.com/Code-Y)", | ||
"private": false, | ||
"description": "A Practical and Functional utility for redux", | ||
"author": "Code-Y", | ||
"sideEffects": false, | ||
"main": "index.js", | ||
"types": "index.d.ts", | ||
"contributors": [ | ||
"Luca Pau <luca.pau82@gmail.com> (https://github.com/Lughino)", | ||
"Giuseppe Mandato <gius.mand.developer@gmail.com> (https://github.com/hitmands)" | ||
"files": [ | ||
"/dist", | ||
"CHANGELOG.md", | ||
"LICENSE", | ||
"index.js", | ||
"index.d.ts" | ||
], | ||
"keywords": [ | ||
"redux", | ||
"ngrx-store", | ||
"state-management", | ||
"typings" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"scripts": { | ||
"lint": "eslint ./src/**/*.ts", | ||
"build": "webpack --config webpack.config.js", | ||
"test": "jest --coverage", | ||
"build": "NODE_ENV=production npm run webpack", | ||
"webpack": "webpack --config webpack.config.js", | ||
"cz": "git-cz", | ||
"release": "standard-version && git push --follow-tags origin master" | ||
"release": "standard-version -m \"chore(release): %s [skip ci]\"" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS" | ||
} | ||
}, | ||
"repository": { | ||
@@ -38,35 +36,57 @@ "type": "git", | ||
}, | ||
"contributors": [ | ||
"Giuseppe Mandato (https://github.com/hitmands)", | ||
"Luca Pau (https://github.com/Lughino)" | ||
], | ||
"keywords": [ | ||
"redux", | ||
"functional programming", | ||
"ramda", | ||
"typings" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"peerDependencies": { | ||
"flux-standard-action": "^2.1.1", | ||
"redux": "^4.0.4" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^21.1.9", | ||
"babel-core": "^6.26.0", | ||
"babel-env": "^2.4.1", | ||
"babel-eslint": "^8.1.2", | ||
"babel-jest": "^22.0.4", | ||
"babel-loader": "^7.1.2", | ||
"commitizen": "^2.9.6", | ||
"cz-conventional-changelog": "^2.1.0", | ||
"eslint": "^4.14.0", | ||
"eslint-config-airbnb": "^16.1.0", | ||
"eslint-loader": "^1.9.0", | ||
"eslint-plugin-import": "^2.8.0", | ||
"eslint-plugin-jest": "^21.5.0", | ||
"eslint-plugin-jsx-a11y": "^6.0.3", | ||
"eslint-plugin-react": "^7.5.1", | ||
"flux-standard-action": "^2.0.1", | ||
"jest": "^21.2.1", | ||
"redux": "^3.7.2", | ||
"standard-version": "^4.3.0", | ||
"webpack": "^3.10.0" | ||
}, | ||
"jest": { | ||
"transform": { | ||
"^.+\\.jsx?$": "babel-jest" | ||
}, | ||
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?)$", | ||
"moduleFileExtensions": [ | ||
"js", | ||
"jsx", | ||
"json" | ||
] | ||
"@commitlint/cli": "^8.2.0", | ||
"@commitlint/config-conventional": "^8.2.0", | ||
"@commitlint/travis-cli": "^8.2.0", | ||
"@types/chai": "^4.2.6", | ||
"@types/jest": "^24.0.23", | ||
"@types/node": "^12.12.15", | ||
"@types/ramda": "^0.26.38", | ||
"@types/sinon": "^7.5.1", | ||
"@types/sinon-chai": "^3.2.3", | ||
"@typescript-eslint/eslint-plugin": "^2.11.0", | ||
"@typescript-eslint/parser": "^2.11.0", | ||
"awesome-typescript-loader": "^5.2.1", | ||
"chai": "^4.2.0", | ||
"eslint": "^6.7.2", | ||
"eslint-config-airbnb-base": "^14.0.0", | ||
"eslint-loader": "^3.0.3", | ||
"eslint-plugin-chai-friendly": "^0.5.0", | ||
"eslint-plugin-import": "^2.19.1", | ||
"eslint-plugin-jest": "^23.1.1", | ||
"flux-standard-action": "^2.1.1", | ||
"gitbook": "^2.6.9", | ||
"gitbook-cli": "^2.3.2", | ||
"gitbook-plugin-codesandbox": "^0.1.1", | ||
"gitbook-plugin-prism": "^2.4.0", | ||
"husky": "^3.1.0", | ||
"jest": "^24.9.0", | ||
"ramda": "^0.26.1", | ||
"redux": "^4.0.4", | ||
"sinon": "^7.5.0", | ||
"sinon-chai": "^3.3.0", | ||
"standard-version": "^7.0.1", | ||
"ts-jest": "^24.2.0", | ||
"typescript": "^3.7.3", | ||
"webpack": "^4.41.2", | ||
"webpack-cli": "^3.3.10", | ||
"webpack-node-externals": "^1.7.2" | ||
} | ||
} |
@@ -1,76 +0,68 @@ | ||
# <a href='https://github.com/Code-Y/redux-fluent'><img src='https://raw.githubusercontent.com/Code-Y/redux-fluent/master/redux-fluent-logo.png' height='60' alt='Redux Fluent Logo' aria-label='https://github.com/Code-Y/redux-fluent' /></a> Redux Fluent | ||
[![npm version](https://img.shields.io/npm/v/redux-fluent.svg)](https://www.npmjs.com/package/redux-fluent) | ||
[![Build Status](https://travis-ci.org/Code-Y/redux-fluent.svg?branch=master)](https://travis-ci.org/Code-Y/redux-fluent) | ||
[![npm downloads](https://img.shields.io/npm/dm/redux-fluent.svg)](https://www.npmjs.com/package/redux-fluent) | ||
[![Code Climate](https://codeclimate.com/github/Code-Y/redux-fluent/badges/gpa.svg)](https://codeclimate.com/github/Code-Y/redux-fluent) | ||
[![Test Coverage](https://api.codeclimate.com/v1/badges/02e8b0d9ba383c19ae50/test_coverage)](https://codeclimate.com/github/Code-Y/redux-fluent/test_coverage) | ||
[![npm version](https://img.shields.io/npm/l/redux-fluent.svg)](https://github.com/Code-Y/redux-fluent/blob/master/LICENSE) | ||
<div align="center"> | ||
# redux-fluent | ||
Tiny and eloquent way to manage a redux-like state manager (*3K*, dependencies free, definitions included). | ||
A Practical and Functional Utility for [redux](https://redux.js.org/) | ||
[Try it out on RunKit](https://runkit.com/hitmands/redux-fluent-playground) | ||
[![Build Status](https://github.com/Code-Y/redux-fluent/workflows/Build/badge.svg)](https://github.com/Code-Y/redux-fluent/actions?query=workflow%3ABuild) | ||
[![npm version](https://img.shields.io/npm/v/redux-fluent.svg)](https://www.npmjs.com/package/redux-fluent) | ||
[![License](https://img.shields.io/npm/l/redux-fluent.svg)](https://github.com/Code-Y/redux-fluent/blob/master/LICENSE) | ||
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org) | ||
[![npm downloads](https://img.shields.io/npm/dm/redux-fluent.svg)](https://www.npmjs.com/package/redux-fluent) | ||
[![Maintainability](https://api.codeclimate.com/v1/badges/2e98502fb6072892995d/maintainability)](https://codeclimate.com/github/Code-Y/redux-fluent/maintainability) | ||
[![Test Coverage](https://api.codeclimate.com/v1/badges/2e98502fb6072892995d/test_coverage)](https://codeclimate.com/github/Code-Y/redux-fluent/test_coverage) | ||
## Documentation | ||
#### [...::: TRY OUR COUNTER REDUCER EXAMPLE ON CODESANDBOX :::...](https://codesandbox.io/s/redux-fluent-the-counter-reducer-enoc2?fontsize=14&hidenavigation=1&theme=dark) | ||
<hr /> | ||
</div> | ||
1. [Action](./docs/Action.MD) | ||
2. [Reducer](./docs/Reducer.MD) | ||
3. [CombinableReducers](./docs/CombinableReducers.MD) | ||
### Installation | ||
## Motivation | ||
``` | ||
yarn add redux-fluent redux flux-standard-action | ||
``` | ||
[Redux](https://redux.js.org/) is great, *every recent web application was most likely been built on top of it*, however we really think we can simplify it further and, after our investigation, we came out with: | ||
### Documentation | ||
- **Reducers** tend to grow and become hard to maintain, 'cause of the amount of switch-cases. | ||
- Concepts such as **Action**, **Action Type** and **Action Creator** could be squashed into only one. | ||
- [FSA action](https://github.com/acdlite/flux-standard-action#actions) may have `error = true` but this involves `IF Statements` inside reducers, so, developers tend to have separate `cases` via `ACTION_SUCCESS` and `ACTION_ERROR`. | ||
- Uncontrolled scaffolding growth. | ||
- https://code-y.github.io/redux-fluent | ||
## Installation | ||
### Getting Started | ||
```bash | ||
npm install --save redux-fluent | ||
``` | ||
```typescript | ||
import { createStore } from 'redux'; | ||
import { createAction, createReducer, ofType } from 'redux-fluent'; | ||
## Getting Started | ||
const increment = createAction('increment'); | ||
const decrement = createAction('decrement'); | ||
```javascript | ||
/** todosReducer.js **/ | ||
import { createAction, createReducer } from 'redux-fluent'; | ||
const counter = createReducer('counter') | ||
.actions( | ||
ofType(increment).map(state => state + 1), | ||
ofType(decrement).map(state => state - 1), | ||
) | ||
.default(() => 0); | ||
const store = createStore(counter); | ||
const addTodo = createAction('@@todos | add'); | ||
store.dispatch(increment()); | ||
``` | ||
const todosReducer = createReducer('@@todos') | ||
.case(addTodo) | ||
.then((state, { payload }) => state.concat(payload)) | ||
### Distribution | ||
.default(() => []) | ||
; | ||
- https://www.npmjs.com/package/redux-fluent | ||
export { todosReducer, addTodo }; | ||
``` | ||
### Stats | ||
```javascript | ||
/** application.js **/ | ||
import { createStore, combineReducers } from 'redux'; | ||
import { createCombinableReducers } from 'redux-fluent'; | ||
import { otherReducer } from './otherReducer'; | ||
import { todosReducer, addTodo } from './todosReducer'; | ||
- `3.2 kB` - https://bundlephobia.com/result?p=redux-fluent | ||
### Discussion | ||
const reducers = combineReducers( | ||
createCombinableReducers(todosReducer, otherReducer), | ||
); | ||
- [![Gitter](https://badges.gitter.im/redux-fluent/community.svg)](https://gitter.im/redux-fluent/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) | ||
- [StackOverflow](https://stackoverflow.com/questions/tagged/redux-fluent) | ||
- [Github Issues](https://github.com/Code-Y/redux-fluent/issues) | ||
- [Submit a Pull Request](https://github.com/Code-Y/redux-fluent/pulls) | ||
const store = createStore(reducers); | ||
### License | ||
// You can think of `addTodo` as an action creator itself | ||
store.dispatch( | ||
addTodo({ | ||
id: 1, | ||
title: 'Walk Gipsy', | ||
}), | ||
); | ||
``` | ||
[MIT](https://github.com/Code-Y/redux-fluent/blob/master/LICENSE) |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
64400
2
36
17
435
2
69
1