Skip to content

arsenykruglikov/flux-standard-action

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flux_standard_action — port of flux-standard-action npm package for Deno

Lint, tests and build

Motivation for port and credits

This project inspired by timche's package flux-standard-action. Thank you a lot for such a good starting point to do this port. And consider seeing his GitHub account and repos and press a like button.

Deno third-party modules lack this useful utility. At this moment timche is looking for maintainers for his projects and less likely he will port his project for Deno soon.

This module has no lodash dependence.

You can see the original explanation here.

Utility functions

The module flux_standard_action is available on deno.land/x. It exports a few utility functions.

isFSA(action)

import { isFSA } from 'https://deno.land/x/flux_standard_action/mod.ts';

const action: any = JSON.parse('{ "type": "ACTION_TYPE" }')

if (isFSA(action)) {
  // now action is checked, considered as flux_standard_action and has a type FluxStandardAction<Type, Payload, Meta>
  const type = action.type;
}

Returns true if action is FSA compliant.

isError(action)

import { isError } from 'https://deno.land/x/flux_standard_action/mod.ts';

const action: any = JSON.parse('{ "type": "SOME_ERROR_TYPE", "error": true }')

if (isError(action)) {
  // now action is checked, considered as error and has a type FluxStandardAction<Type, Payload, Meta>
  const type = action.type;
  const isError = action.error;
}

Returns true if action represents an error.