@nemigo/storage 1.7.2 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
+ import type { IRuntimeStorageSetOptions } from "./runtime.js";
1
2
  import { RuntimeStorage } from "./runtime.js";
2
- import type { IStorageSetOptions } from "./types.js";
3
3
  export interface ConstructCapacityStorage {
4
4
  capacity: number;
5
5
  ttl_seconds?: number;
@@ -8,5 +8,5 @@ export declare class CapacityStorage extends RuntimeStorage {
8
8
  capacity: number;
9
9
  constructor({ capacity, ttl_seconds }: ConstructCapacityStorage);
10
10
  get<T = any>(key: string): T | undefined;
11
- set(key: string, value: any, options?: IStorageSetOptions): void;
11
+ set(key: string, value: any, options?: IRuntimeStorageSetOptions): void;
12
12
  }
package/dist/cookie.d.ts CHANGED
@@ -1,11 +1,16 @@
1
1
  import type { ConstructVeilPrefixStorage } from "./internal/veil-prefix.js";
2
2
  import { VeilPrefixStorage } from "./internal/veil-prefix.js";
3
- import type { IStorage, IStorageSetOptions, IStorageValue } from "./types.js";
3
+ import type { IStorage, IStorageValue } from "./types.js";
4
4
  import type { SetDocumentCookieOptions } from "@nemigo/helpers/html/cookie";
5
5
  /**
6
6
  * Опции для {@link CookieStorage.set}
7
7
  */
8
- export interface CookieStorageSetOptions extends SetDocumentCookieOptions, IStorageSetOptions {
8
+ export interface CookieStorageSetOptions extends SetDocumentCookieOptions {
9
+ /**
10
+ * - при `undefined` будет использован `ttl_seconds` хранилища
11
+ * - при `null` хранение будет точно сессионным!
12
+ */
13
+ ttl_seconds?: number | null;
9
14
  prefix?: string;
10
15
  }
11
16
  /**
@@ -32,9 +37,6 @@ export declare class CookieStorage extends VeilPrefixStorage implements IStorage
32
37
  __unveil<T>(value?: string | null): T | undefined;
33
38
  has(name: string): boolean;
34
39
  get<T extends IStorageValue>(name: string, prefix?: string): T | undefined;
35
- /**
36
- * @remarks `options.ttl_seconds === undefined` делает хранение сессионным!
37
- */
38
40
  set(name: string, value: IStorageValue, options?: CookieStorageSetOptions): void;
39
41
  delete(name: string, options?: CookieStorageDeleteOptions): void;
40
42
  /**
package/dist/cookie.js CHANGED
@@ -23,12 +23,11 @@ export class CookieStorage extends VeilPrefixStorage {
23
23
  const key = this.__toKey(name, prefix);
24
24
  return this.__unveil(isSSR ? this.__server.get(key) : getDocumentCookie(key));
25
25
  }
26
- /**
27
- * @remarks `options.ttl_seconds === undefined` делает хранение сессионным!
28
- */
29
26
  set(name, value, options = {}) {
30
- if (!isSSR)
31
- setDocumentCookie(this.__toKey(name, options.prefix), veil(value), { ...options, MaxAge: options.ttl_seconds });
27
+ if (isSSR)
28
+ return;
29
+ const MaxAge = options.ttl_seconds === null ? undefined : (options.ttl_seconds ?? options.ttl_seconds);
30
+ setDocumentCookie(this.__toKey(name, options.prefix), veil(value), { ...options, MaxAge });
32
31
  }
33
32
  delete(name, options = {}) {
34
33
  if (!isSSR)
@@ -1,5 +1,5 @@
1
- import type { IStorage } from "../types.js";
2
- import type { CanBePromise } from "@nemigo/helpers/types";
1
+ import type { IStorageSetOptions } from "../types.js";
2
+ import type { CanBePromise, Return } from "@nemigo/helpers/types";
3
3
  export interface VaultItem<PayloadData> {
4
4
  /**
5
5
  * Полезная нагрузка
@@ -18,21 +18,65 @@ export interface VaultItem<PayloadData> {
18
18
  */
19
19
  upd?: number;
20
20
  }
21
+ export interface IVaultStorage<PayloadData> {
22
+ get(key: string): CanBePromise<VaultItem<PayloadData> | undefined>;
23
+ set(name: string, value: VaultItem<PayloadData>, options?: IStorageSetOptions): CanBePromise;
24
+ }
21
25
  export interface VaultTimings {
22
26
  /**
23
- * Срок действия данных (в секундах). Если не задано — данные не устаревают
27
+ * Срок действия (дельта) данных в секундах
28
+ *
29
+ * - при `undefined` будет использован `exp` экземпляра
30
+ * - при `null` элементы точно не будут устаревать
31
+ */
32
+ exp?: number | null;
33
+ /**
34
+ * Минимальный интервал (дельта) до следующего обновления в секундах
35
+ *
36
+ * - при `undefined` будет использован `upd` экземпляра
37
+ * - при `null` обновление точно не разрешено в любой момент
38
+ */
39
+ upd?: number | null;
40
+ /**
41
+ * TTL (дельта) для хранилища в секундах
42
+ *
43
+ * - при `undefined` будет использован `ttl` экземпляра
44
+ * - при `null` хранилищу будет передан `undefined`
45
+ */
46
+ ttl?: number | null;
47
+ }
48
+ export interface InternalVaultTimings {
49
+ /**
50
+ * Срок действия (дельта) данных в секундах.
51
+ * Если не задано — данные не устаревают
24
52
  */
25
53
  exp?: number;
26
54
  /**
27
- * Минимальный интервал до следующего обновления (в секундах).
55
+ * Минимальный интервал (дельта) до следующего обновления в секундах.
28
56
  * Если не задано — обновление разрешено в любой момент
29
57
  */
30
58
  upd?: number;
31
59
  /**
32
- * TTL в хранилище (в секундах, дельта от текущего момента)
60
+ * TTL (дельта) для хранилища в секундах
33
61
  */
34
62
  ttl?: number;
35
63
  }
64
+ export interface VaultController<PayloadData> {
65
+ /**
66
+ * Функция генерации полезной нагрузки
67
+ */
68
+ generate: (timings: InternalVaultTimings, now_seconds: number) => CanBePromise<PayloadData>;
69
+ /**
70
+ * Функция сравнения двух полезных нагрузок на эквивалентность
71
+ */
72
+ equal: (a: PayloadData, b: PayloadData) => CanBePromise<boolean>;
73
+ }
74
+ export interface ConstructVault<PayloadData> extends InternalVaultTimings, VaultController<PayloadData> {
75
+ }
76
+ export type VaultCanBeUpdateResult<PayloadData> = {
77
+ item: VaultItem<PayloadData>;
78
+ ready: boolean;
79
+ } | null;
36
80
  export interface VaultRunOptions<PayloadData> extends VaultTimings {
37
81
  /**
38
82
  * Использовать иные данные вместо генерации
@@ -43,20 +87,27 @@ export interface VaultRunOptions<PayloadData> extends VaultTimings {
43
87
  */
44
88
  force?: boolean;
45
89
  }
46
- export interface ConstructVault<PayloadData> extends VaultTimings {
47
- /**
48
- * Функция генерации полезной нагрузки
49
- */
50
- generate: (delta: VaultTimings, now_seconds: number) => CanBePromise<PayloadData>;
51
- /**
52
- * Функция сравнения двух полезных нагрузок на эквивалентность
53
- */
54
- equal: (a: PayloadData, b: PayloadData) => CanBePromise<boolean>;
90
+ export interface VaultRunResult<PayloadData> extends VaultTimings {
91
+ generated: boolean;
92
+ item: VaultItem<PayloadData>;
55
93
  }
56
94
  /**
57
95
  * @example
58
96
  * ```typescript
59
- * export const codeVault = new Vault<string, RedisStorage>(redisStorage, {
97
+ * import { rand } from "@nemigo/helpers/random";
98
+ * import type { RedisStorage } from "@nemigo/server/redis";
99
+ * import { Vault } from "@nemigo/storage/derived/vault";
100
+ *
101
+ * declare const redisStorage: RedisStorage;
102
+ *
103
+ * export const redisCodeVault = new Vault<
104
+ * string,
105
+ * RedisStorage,
106
+ * {
107
+ * generate: () => string,
108
+ * equal: (a: string, b: string) => boolean,
109
+ * }
110
+ * >(redisStorage, {
60
111
  * generate: () => rand(),
61
112
  * equal: (a, b) => a === b,
62
113
  * exp: 60 * 10,
@@ -64,17 +115,31 @@ export interface ConstructVault<PayloadData> extends VaultTimings {
64
115
  * upd: 60,
65
116
  * });
66
117
  *
67
- * const result = await codeVault.run("some:key")
118
+ * // await redisCodeVault.run("some:key");
68
119
  * ```
69
120
  */
70
- export declare class Vault<PayloadData, Storage extends IStorage = IStorage> {
121
+ export declare class Vault<PayloadData, Storage extends IVaultStorage<PayloadData> = IVaultStorage<PayloadData>, Controller extends VaultController<PayloadData> = VaultController<PayloadData>> {
71
122
  storage: Storage;
72
- ctx: ConstructVault<PayloadData>;
73
- constructor(storage: Storage, ctx: ConstructVault<PayloadData>);
74
- find(key: string): CanBePromise<VaultItem<PayloadData> | undefined>;
75
- check(key: string, pld: PayloadData): Promise<boolean>;
76
- run(key: string, options?: VaultRunOptions<PayloadData>): Promise<{
77
- generate: boolean;
123
+ ctx: Controller & InternalVaultTimings;
124
+ constructor(storage: Storage, ctx: Controller & InternalVaultTimings);
125
+ timings(options?: VaultTimings): InternalVaultTimings;
126
+ __isExpired(item: VaultItem<PayloadData>, now_sec: number): boolean;
127
+ __check(existed: VaultItem<PayloadData> | undefined, pld: PayloadData): Return<Controller["equal"]>;
128
+ __async_check(existed: Promise<VaultItem<PayloadData> | undefined>, pld: PayloadData): Promise<boolean>;
129
+ check(key: string, pld: PayloadData): Return<Storage["get"]> extends Promise<any> ? Promise<boolean> : Return<Controller["equal"]>;
130
+ __isTooEarlyToUpdate(item: VaultItem<PayloadData>, now_sec: number): boolean;
131
+ __canBeUpdate(existed: VaultItem<PayloadData> | undefined, now_sec: number): VaultCanBeUpdateResult<PayloadData>;
132
+ __async_canBeUpdate(existed: Promise<VaultItem<PayloadData> | undefined>, now_sec: number): Promise<VaultCanBeUpdateResult<PayloadData>>;
133
+ canBeUpdate(key: string, now_sec?: number): Return<Storage["set"]> extends Promise<any> ? Promise<VaultCanBeUpdateResult<PayloadData>> : VaultCanBeUpdateResult<PayloadData>;
134
+ __upsert(key: string, pld: PayloadData, timings: InternalVaultTimings, now_sec: number): {
135
+ item: VaultItem<PayloadData>;
136
+ transaction: Return<Storage["set"]>;
137
+ };
138
+ __async_upsert(temp: {
78
139
  item: VaultItem<PayloadData>;
79
- }>;
140
+ transaction: Return<Storage["set"]>;
141
+ }): Promise<VaultItem<PayloadData>>;
142
+ upsert(key: string, pld: PayloadData, timings?: InternalVaultTimings, now_sec?: number): Return<Storage["set"]> extends Promise<any> ? Promise<VaultItem<PayloadData>> : VaultItem<PayloadData>;
143
+ sync(key: string, options?: VaultRunOptions<PayloadData>): Return<Storage["set"]> extends Promise<any> ? never : Return<Storage["get"]> extends Promise<any> ? never : Return<Controller["generate"]> extends Promise<any> ? never : VaultRunResult<PayloadData>;
144
+ run(key: string, options?: VaultRunOptions<PayloadData>): Promise<VaultRunResult<PayloadData>>;
80
145
  }
@@ -1,7 +1,23 @@
1
+ import { isPromise } from "@nemigo/helpers";
2
+ import { toSeconds } from "@nemigo/helpers/datetime";
3
+ //...
1
4
  /**
2
5
  * @example
3
6
  * ```typescript
4
- * export const codeVault = new Vault<string, RedisStorage>(redisStorage, {
7
+ * import { rand } from "@nemigo/helpers/random";
8
+ * import type { RedisStorage } from "@nemigo/server/redis";
9
+ * import { Vault } from "@nemigo/storage/derived/vault";
10
+ *
11
+ * declare const redisStorage: RedisStorage;
12
+ *
13
+ * export const redisCodeVault = new Vault<
14
+ * string,
15
+ * RedisStorage,
16
+ * {
17
+ * generate: () => string,
18
+ * equal: (a: string, b: string) => boolean,
19
+ * }
20
+ * >(redisStorage, {
5
21
  * generate: () => rand(),
6
22
  * equal: (a, b) => a === b,
7
23
  * exp: 60 * 10,
@@ -9,7 +25,7 @@
9
25
  * upd: 60,
10
26
  * });
11
27
  *
12
- * const result = await codeVault.run("some:key")
28
+ * // await redisCodeVault.run("some:key");
13
29
  * ```
14
30
  */
15
31
  export class Vault {
@@ -19,37 +35,77 @@ export class Vault {
19
35
  this.storage = storage;
20
36
  this.ctx = ctx;
21
37
  }
22
- find(key) {
23
- return this.storage.get(key);
38
+ timings(options = {}) {
39
+ const ttl = options.ttl === null ? undefined : (options.ttl ?? this.ctx.ttl);
40
+ const exp = options.exp === null ? undefined : (options.exp ?? this.ctx.exp);
41
+ const upd = options.upd === null ? undefined : (options.upd ?? this.ctx.upd);
42
+ return { ttl, exp, upd };
24
43
  }
25
- async check(key, pld) {
26
- const existed = await this.find(key);
27
- if (!existed)
44
+ //...
45
+ __isExpired(item, now_sec) {
46
+ return item.exp !== undefined && now_sec > item.exp;
47
+ }
48
+ __check(existed, pld) {
49
+ if (!existed || this.__isExpired(existed, toSeconds()))
28
50
  return false;
29
51
  return this.ctx.equal(existed.pld, pld);
30
52
  }
31
- async run(key, options = {}) {
32
- const { ttl = this.ctx.ttl, exp = this.ctx.exp, upd = this.ctx.upd, force = false, overload } = options;
33
- // работаем в секундах
34
- const nowSec = Math.floor(Date.now() / 1000);
35
- const existed = await this.find(key);
36
- if (existed && !force) {
37
- const expired = existed.exp !== undefined && nowSec > existed.exp;
38
- const tooEarlyToUpdate = existed.upd !== undefined && nowSec < existed.upd;
39
- if (!expired && !tooEarlyToUpdate) {
40
- return { generate: false, item: existed };
41
- }
42
- }
53
+ async __async_check(existed, pld) {
54
+ return this.__check(await existed, pld);
55
+ }
56
+ check(key, pld) {
57
+ const existed = this.storage.get(key);
58
+ return (isPromise(existed) ? this.__async_check(existed, pld) : this.__check(existed, pld));
59
+ }
60
+ //...
61
+ __isTooEarlyToUpdate(item, now_sec) {
62
+ return item.upd !== undefined && now_sec < item.upd;
63
+ }
64
+ __canBeUpdate(existed, now_sec) {
65
+ return existed ? { ready: !this.__isTooEarlyToUpdate(existed, now_sec), item: existed } : null;
66
+ }
67
+ async __async_canBeUpdate(existed, now_sec) {
68
+ return this.__canBeUpdate(await existed, now_sec);
69
+ }
70
+ canBeUpdate(key, now_sec = toSeconds()) {
71
+ const existed = this.storage.get(key);
72
+ return (isPromise(existed) ? this.__async_canBeUpdate(existed, now_sec) : this.__canBeUpdate(existed, now_sec));
73
+ }
74
+ //...
75
+ __upsert(key, pld, timings, now_sec) {
43
76
  // Вычисляем абсолютные времена для сохранения
44
- const newExp = exp !== undefined ? nowSec + exp : undefined;
45
- const newUpd = upd !== undefined ? nowSec + upd : undefined;
46
- const item = {
47
- pld: overload ?? (await this.ctx.generate({ exp, upd }, nowSec)),
48
- iat: nowSec,
49
- exp: newExp,
50
- upd: newUpd,
51
- };
52
- await this.storage.set(key, item, { ttl_seconds: ttl });
53
- return { generate: true, item };
77
+ const Exp = timings.exp !== undefined ? now_sec + timings.exp : undefined;
78
+ const Upd = timings.upd !== undefined ? now_sec + timings.upd : undefined;
79
+ const item = { pld, iat: now_sec, exp: Exp, upd: Upd };
80
+ return { item, transaction: this.storage.set(key, item, { ttl_seconds: timings.ttl }) };
81
+ }
82
+ async __async_upsert(temp) {
83
+ await temp.transaction;
84
+ return temp.item;
85
+ }
86
+ upsert(key, pld, timings = this.timings(), now_sec = toSeconds()) {
87
+ const temp = this.__upsert(key, pld, timings, now_sec);
88
+ return (isPromise(temp.transaction) ? this.__async_upsert(temp) : temp.item);
89
+ }
90
+ //...
91
+ sync(key, options = {}) {
92
+ const { force = false, overload } = options;
93
+ const timings = this.timings(options);
94
+ const now_sec = toSeconds();
95
+ const existed = this.canBeUpdate(key, now_sec);
96
+ if (existed && !existed.ready && !force)
97
+ return { generated: false, item: existed.item };
98
+ const item = this.upsert(key, (overload ?? this.ctx.generate(timings, now_sec)), timings, now_sec);
99
+ return { generated: true, item };
100
+ }
101
+ async run(key, options = {}) {
102
+ const { force = false, overload } = options;
103
+ const timings = this.timings(options);
104
+ const now_sec = toSeconds();
105
+ const existed = await this.canBeUpdate(key, now_sec);
106
+ if (existed && !existed.ready && !force)
107
+ return { generated: false, item: existed.item };
108
+ const item = await this.upsert(key, overload ?? (await this.ctx.generate(timings, now_sec)), timings, now_sec);
109
+ return { generated: true, item };
54
110
  }
55
111
  }
@@ -3,9 +3,6 @@ export interface ConstructVeilPrefixStorage {
3
3
  ttl_seconds?: number;
4
4
  }
5
5
  export declare abstract class VeilPrefixStorage {
6
- /**
7
- * TTL хранилища для быстрого использования
8
- */
9
6
  ttl_seconds?: number;
10
7
  prefix: string;
11
8
  constructor({ ttl_seconds, prefix }?: ConstructVeilPrefixStorage);
@@ -1,8 +1,5 @@
1
1
  import { veil } from "@nemigo/helpers/veil";
2
2
  export class VeilPrefixStorage {
3
- /**
4
- * TTL хранилища для быстрого использования
5
- */
6
3
  ttl_seconds;
7
4
  prefix;
8
5
  // noinspection TypeScriptAbstractClassConstructorCanBeMadeProtected
package/dist/runtime.d.ts CHANGED
@@ -1,20 +1,24 @@
1
- import type { IStorage, IStorageSetOptions, IStorageValue } from "./types.js";
1
+ import type { IStorage, IStorageValue } from "./types.js";
2
2
  import type { Timestamp } from "@nemigo/helpers/types";
3
3
  export interface EntryValue {
4
4
  value: IStorageValue;
5
5
  expired?: Timestamp;
6
6
  }
7
- export declare class RuntimeStorage implements IStorage<boolean> {
8
- __storage: Map<string, EntryValue>;
7
+ export interface IRuntimeStorageSetOptions {
9
8
  /**
10
- * TTL хранилища для быстрого использования
9
+ * - при `undefined` будет использован `ttl_seconds` хранилища
10
+ * - при `null` элементы точно не будут устаревать
11
11
  */
12
+ ttl_seconds?: number | null;
13
+ }
14
+ export declare class RuntimeStorage implements IStorage<boolean> {
15
+ __storage: Map<string, EntryValue>;
12
16
  ttl_seconds?: number;
13
17
  constructor(ttl_seconds?: number);
14
18
  __isExpired(entry: EntryValue): boolean;
15
19
  __get(key: string): EntryValue | undefined;
16
20
  has(key: string): boolean;
17
21
  get<T = any>(key: string): T | undefined;
18
- set(key: string, value: any, options?: IStorageSetOptions): void;
22
+ set(key: string, value: any, options?: IRuntimeStorageSetOptions): void;
19
23
  delete(key: string): boolean;
20
24
  }
package/dist/runtime.js CHANGED
@@ -1,8 +1,5 @@
1
1
  export class RuntimeStorage {
2
2
  __storage;
3
- /**
4
- * TTL хранилища для быстрого использования
5
- */
6
3
  ttl_seconds;
7
4
  constructor(ttl_seconds) {
8
5
  this.__storage = new Map();
@@ -28,8 +25,9 @@ export class RuntimeStorage {
28
25
  get(key) {
29
26
  return this.__get(key)?.value;
30
27
  }
31
- set(key, value, options) {
32
- this.__storage.set(key, options?.ttl_seconds ? { value, expired: options.ttl_seconds * 1000 } : { value });
28
+ set(key, value, options = {}) {
29
+ const ttl_seconds = options.ttl_seconds === null ? undefined : (options.ttl_seconds ?? options.ttl_seconds);
30
+ this.__storage.set(key, ttl_seconds ? { value, expired: ttl_seconds * 1000 } : { value });
33
31
  }
34
32
  delete(key) {
35
33
  return this.__storage.delete(key);
package/dist/web.d.ts CHANGED
@@ -1,20 +1,27 @@
1
1
  import { VeilPrefixStorage } from "./internal/veil-prefix.js";
2
- import type { IStorage, IStorageSetOptions, IStorageValue } from "./types.js";
2
+ import type { IStorage, IStorageValue } from "./types.js";
3
3
  import type { Timestamp } from "@nemigo/helpers/types";
4
4
  export type WebStorageType = "local" | "session";
5
5
  export interface WebStorageOptions {
6
6
  type?: WebStorageType;
7
7
  prefix?: string;
8
8
  }
9
+ export interface IWebStorageSetOptions extends WebStorageOptions {
10
+ /**
11
+ * - при `undefined` будет использован `ttl_seconds` хранилища
12
+ * - при `null` элементы точно не будут устаревать
13
+ */
14
+ ttl_seconds?: number | null;
15
+ }
9
16
  export interface EntryValue {
10
17
  value: IStorageValue;
11
18
  expired?: Timestamp;
12
19
  }
13
20
  export declare class WebStorage extends VeilPrefixStorage implements IStorage<void> {
14
- __isExpired(entry: EntryValue): boolean;
21
+ __isExpired(entry: EntryValue, now: number): boolean;
15
22
  __get<T>(storage: Storage, key: string): T | undefined;
16
23
  has(name: string, options?: WebStorageOptions): boolean;
17
24
  get<T extends IStorageValue>(name: string, options?: WebStorageOptions): T | undefined;
18
- set(name: string, value: IStorageValue, options?: IStorageSetOptions & WebStorageOptions): void;
25
+ set(name: string, value: IStorageValue, options?: IWebStorageSetOptions): void;
19
26
  delete(name: string, options?: WebStorageOptions): void;
20
27
  }
package/dist/web.js CHANGED
@@ -2,15 +2,15 @@ import { VeilPrefixStorage } from "./internal/veil-prefix.js";
2
2
  import { isSSR } from "@nemigo/helpers/html";
3
3
  import { unveil, veil } from "@nemigo/helpers/veil";
4
4
  export class WebStorage extends VeilPrefixStorage {
5
- __isExpired(entry) {
6
- return Boolean(entry.expired && Date.now() > entry.expired);
5
+ __isExpired(entry, now) {
6
+ return entry.expired !== undefined && now > entry.expired;
7
7
  }
8
8
  __get(storage, key) {
9
9
  const entry = storage.getItem(key);
10
10
  if (!entry)
11
11
  return;
12
12
  const unveiled = unveil(entry);
13
- if (this.__isExpired(unveiled)) {
13
+ if (this.__isExpired(unveiled, Date.now())) {
14
14
  storage.removeItem(key);
15
15
  }
16
16
  else {
@@ -37,7 +37,8 @@ export class WebStorage extends VeilPrefixStorage {
37
37
  if (isSSR)
38
38
  return;
39
39
  const key = this.__toKey(name, options.prefix);
40
- const veiled = veil(options.ttl_seconds ? { value, expired: options.ttl_seconds * 1000 } : { value });
40
+ const ttl_seconds = options.ttl_seconds === null ? undefined : (options.ttl_seconds ?? options.ttl_seconds);
41
+ const veiled = veil(ttl_seconds ? { value, expired: ttl_seconds * 1000 } : { value });
41
42
  if (options.type === "session")
42
43
  sessionStorage.setItem(key, veiled);
43
44
  else
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nemigo/storage",
3
- "version": "1.7.2",
3
+ "version": "1.8.0",
4
4
  "private": false,
5
5
  "author": {
6
6
  "name": "Vlad Logvin",
@@ -48,7 +48,7 @@
48
48
  }
49
49
  },
50
50
  "peerDependencies": {
51
- "@nemigo/helpers": ">=1.6.0"
51
+ "@nemigo/helpers": ">=1.6.2"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@nemigo/configs": "workspace:*",