Socket
Socket
Sign inDemoInstall

zustand-fetching

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zustand-fetching - npm Package Compare versions

Comparing version 1.1.2 to 1.1.3

dist/examples/common.d.ts

9

dist/helpers/zustandGroupSlice.d.ts

@@ -10,9 +10,6 @@ import { StoreApi } from "zustand";

call: (params: IGroupRequestParams<Payload>[]) => void;
get: (key?: string) => void;
getContent: (key: string) => void;
get: (key: string) => ICreateRequest<IGroupRequestParams<Payload>, Result> | undefined;
getContent: (key: string) => Result | undefined | null;
clear: (key?: string) => void;
}
export declare const createGroupSlice: <Payload, Result, State extends Record<string, any>, K extends keyof State>(set: (partial: State | Partial<State> | ((state: State) => State | Partial<State>), replace?: boolean | undefined) => void, get: () => State, name: K, payloadCreator: (params: {
key: string;
payload: Payload;
}) => Promise<Result>, extraArgument?: IExtraReaction<IGroupRequestParams<Payload>, Result> | undefined) => Record<K, ICreateGroupRequests<Payload, Result>>;
export declare const createGroupSlice: <Payload, Result, State extends Record<string, any>, K extends keyof State>(set: (partial: State | Partial<State> | ((state: State) => State | Partial<State>), replace?: boolean | undefined) => void, get: () => State, name: K, payloadCreator: (params: IGroupRequestParams<Payload>) => Promise<Result>, extraArgument?: IExtraReaction<IGroupRequestParams<Payload>, Result> | undefined) => Record<K, ICreateGroupRequests<Payload, Result>>;

@@ -63,3 +63,4 @@ import { createRequest } from "./zustandSlice";

const getContent = (key) => {
return get()[name].requests[key].atom.content;
var _a;
return (_a = get()[name].requests[key]) === null || _a === void 0 ? void 0 : _a.atom.content;
};

@@ -66,0 +67,0 @@ return {

@@ -26,3 +26,3 @@ import { StoreApi } from "zustand";

reaction?: ((params: IModalActionType<Data, M>) => any) | undefined;
clearOnClose?: boolean | undefined;
doNotClearOnClose?: boolean | undefined;
} | undefined) => IModalCreator<Data, M>;

@@ -49,3 +49,3 @@ /**

reaction?: ((params: IModalActionType<Data, M>) => any) | undefined;
clearOnClose?: boolean | undefined;
doNotClearOnClose?: boolean | undefined;
} | undefined) => Record<K, IModalCreator<Data, M>>;

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

/* eslint-disable @typescript-eslint/no-explicit-any */
export const modalCreator = (initialState, set, get, extra) => {

@@ -8,3 +7,3 @@ const action = (params) => {

isOpen: false,
data: (extra === null || extra === void 0 ? void 0 : extra.clearOnClose) ? initialState : get().data,
data: (extra === null || extra === void 0 ? void 0 : extra.doNotClearOnClose) ? get().data : initialState,
});

@@ -19,6 +18,13 @@ }

else if (params.type === "TOGGLE") {
set({ isOpen: !get().isOpen });
set({
isOpen: !get().isOpen,
data: !get().isOpen
? (extra === null || extra === void 0 ? void 0 : extra.doNotClearOnClose)
? get().data
: initialState
: get().data,
});
}
else if (params.type === "SET_DATA") {
set({ data: params.payload });
set({ isOpen: get().isOpen, data: params.payload });
}

@@ -25,0 +31,0 @@ (_a = extra === null || extra === void 0 ? void 0 : extra.reaction) === null || _a === void 0 ? void 0 : _a.call(extra, params);

@@ -34,3 +34,3 @@ import { nanoid } from "nanoid";

},
rejectedReaction: (params, error, fetchError) => {
rejectedReaction: (params, error) => {
var _a, _b, _c;

@@ -41,9 +41,8 @@ const state = get();

content: ((_a = extra === null || extra === void 0 ? void 0 : extra.contentReducers) === null || _a === void 0 ? void 0 : _a.rejected)
? (_b = extra.contentReducers) === null || _b === void 0 ? void 0 : _b.rejected(params, error, fetchError)
? (_b = extra.contentReducers) === null || _b === void 0 ? void 0 : _b.rejected(params, error)
: state.content,
status: "error",
error,
fetchError,
});
(_c = extra === null || extra === void 0 ? void 0 : extra.rejectedReaction) === null || _c === void 0 ? void 0 : _c.call(extra, params, error, fetchError);
(_c = extra === null || extra === void 0 ? void 0 : extra.rejectedReaction) === null || _c === void 0 ? void 0 : _c.call(extra, params, error);
},

@@ -59,4 +58,3 @@ abortReaction: (params) => {

status: (extra === null || extra === void 0 ? void 0 : extra.initialStatus) || "loading",
error: null,
fetchError: undefined,
error: undefined,
});

@@ -106,15 +104,8 @@ (_b = extra === null || extra === void 0 ? void 0 : extra.abortReaction) === null || _b === void 0 ? void 0 : _b.call(extra, params);

.catch((error) => {
var _a, _b, _c, _d;
if (error instanceof FetchError &&
error.message === "The user aborted a request.") {
var _a, _b;
if (error.message === "The user aborted a request.") {
(_a = extra === null || extra === void 0 ? void 0 : extra.abortReaction) === null || _a === void 0 ? void 0 : _a.call(extra, params);
}
else if (error instanceof FetchError) {
(_b = extra === null || extra === void 0 ? void 0 : extra.rejectedReaction) === null || _b === void 0 ? void 0 : _b.call(extra, params, error.message, error);
}
else if (error instanceof Error) {
(_c = extra === null || extra === void 0 ? void 0 : extra.rejectedReaction) === null || _c === void 0 ? void 0 : _c.call(extra, params, error.message);
}
else {
(_d = extra === null || extra === void 0 ? void 0 : extra.rejectedReaction) === null || _d === void 0 ? void 0 : _d.call(extra, params, "Unknown Failure");
(_b = extra === null || extra === void 0 ? void 0 : extra.rejectedReaction) === null || _b === void 0 ? void 0 : _b.call(extra, params, error);
}

@@ -121,0 +112,0 @@ })

@@ -0,4 +1,9 @@

export * from "./helpers/resettableStore";
export * from "./helpers/zustandContextStore";
export * from "./helpers/zustandGroupSlice";
export * from "./helpers/zustandList";
export * from "./helpers/zustandModal";
export * from "./helpers/zustandNormalizedList";
export * from "./helpers/zustandPrimitive";
export * from "./helpers/zustandSlice";
export * from "./interfaces/ContentLoading";

@@ -0,4 +1,9 @@

export * from "./helpers/resettableStore";
export * from "./helpers/zustandContextStore";
export * from "./helpers/zustandGroupSlice";
export * from "./helpers/zustandList";
export * from "./helpers/zustandModal";
export * from "./helpers/zustandNormalizedList";
export * from "./helpers/zustandPrimitive";
export * from "./helpers/zustandSlice";
export * from "./interfaces/ContentLoading";

@@ -6,5 +6,5 @@ export type ILoadingStatus = "init" | "loading" | "loaded" | "waiting" | "progress" | "error";

error?: any;
lastFetchTime: Date | null;
payload?: Payload | null;
requestId?: string;
}
export declare const initialContentLoading: <Content, Payload>(value: Content | null, initialStatus?: ILoadingStatus) => ContentLoading<Content, Payload>;

@@ -7,3 +7,3 @@ /* eslint-disable @typescript-eslint/no-explicit-any */

payload: undefined,
lastFetchTime: null,
requestId: undefined,
});
{
"name": "zustand-fetching",
"version": "1.1.2",
"version": "1.1.3",
"private": false,

@@ -5,0 +5,0 @@ "description": "Zustand fetching helpers",

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