yummies 3.1.3 → 3.1.4

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.
@@ -2,5 +2,10 @@ import { AnyObject } from '../utils/types.js';
2
2
  /**
3
3
  * Создает глобальный конфиг, который может быть доступен в любой точке в коде
4
4
  */
5
- export declare const createGlobalConfig: <T extends AnyObject>(defaultValue: T, accessSymbol?: any) => T;
5
+ export declare const createGlobalConfig: <T extends AnyObject>(defaultValue: T, accessSymbol?: any) => any;
6
+ export declare const createGlobalDynamicConfig: <T extends AnyObject>(updateFn?: (value: Partial<T>) => Partial<T>, accessSymbol?: any) => {
7
+ update: (value: Partial<T>) => void;
8
+ get: () => any;
9
+ set: (value: any) => any;
10
+ };
6
11
  //# sourceMappingURL=global-config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"global-config.d.ts","sourceRoot":"","sources":["../../src/complex/global-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,SAAS,gBACtC,CAAC,iBACD,GAAG,MAelB,CAAC"}
1
+ {"version":3,"file":"global-config.d.ts","sourceRoot":"","sources":["../../src/complex/global-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAW9C;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,SAAS,gBACtC,CAAC,iBACD,GAAG,QAIlB,CAAC;AAEF,eAAO,MAAM,yBAAyB,GAAI,CAAC,SAAS,SAAS,aAChD,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,iBAC9B,GAAG;oBAMC,OAAO,CAAC,CAAC,CAAC;;iBAvBb,GAAG;CA2BnB,CAAC"}
@@ -1,11 +1,23 @@
1
+ const createGlobalPoint = (accessSymbol) => {
2
+ const _globalThis = globalThis;
3
+ return {
4
+ get: () => _globalThis[accessSymbol],
5
+ set: (value) => (_globalThis[accessSymbol] = value),
6
+ };
7
+ };
1
8
  /**
2
9
  * Создает глобальный конфиг, который может быть доступен в любой точке в коде
3
10
  */
4
11
  export const createGlobalConfig = (defaultValue, accessSymbol = Symbol()) => {
5
- const defaultViewModelsConfig = defaultValue;
6
- const _globalThis = globalThis;
7
- if (!_globalThis[accessSymbol]) {
8
- _globalThis[accessSymbol] = defaultViewModelsConfig;
9
- }
10
- return _globalThis[accessSymbol];
12
+ const globalPoint = createGlobalPoint(accessSymbol);
13
+ return globalPoint.get() || globalPoint.set(defaultValue);
14
+ };
15
+ export const createGlobalDynamicConfig = (updateFn, accessSymbol = Symbol()) => {
16
+ const globalPoint = createGlobalPoint(accessSymbol);
17
+ return {
18
+ ...globalPoint,
19
+ update: (value) => {
20
+ Object.assign(globalPoint.get(), updateFn ? updateFn(value) : value);
21
+ },
22
+ };
11
23
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yummies",
3
- "version": "3.1.3",
3
+ "version": "3.1.4",
4
4
  "keywords": [],
5
5
  "author": "js2me",
6
6
  "license": "MIT",