UNPKG

@wordpress/redux-routine

Version:
8 lines (7 loc) 1.17 kB
{ "version": 3, "sources": ["../src/is-action.ts"], "sourcesContent": ["/**\n * External dependencies\n */\nimport { isPlainObject } from 'is-plain-object';\nimport type { Action } from 'redux';\n\n/**\n * Returns true if the given object quacks like an action.\n *\n * @param object Object to test\n *\n * @return Whether object is an action.\n */\nexport function isAction( object: unknown ): object is Action {\n\treturn isPlainObject( object ) && typeof object.type === 'string';\n}\n\n/**\n * Returns true if the given object quacks like an action and has a specific\n * action type\n *\n * @param object Object to test\n * @param expectedType The expected type for the action.\n *\n * @return Whether object is an action and is of specific type.\n */\nexport function isActionOfType(\n\tobject: unknown,\n\texpectedType: string\n): object is Action {\n\treturn isAction( object ) && object.type === expectedType;\n}\n"], "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,6BAA8B;AAUvB,SAAS,SAAU,QAAoC;AAC7D,aAAO,sCAAe,MAAO,KAAK,OAAO,OAAO,SAAS;AAC1D;AAWO,SAAS,eACf,QACA,cACmB;AACnB,SAAO,SAAU,MAAO,KAAK,OAAO,SAAS;AAC9C;", "names": [] }