Skip to content
This repository has been archived by the owner on Feb 25, 2024. It is now read-only.

Commit

Permalink
Prevent the whole implementation of an anonymous inline action being …
Browse files Browse the repository at this point in the history
…displayed on a transition (#148)
  • Loading branch information
Andarist committed Aug 4, 2021
1 parent 59cb305 commit 7460002
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,16 @@ export function getEdges(stateNode: StateNode): Array<Edge<any, any, any>> {
return edges;
}

const isStringifiedFunction = (str: string): boolean =>
/^function\s*\(/.test(str) || str.includes('=>');

export const getActionLabel = (action: ActionObject<any, any>) => {
if (typeof action.exec === 'function') {
return isStringifiedFunction(action.type) ? 'anonymous' : action.type;
}
if (action.type !== 'xstate.assign') {
return action.type;
}

switch (typeof action.assignment) {
case 'object':
const keys = Object.keys(action.assignment).join();
Expand Down

1 comment on commit 7460002

@vercel
Copy link

@vercel vercel bot commented on 7460002 Aug 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.