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

storeon

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

storeon - npm Package Compare versions

Comparing version 0.7.0 to 0.8.0

devtools/logger.browser.d.ts

6

CHANGELOG.md
# Change Log
This project adheres to [Semantic Versioning](http://semver.org/).
## 0.8
* Add `Symbol` support for store keys and event names (by Vlad Rindevich).
* Fix `async`/`await` support (by Vlad Rindevich).
* Fix TypeScript definitions (by Vlad Rindevich).
* Reduce size (by Vlad Rindevich).
## 0.7

@@ -5,0 +11,0 @@ * Move event typo check to `devtools`.

9

devtools/index.d.ts

@@ -1,5 +0,8 @@

import { Module } from "..";
import {Store} from '..';
declare const devtool: Module<any>;
declare const devtools: {
<State>(store: Store<State>): void;
(): <State>(store: Store<State>) => void;
};
export default devtool;
export = devtools;

@@ -43,3 +43,3 @@ /**

store.on('@dispatch', function (state, data) {
var event = data[0]
var event = String(data[0])
if (event !== 'UPDATE_FROM_DEVTOOLS' && prev !== 'UPDATE_FROM_DEVTOOLS') {

@@ -46,0 +46,0 @@ if (event[0] !== '@' && (!data[2] || data[2].length === 0)) {

@@ -10,7 +10,7 @@ var STYLE = 'color: #008100'

} else if (data[1]) {
console.log('%caction %c' + data[0], STYLE, BOLD, data[1])
console.log('%caction %c' + String(data[0]), STYLE, BOLD, data[1])
} else {
console.log('%caction %c' + data[0], STYLE, BOLD)
console.log('%caction %c' + String(data[0]), STYLE, BOLD)
}
})
}
import { Module } from "..";
declare const logger: Module<any>;
declare const logger: Module<unknown>;
export default logger;
export = logger;

@@ -21,7 +21,7 @@ /**

} else if (data[1]) {
console.log('action ' + data[0], data[1])
console.log('action ' + String(data[0]), data[1])
} else {
console.log('action ' + data[0])
console.log('action ' + String(data[0]))
}
})
}

@@ -1,18 +0,20 @@

export type Dispatch = {
(event: string, data?: any): void;
};
declare namespace createStore {
export type Dispatch = (event: PropertyKey, data?: unknown) => void;
export interface Store<T> {
on: (
event: string,
handler: (state: Readonly<T>, data: any) => Partial<T> | null
) => () => void;
dispatch: Dispatch;
get: () => T;
export interface Store<State = unknown> {
readonly on: (
event: PropertyKey,
handler: (state: Readonly<State>, data: unknown) => Partial<State> | Promise<void> | null
) => () => void;
readonly dispatch: Dispatch;
readonly get: () => State;
}
export type Module<State> = (store: Store<State>) => void;
}
export type Module<T> = false | { (store: Store<T>): void };
declare function createStore<State>(
modules: Array<createStore.Module<State> | false>
): createStore.Store<State>;
declare function createStore<T>(modules: Array<Module<T>>): Store<T>;
export default createStore;
export = createStore;

@@ -45,9 +45,8 @@ /**

var changes = { }
var changed, key
var changed
events[event].forEach(function (i) {
var diff = i(state, data)
if (diff) {
changed = { }
for (key in state) changed[key] = state[key]
for (key in diff) changed[key] = changes[key] = diff[key]
if (diff && typeof diff.then !== 'function') {
changed = Object.assign({ }, state, diff)
Object.assign(changes, diff)
state = changed

@@ -54,0 +53,0 @@ }

{
"name": "storeon",
"version": "0.7.0",
"description": "Tiny (174 bytes) event-based Redux-like state manager for React and Preact",
"version": "0.8.0",
"description": "Tiny (173 bytes) event-based Redux-like state manager for React and Preact",
"keywords": [

@@ -6,0 +6,0 @@ "state",

import { AnyComponent, FunctionalComponent } from "preact";
import { Dispatch, Store } from "..";
declare namespace connect {
export type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
// Removes dispatch from the props requirements and mark everything else optional
export type ConnectedComponent<ComponentProps> = FunctionalComponent<
Partial<Omit<ComponentProps, "dispatch">>
>;
}
type MapStateToProps<T> = {
(store: any): T;
};
// Removes dispatch from the props requirements and mark everything else optional
type ConnectedComponent<ComponentProps> = FunctionalComponent<
Partial<Omit<ComponentProps, "dispatch">>
>;
// As the number of keys is indefinite and keys are not inferrable as types,
// it is upto the user to have the component as last parameter
export default function connect<ComponentProps>(
...keysORcomponent: Array<string | AnyComponent<ComponentProps>>
): ConnectedComponent<ComponentProps>;
declare function connect<ComponentProps>(
...keysOrComponent: Array<PropertyKey | AnyComponent<ComponentProps>>
): connect.ConnectedComponent<ComponentProps>;
export = connect
import { PreactContext } from "preact";
import { Store } from "..";
declare const StoreContext: PreactContext<Store<any>>;
declare const StoreContext: PreactContext<Store>;
export default StoreContext;
export = StoreContext;
import { Dispatch } from "..";
type StoreData = {
dispatch: Dispatch;
[x: string]: any;
};
declare namespace useStoreon {
export type StoreData<State extends object = {}> = {
dispatch: Dispatch;
} & State
}
declare function useStoreon(...keys: string[]): StoreData;
declare function useStoreon<State extends object = {}>(
...keys: (keyof State)[]
): useStoreon.StoreData<State>;
export default useStoreon;
export = useStoreon;
import { ComponentType, FunctionComponent } from "react";
import { Dispatch, Store } from "..";
declare namespace connect {
export type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
// Removes dispatch from the props requirements and mark everything else optional
export type ConnectedComponent<ComponentProps> = FunctionComponent<
Partial<Omit<ComponentProps, "dispatch">>
>;
}
type MapStateToProps<T> = {
(store: any): T;
};
// Removes dispatch from the props requirements and mark everything else optional
type ConnectedComponent<ComponentProps> = FunctionComponent<
Partial<Omit<ComponentProps, "dispatch">>
>;
// As the number of keys is indefinite and keys are not inferrable as types,
// it is upto the user to have the component as last parameter
export default function connect<ComponentProps>(
...keysORcomponent: Array<string | ComponentType<ComponentProps>>
): ConnectedComponent<ComponentProps>;
declare function connect<ComponentProps>(
...keysOrComponent: Array<PropertyKey | ComponentType<ComponentProps>>
): connect.ConnectedComponent<ComponentProps>;
export = connect;

@@ -30,8 +30,5 @@ var React = require('react')

return function (originProps) {
var props = useStoreon.apply(null, keys)
for (var i in originProps) {
if (!(i in props)) props[i] = originProps[i]
}
var props = Object.assign({ }, originProps, useStoreon.apply(null, keys))
return React.createElement(Component, props)
}
}
import { Context } from "react";
import { Store } from "..";
declare const StoreContext: Context<Store<any>>;
declare const StoreContext: Context<Store>;
export default StoreContext;
export = StoreContext;

@@ -1,10 +0,13 @@

import { Dispatch } from "..";
import {Dispatch} from '..'
type StoreData = {
dispatch: Dispatch;
[x: string]: any;
};
declare namespace useStoreon {
export type StoreData<State extends object = {}> = {
dispatch: Dispatch;
} & State
}
declare function useStoreon(...keys: string[]): StoreData;
declare function useStoreon<State extends object = {}>(
...keys: (keyof State)[]
): useStoreon.StoreData<State>;
export default useStoreon;
export = useStoreon;

@@ -5,7 +5,7 @@ # Storeon

* **Small.** 174 bytes (minified and gzipped). No dependencies.
* **Small.** 173 bytes (minified and gzipped). No dependencies.
It uses [Size Limit] to control size.
* **Fast.** It tracks what parts of state were changed and re-renders
only components based on the changes.
* **Hooks.** The same Redux reducers. Now with hooks for **React/Preact**.
* **Hooks.** The same Redux reducers. With hooks for **React** and **Preact**.
* **Modular.** API created to move business logic away from React components.

@@ -62,2 +62,11 @@

If you need to support IE, add [`Object.assign`] polyfill to your bundle.
You should have this polyfill already if you are using React.
```js
Object.assign = require('object-assign')
```
[`Object.assign`]: https://www.npmjs.com/package/object-assign
## Store

@@ -169,3 +178,2 @@

## Components

@@ -172,0 +180,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