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

state-local

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

state-local - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

5

CHANGELOG.md
### Versions
## 1.0.7
###### *Jan 7, 2021*
- package: add jsdelivr source path
## 1.0.6

@@ -4,0 +9,0 @@ ###### *Jan 3, 2021*

5

package.json
{
"name": "state-local",
"version": "1.0.6",
"version": "1.0.7",
"description": "Tiny, simple, and robust technique for defining and acting with local states",
"main": "lib/cjs/state-local.js",
"module": "lib/es/state-local.js",
"unpkg": "lib/umd/state-local.js",
"unpkg": "lib/umd/state-local.min.js",
"jsdelivr": "lib/umd/state-local.min.js",
"types": "lib/types.d.ts",

@@ -9,0 +10,0 @@ "author": "Suren Atoyan <contact@surenatoyan.com>",

40

README.md

@@ -149,7 +149,9 @@ # State &middot; [![monthly downloads](https://img.shields.io/npm/dm/state-local)](https://www.npmjs.com/package/state-local) [![gitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/suren-atoyan/state-local/blob/master/LICENSE) [![Rate on Openbase](https://badges.openbase.io/js/rating/state-local.svg)](https://openbase.io/js/state-local?utm_source=embedded&utm_medium=badge&utm_campaign=rate-badge) [![build size](https://img.shields.io/bundlephobia/minzip/state-local)](https://bundlephobia.com/result?p=state-local) [![npm version](https://img.shields.io/npm/v/state-local.svg?style=flat)](https://www.npmjs.com/package/state-local) [![PRs welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/suren-atoyan/state-local/pulls)

There is a named export `create` in this library, which is supposed to be a function to create a state:
The default export has a method called `create`, which is supposed to be a function to create a state:
```javascript
import { create as createState } from 'state-local';
import state from 'state-local';
// state.create
// ...

@@ -170,11 +172,11 @@ ```

```javascript
import { create as createState } from 'state-local';
import state from 'state-local';
/*
const [getState, setState] = createState(); // ❌ error - initial state is required
const [getState, setState] = createState(5); // ❌ error - initial state should be an object
const [getState, setState] = createState({}); // ❌ error - initial state shouldn\'t be an empty object
const [getState, setState] = state.create(); // ❌ error - initial state is required
const [getState, setState] = state.create(5); // ❌ error - initial state should be an object
const [getState, setState] = state.create({}); // ❌ error - initial state shouldn\'t be an empty object
*/
const [getState, setState] = createState({ isLoading: false, payload: null }); // ✅
const [getState, setState] = state.create({ isLoading: false, payload: null }); // ✅
// ...

@@ -196,5 +198,5 @@ ```

```javascript
import { create as createState } from 'state-local';
import state from 'state-local';
const [getState, setState] = createState({ x: 2, y: 3, z: 5 }, handleStateUpdate /* will be called immediately after every state update */);
const [getState, setState] = state.create({ x: 2, y: 3, z: 5 }, handleStateUpdate /* will be called immediately after every state update */);

@@ -213,5 +215,5 @@ function handleStateUpdate(latestState) {

```javascript
import { create as createState } from 'state-local';
import state from 'state-local';
const [getState, setState] = createState({ x: 2, y: 3, z: 5 }, {
const [getState, setState] = state.create({ x: 2, y: 3, z: 5 }, {
x: handleXUpdate, // will be called immediately after every "x" update

@@ -241,5 +243,5 @@ y: handleYUpdate, // will be called immediately after every "y" update

```javascript
import { create as createState } from "state-local";
import state from "state-local";
const [getState, setState] = createState({ p1: 509, p2: 521 });
const [getState, setState] = state.create({ p1: 509, p2: 521 });

@@ -264,5 +266,5 @@ const state = getState();

```javascript
import { create as createState } from 'state-local';
import state from 'state-local';
const [getState, setState] = createState({ p1: 389, p2: 397, p3: 401 });
const [getState, setState] = state.create({ p1: 389, p2: 397, p3: 401 });

@@ -286,5 +288,5 @@ function someFn() {

```javascript
import { create as createState } from 'state-local';
import state from 'state-local';
const [getState, setState] = createState({ x:0, y: 0 });
const [getState, setState] = state.create({ x:0, y: 0 });

@@ -303,5 +305,5 @@ setState({ z: 'some value' }); // ❌ error - it seams you want to change a field in the state which is not specified in the "initial" state

```javascript
import { create as createState } from 'state-local';
import state from 'state-local';
const [getState, setState] = createState({ x:0, y: 0 });
const [getState, setState] = state.create({ x:0, y: 0 });

@@ -308,0 +310,0 @@ setState(state => ({ x: state.x + 2 })); // ✅ ok

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