Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

correction type judgment #343

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/createAction.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import invariant from 'invariant';
import isFunction from './utils/isFunction';
import identity from './utils/identity';
import isNull from './utils/isNull';
import isNil from './utils/isNil';

export default function createAction(
type,
payloadCreator = identity,
metaCreator
) {
invariant(
isFunction(payloadCreator) || isNull(payloadCreator),
isFunction(payloadCreator) || isNil(payloadCreator),
'Expected payloadCreator to be a function, undefined or null'
);

const finalPayloadCreator =
isNull(payloadCreator) || payloadCreator === identity
isNil(payloadCreator) || payloadCreator === identity
? identity
: (head, ...args) =>
head instanceof Error ? head : payloadCreator(head, ...args);

const hasMeta = isFunction(metaCreator);
const typeString = type.toString();
const typeString = String(type);

const actionCreator = (...args) => {
const payload = finalPayloadCreator(...args);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/flattenWhenNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default predicate =>
) {
function connectNamespace(type) {
if (!partialFlatActionType) return type;
const types = type.toString().split(ACTION_TYPE_DELIMITER);
const types = String(type).split(ACTION_TYPE_DELIMITER);
const partials = partialFlatActionType.split(ACTION_TYPE_DELIMITER);
return []
.concat(...partials.map(p => types.map(t => `${p}${namespace}${t}`)))
Expand Down
1 change: 0 additions & 1 deletion src/utils/isNull.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/utils/toString.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default value => value.toString();
export default value => String(value);