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

patronum

Package Overview
Dependencies
Maintainers
1
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

patronum - npm Package Compare versions

Comparing version 0.9.0 to 0.10.0

spread/readme.md

2

package.json
{
"name": "patronum",
"version": "0.9.0",
"version": "0.10.0",
"description": "☄️ Effector utility library delivering modularity and convenience",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -13,2 +13,3 @@ # effecto patronum ✨

- [Delay](#-delay)
- [Spread](#-spread)
- [Status](#-status)

@@ -20,3 +21,2 @@ - [Throttle](#-throttle)

- [Reshape](#-reshape)
- [Spread](#-spread)
- [SplitMap](#-splitmap)

@@ -167,2 +167,26 @@

## [🧁 Spread](/spread 'Documentation')
```ts
import { createEvent, createStore } from 'effector';
import { spread } from 'patronum/spread';
const trigger = createEvent<{ first: string; second: string }>();
const $first = createStore('');
const $second = createStore('');
spread(trigger, {
first: $first,
second: $second,
});
trigger({ first: 'Hello', second: 'World' });
$first.getState(); // "Hello"
$second.getState(); // "World"
```
---
## [🍰 Reshape](/reshape 'Documentation')

@@ -189,28 +213,2 @@

## [🍰 Spread](/spread 'Documentation')
> No tests yet
> No readme yet
```ts
import { createEvent, createStore } from 'effector';
import { spread } from 'patronum/spread';
const trigger = createEvent<{ first: string; second: string }>();
const $first = createStore('');
const $second = createStore('');
spread(trigger, {
first: $first,
second: $second,
});
trigger({ first: 'Hello', second: 'World' });
$first.getState(); // "Hello"
$second.getState(); // "World"
```
## [🍰 SplitMap](/splitmap 'Documentation')

@@ -217,0 +215,0 @@

import {} from 'effector';
// TODO: should be typed
export function spread(source: any, cases: any): void;
export function spread(cases: any): void;
/* eslint-disable no-param-reassign */
const { createEvent, sample } = require('effector');
const { createEvent, sample, guard } = require('effector');
function spread(source, target) {
if (target === undefined) {
target = source;
/**
* @examle
* spread(dataObject, { first: targetA, second: targetB })
* forward({
* to: spread({ first: targetA, second: targetB })
* })
*/
function spread(source, targetCases) {
if (targetCases === undefined) {
targetCases = source;
source = createEvent();
}
for (const key in target) {
if (key in target) {
for (const key in targetCases) {
if (key in targetCases) {
const correctKey = guard(source, {
filter: (data) =>
typeof data === 'object' && data !== null && key in data,
});
sample({
source,
source: correctKey,
fn: (data) => data[key],
target: target[key],
target: targetCases[key],
});

@@ -16,0 +28,0 @@ }

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