
Product
Introducing Data Exports
Export Socket alert data to your own cloud storage in JSON, CSV, or Parquet, with flexible snapshot or incremental delivery.
js-messages
Advanced tools
A small library to handle messages, message types and message creators (also known as "actions", "action types" and "action creators" in redux context). js-messages is written in TypeScript, everything is completely type safe.
A small library to handle messages, message types and message creators (also known as "actions", "action types" and "action creators" in redux context). js-messages is written in TypeScript, everything is completely type safe.
npm install --save js-messages
js-messages consists of three functions:
defineMessage: To define one type of message / to create one message creatordefineMessages: To define multiple related messages represented by message creatorsprops: A helper function to define a message creator where all message properties
must be declared explicitly in an object.Example 1 (using defineMessage)
import { defineMessage } from 'js-messages'
const increment = defineMessage('increment')
// for messages of shape { type: 'increment' }
const decrement = defineMessage('decrement')
// for messages of shape { type: 'decrement' }
const resetTo = defineMessage('resetTo', (value: number) => ({ value }))
// for messages of shape { type: 'resetTo', value: number }
Example 2 (using defineMessage and props)
const saveToStorage = defineMessage(
'saveToStorage',
props<{ tasks: Task[]; storageKey: string }>()
)
// for messages of shape
// {
// type: 'saveToStorage',
// tasks: Task[],
// storageKey: string
// }
Example 3 (using defineMessages, without namespace):
import { defineMessages } from 'js-messages'
const Actions = defineMessages({
increment: null,
// for messages of shape { type: 'increment' }
decrement: null,
// for messages of shape { type: 'decrement' }
resetTo: (value: number) => ({ value })
// for messages of shape { type: 'resetTo', value: number }
log: (value: number, message: string = null) => ({ value, message })
// for messages of shape { type: 'log', value: number, message: string }
})
Example 4 (using defineMessages, with namespace):
import { defineMessages } from 'js-messages'
const Actions = defineMessages('counter', {
increment: null,
// for messages of shape { type: 'counter.increment' }
decrement: null,
// for messages of shape { type: 'counter.decrement' }
resetTo: (value: number) => ({ value })
// for messages of shape { type: 'counter.resetTo', value: number }
log: (value: number, message: string = null) => ({ value, message })
// for messages of shape { type: 'counter.log', value: number, message: string }
})
"js-messages" is licensed under LGPLv3.
"js-messages" is currently in beta status.
FAQs
A small library to handle messages, message types and message creators (also known as "actions", "action types" and "action creators" in redux context). js-messages is written in TypeScript, everything is completely type safe.
We found that js-messages demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Export Socket alert data to your own cloud storage in JSON, CSV, or Parquet, with flexible snapshot or incremental delivery.

Research
/Security News
Bitwarden CLI 2026.4.0 was compromised in the Checkmarx supply chain campaign after attackers abused a GitHub Action in Bitwarden’s CI/CD pipeline.

Research
/Security News
Docker and Socket have uncovered malicious Checkmarx KICS images and suspicious code extension releases in a broader supply chain compromise.