New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@codescouts/store

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codescouts/store - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

lib/auto-create.d.ts

1

lib/index.d.ts
export * from "./store";
export * from "./store.types";
//# sourceMappingURL=index.d.ts.map

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

__exportStar(require("./store"), exports);
__exportStar(require("./store.types"), exports);
//# sourceMappingURL=index.js.map
import { StateCreator } from "zustand";
export declare const create: <T extends object, Mos extends [keyof import("zustand").StoreMutators<unknown, unknown>, unknown][] = []>(stateCreator: StateCreator<T, [], Mos, T>) => {
import { Factory, Newly, Return } from "./store.types";
export declare const create: <T extends unknown, Mos extends [keyof import("zustand").StoreMutators<unknown, unknown>, unknown][] = []>(stateCreator: StateCreator<T, [], Mos, T>) => {
build: () => import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<T>, "setState"> & {
setState(partial: T | Partial<T> | ((state: T) => T | Partial<T>), replace?: boolean | undefined, actionType?: string | {
setState<A extends string | {
type: unknown;
} | undefined): void;
}>(partial: T | Partial<T> | ((state: T) => T | Partial<T>), replace?: boolean | undefined, action?: A | undefined): void;
}>;
withPersist: (entityType: any) => {
build: () => import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<T>, "setState"> & {
setState(partial: T | Partial<T> | ((state: T) => T | Partial<T>), replace?: boolean | undefined, actionType?: string | {
type: unknown;
} | undefined): void;
}>;
withPersist: {
<E>(entityType: string | Newly<E>, factory: Factory): Return<T>;
<E_1>(entityType: Newly<E_1>): Return<T>;
};
};
//# sourceMappingURL=store.d.ts.map

@@ -1,2 +0,3 @@

export declare const merge: <StateType, E>(EntityType: E, persistedState: any, currentState: StateType) => StateType;
import { Factory } from "./store.types";
export declare const merge: <StateType, E>(persistedState: any, currentState: StateType, EntityType: E, factory?: Factory) => StateType;
//# sourceMappingURL=store.extensions.d.ts.map

@@ -15,12 +15,16 @@ "use strict";

exports.merge = void 0;
var init = function (ctor, props) {
return Object.assign(new ctor(), props);
var auto_create_1 = require("./auto-create");
var reflectiveConstructor = function (persistedEntity, EntityType) {
return Array.isArray(persistedEntity)
? persistedEntity.map(function (entity) { return (0, auto_create_1.create)(EntityType, entity); })
: (0, auto_create_1.create)(EntityType, persistedEntity);
};
var merge = function (EntityType, persistedState, currentState) {
var merge = function (persistedState, currentState, EntityType, factory) {
var _a;
var entityKey = Object.keys(persistedState)[0];
var persistedEntity = persistedState[entityKey];
var entityData = Array.isArray(persistedEntity)
? persistedEntity.map(function (entity) { return init(EntityType, entity); })
: init(EntityType, persistedEntity);
var factoryImpl = !!factory ?
function () { return factory(persistedEntity, Object.assign); } :
function () { return reflectiveConstructor(persistedEntity, EntityType); };
var entityData = factoryImpl();
var state = (_a = {},

@@ -27,0 +31,0 @@ _a[entityKey] = entityData,

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.create = void 0;
var zustand_1 = __importDefault(require("zustand"));
var zustand_1 = require("zustand");
var middleware_1 = require("zustand/middleware");

@@ -14,4 +11,5 @@ var store_extensions_1 = require("./store.extensions");

entityType: undefined,
factory: undefined
};
var store = (0, zustand_1.default)();
var store = (0, zustand_1.create)();
var build = function () {

@@ -24,4 +22,4 @@ var withPersist = configuration.withPersist, entityType = configuration.entityType;

merge: function (persistedState, currentState) {
return (0, store_extensions_1.merge)(entityType, persistedState, currentState);
},
return (0, store_extensions_1.merge)(persistedState, currentState, configuration.entityType, configuration.factory);
}
})));

@@ -31,7 +29,9 @@ }

};
var withPersist = function (entityType) {
function withPersist(entityType, factory) {
configuration.entityType = entityType;
configuration.withPersist = true;
configuration.factory = factory;
return { build: build };
};
}
;
return {

@@ -38,0 +38,0 @@ build: build,

@@ -1,7 +0,14 @@

import { State } from "zustand";
export declare type SetState<T extends State> = {
export declare type SetState<T extends unknown> = {
_(partial: T | Partial<T> | ((state: T) => T | Partial<T>)): void;
}["_"];
export declare type GetState<T extends State> = () => T;
export declare type GetState<T extends unknown> = () => T;
export declare type Destroy = () => void;
export type Factory = (persistedEntity: any, assign: <T extends {}, U>(target: T, source: U) => T & U) => unknown;
export type Newly<T> = {
new (...args: any[]): T;
};
export type Creator<T> = () => T;
export type Return<T> = {
build: () => Creator<T>;
};
//# sourceMappingURL=store.types.d.ts.map
{
"name": "@codescouts/store",
"version": "1.0.1",
"version": "1.0.2",
"main": "./lib/index.js",

@@ -14,5 +14,5 @@ "types": "./lib/index.d.ts",

"dependencies": {
"zustand": "^4.0.0-rc.1",
"zustand": "^4.3.6",
"typescript": "^4.6.4"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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