Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

use-broadcast-ts

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-broadcast-ts - npm Package Compare versions

Comparing version 1.2.3 to 1.2.4

32

dist/index.js

@@ -164,2 +164,6 @@ 'use strict';

/**
* Types
*/
/**
* Handle the Zustand set function

@@ -170,15 +174,31 @@ * Trigger a postMessage to all the other tabs

/**
* Update the state
* Get the previous states
*/
const previous = get();
/**
* Update the states
*/
set(...args);
/**
* Get the state to send
* Get the fresh states
*/
const state = args.reduce((obj, item) => obj = {
...obj,
...item
const updated = get();
/**
* Get the states that changed
*/
const state = Object.entries(updated).reduce((obj, [key, val]) => {
if (previous[key] !== val) {
obj = {
...obj,
[key]: val
};
}
return obj;
}, {});
/**
* Send the state to all the other tabs
* Send the states to all the other tabs
*/

@@ -185,0 +205,0 @@ channel.postMessage(state);

2

package.json
{
"name": "use-broadcast-ts",
"version": "1.2.3",
"version": "1.2.4",
"description": "Use the Broadcast Channel API in React easily with hooks or Zustand, and Typescript!",

@@ -5,0 +5,0 @@ "type": "module",

@@ -58,2 +58,7 @@ import { StateCreator, StoreMutatorIdentifier } from 'zustand';

/**
* Types
*/
type Item = { [key: string]: unknown };
/**
* Handle the Zustand set function

@@ -64,15 +69,28 @@ * Trigger a postMessage to all the other tabs

/**
* Update the state
* Get the previous states
*/
const previous = get() as Item;
/**
* Update the states
*/
set(...args);
type Item = { [key: string]: unknown };
/**
* Get the fresh states
*/
const updated = get() as Item;
/**
* Get the state to send
* Get the states that changed
*/
const state = args.reduce((obj, item) => (obj = { ...obj, ...(item as Item) }), {} as Item);
const state = Object.entries(updated).reduce((obj, [key, val]) => {
if (previous[key] !== val) {
obj = { ...obj, [key]: val };
}
return obj;
}, {} as Item);
/**
* Send the state to all the other tabs
* Send the states to all the other tabs
*/

@@ -99,3 +117,3 @@ channel.postMessage(state);

*/
const state = Object.entries(get() as s).reduce((obj, [key, val]) => {
const state = Object.entries(get() as Item).reduce((obj, [key, val]) => {
if (typeof val !== 'function' && typeof val !== 'symbol') {

@@ -102,0 +120,0 @@ obj = { ...obj, [key]: val };

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc