Socket
Socket
Sign inDemoInstall

zustand-store

Package Overview
Dependencies
9
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.1 to 0.0.2

33

dist/store.js

@@ -45,2 +45,3 @@ "use strict";

}
return ret;
};

@@ -67,3 +68,14 @@ };

loopPrototype(ret, function (key, proto) {
ret[key] = proto[key];
var descriptor = Object.getOwnPropertyDescriptor(proto, key);
if (!(descriptor === null || descriptor === void 0 ? void 0 : descriptor.get)) {
ret[key] = proto[key];
}
else {
Object.defineProperty(ret, key, {
enumerable: true,
get: function () {
return descriptor.get.call(this);
},
});
}
});

@@ -80,15 +92,18 @@ return ret;

var p = [];
for (; obj != null && obj !== Store.prototype; obj = Object.getPrototypeOf(obj)) {
var op = Object.getOwnPropertyNames(obj);
var proto = obj;
while (proto != null) {
proto = Object.getPrototypeOf(proto);
if (proto == null) {
break;
}
var op = Object.getOwnPropertyNames(proto);
for (var i = 0; i < op.length; i++) {
if (p.indexOf(op[i]) === -1) {
callback(op[i], obj);
callback(op[i], proto);
}
}
if (proto === BaseStore.prototype) {
break;
}
}
}
// export const useStore = Store.create(class A extends BaseStore<A> {})
// class User extends Store.BaseStore<User> {
// getName(){
// }
// }
{
"name": "zustand-store",
"version": "0.0.1",
"version": "0.0.2",
"description": "zustand store",

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

# zustand-store
> Made with create-react-library
[![NPM](https://img.shields.io/npm/v/zustand-store.svg)](https://www.npmjs.com/package/zustand-store) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
基于 zustand 封装的 `Store` 方案,支持 `class` 写法。
## Install

@@ -16,11 +16,11 @@

```tsx
import React from 'react'
import { useStore } from './store'
import React from 'react';
import { useStore } from './store';
const App = () => {
const store = useStore()
const store = useStore();
const onClick = () => {
store.updateTime(Date.now())
}
const isLoading = store.loading.updateTime
store.updateTime(Date.now());
};
const isLoading = store.loading.updateTime;

@@ -32,6 +32,6 @@ return (

</div>
)
}
);
};
export default App
export default App;
```

@@ -42,6 +42,6 @@

```tsx
import Store from 'zustand-store'
import Store from 'zustand-store';
class StoreClass extends Store.BaseStore<StoreClass> {
public time = Date.now()
public time = Date.now();

@@ -53,10 +53,10 @@ @Store.loading()

this.set((state) => {
state.time = time
})
resolve()
}, 2000)
})
state.time = time;
});
resolve();
}, 2000);
});
}
}
export const useStore = Store.create(StoreClass)
export const useStore = Store.create(StoreClass);
```

@@ -63,0 +63,0 @@

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc