
Security News
Django Joins curl in Pushing Back on AI Slop Security Reports
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
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.
The npm package js-messages receives a total of 42 weekly downloads. As such, js-messages popularity was classified as not popular.
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.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.