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

deep-storage

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deep-storage - npm Package Compare versions

Comparing version 1.0.10 to 1.0.11

30

async.d.ts

@@ -8,4 +8,9 @@ import { DeepStorage, UsesDeepStorage } from "./index";

}
export interface DeepAsyncData<Request, Response> {
export interface DeepAsyncState<Request, Response> {
status: AsyncStatus;
request?: Request;
response?: Response;
error?: any;
}
export interface DeepAsync<Request, Response> extends DeepAsyncState<Request, Response>, UsesDeepStorage<DeepAsyncState<Request, Response>> {
completed: boolean;

@@ -16,20 +21,15 @@ succeeded: boolean;

failed: boolean;
request?: Request;
response?: Response;
error?: any;
run(request: Request): Promise<DeepAsyncState<Request, Response>>;
rerun(): Promise<DeepAsyncState<Request, Response>>;
updateResponse(updater: (prevState: Response) => Response): Promise<DeepAsyncState<Request, Response>>;
}
export interface DeepAsync<Request, Response> extends DeepAsyncData<Request, Response>, UsesDeepStorage<DeepAsyncData<Request, Response>> {
run(request: Request): Promise<DeepAsyncData<Request, Response>>;
rerun(): Promise<DeepAsyncData<Request, Response>>;
update(response: Response): Promise<DeepAsyncData<Request, Response>>;
}
export declare class AlreadyRunningError extends Error {
}
export declare class DefaultDeepAsync<Request, Response> implements DeepAsync<Request, Response> {
storage: DeepStorage<DeepAsyncData<Request, Response>>;
storage: DeepStorage<DeepAsyncState<Request, Response>>;
process: (request: Request) => Promise<Response>;
constructor(storage: DeepStorage<DeepAsyncData<Request, Response>>, process: (request: Request) => Promise<Response>);
run: (request: Request) => Promise<DeepAsyncData<Request, Response>>;
rerun: () => Promise<DeepAsyncData<Request, Response>>;
update: (response: Response) => Promise<DeepAsyncData<Request, Response>>;
constructor(storage: DeepStorage<DeepAsyncState<Request, Response>>, process: (request: Request) => Promise<Response>);
run: (request: Request) => Promise<DeepAsyncState<Request, Response>>;
rerun: () => Promise<DeepAsyncState<Request, Response>>;
updateResponse: (updater: (prevState: Response) => Response) => Promise<DeepAsyncState<Request, Response>>;
readonly status: AsyncStatus;

@@ -45,3 +45,3 @@ readonly running: boolean;

}
export declare const deepAsync: <Request, Response>(storage: DeepStorage<DeepAsyncData<Request, Response>, {}>, process: (request: Request) => Promise<Response>) => DefaultDeepAsync<Request, Response>;
export declare const deepAsync: <Request, Response>(storage: DeepStorage<DeepAsyncState<Request, Response>, {}>, process: (request: Request) => Promise<Response>) => Promise<DefaultDeepAsync<Request, Response>>;
export default deepAsync;

@@ -17,2 +17,7 @@ export * from './async';

/**
* sets a value in deep storage and notifies subscribers. shortcut for
* update where the old value is ignored
*/
set: (newValue: State) => Promise<State>;
/**
* Updates the whole state and notifies subscribers

@@ -96,2 +101,3 @@ */

updateProperty: <Key extends keyof State>(key: Key, callback: (s: State[Key]) => State[Key]) => Promise<State[Key]>;
set: (newValue: State) => Promise<State>;
setIn: (...path: (string | number)[]) => <DeepState>(newValue: DeepState) => Promise<DeepState>;

@@ -122,2 +128,3 @@ merge: (partial: {

setIn: (...path: (string | number)[]) => <DeepState>(newValue: DeepState) => Promise<DeepState>;
set: (newValue: State) => Promise<State>;
update: (callback: (s: State) => State) => Promise<State>;

@@ -124,0 +131,0 @@ updateIn: (...path: (string | number)[]) => <DeepState>(callback: (s: DeepState) => DeepState) => Promise<DeepState>;

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

};
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -111,6 +112,8 @@ var AsyncStatus;

};
this.update = function (response) { return __awaiter(_this, void 0, void 0, function () {
this.updateResponse = function (updater) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.storage.update(function (state) { return (__assign({}, state, { status: AsyncStatus.Succeeded, response: response, error: undefined })); })];
case 0: return [4 /*yield*/, this.storage.update(function (state) {
return (__assign({}, state, { status: AsyncStatus.Succeeded, response: updater(state.response), error: undefined }));
})];
case 1:

@@ -174,6 +177,15 @@ _a.sent();

exports.DefaultDeepAsync = DefaultDeepAsync;
exports.deepAsync = function (storage, process) {
return new DefaultDeepAsync(storage, process);
};
exports.deepAsync = function (storage, process) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, storage.set({
status: AsyncStatus.Created
})];
case 1:
_a.sent();
return [2 /*return*/, new DefaultDeepAsync(storage, process)];
}
});
}); };
exports.default = exports.deepAsync;
//# sourceMappingURL=async.js.map

@@ -74,2 +74,5 @@ "use strict";

};
this.set = function (newValue) {
return _this.updateIn()(function () { return newValue; });
};
this.setIn = function () {

@@ -231,2 +234,6 @@ var path = [];

};
this.set = function (newValue) {
return (_a = _this.rootStorage).setIn.apply(_a, _this.path)(newValue);
var _a;
};
this.update = function (callback) {

@@ -233,0 +240,0 @@ return (_a = _this.rootStorage).updateIn.apply(_a, _this.path)(callback);

{
"name": "deep-storage",
"version": "1.0.10",
"version": "1.0.11",
"description": "Simple observable state management for reactive applications",

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

@@ -12,7 +12,2 @@ import { DeepStorage, UsesDeepStorage } from "./index";

status: AsyncStatus;
completed: boolean;
succeeded: boolean;
running: boolean;
started: boolean;
failed: boolean;
request?: Request;

@@ -26,2 +21,7 @@ response?: Response;

UsesDeepStorage<DeepAsyncState<Request, Response>> {
completed: boolean;
succeeded: boolean;
running: boolean;
started: boolean;
failed: boolean;
run(request: Request): Promise<DeepAsyncState<Request, Response>>;

@@ -58,3 +58,10 @@ rerun(): Promise<DeepAsyncState<Request, Response>>;

updateResponse = async (updater: (prevState: Response) => Response): Promise<DeepAsyncState<Request, Response>> => {
await this.storage.update((state: DeepAsyncState<Request, Response>) => ({ ...state, status: AsyncStatus.Succeeded, updater(state.response), error: undefined }));
await this.storage.update(
(state: DeepAsyncState<Request, Response>) =>
({
...state,
status: AsyncStatus.Succeeded,
response: updater(state.response),
error: undefined
}));
return this.storage.state;

@@ -78,4 +85,3 @@ }

await storage.set({
status: AsyncStatus.Created,
status: AsyncStatus.Created
});

@@ -82,0 +88,0 @@ return new DefaultDeepAsync(storage, process);

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