@tramvai/core 3.4.6 → 3.7.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.
package/lib/index.d.ts CHANGED
@@ -4,4 +4,5 @@ export { createAction } from './actions/createActions';
4
4
  export * from './actions/declareAction';
5
5
  export * from '@tramvai/tokens-core';
6
6
  export { DI_TOKEN, IS_DI_CHILD_CONTAINER_TOKEN, Scope, Provider, createToken, provide, optional, ExtractTokenType, ExtractDependencyType, Module, MODULE_PARAMETERS, getModuleParameters, walkOfModules, isExtendedModule, ModuleType, ExtendedModule, declareModule, } from '@tinkoff/dippy';
7
+ export { Deferred } from './utils/deferred';
7
8
  //# sourceMappingURL=index.d.ts.map
package/lib/index.es.js CHANGED
@@ -4,3 +4,4 @@ export { createAction } from './actions/createActions.es.js';
4
4
  export { declareAction, isTramvaiAction } from './actions/declareAction.es.js';
5
5
  export * from '@tramvai/tokens-core';
6
6
  export { DI_TOKEN, IS_DI_CHILD_CONTAINER_TOKEN, MODULE_PARAMETERS, Module, Scope, createToken, declareModule, getModuleParameters, isExtendedModule, optional, provide, walkOfModules } from '@tinkoff/dippy';
7
+ export { Deferred } from './utils/deferred.es.js';
package/lib/index.js CHANGED
@@ -8,6 +8,7 @@ var createActions = require('./actions/createActions.js');
8
8
  var declareAction = require('./actions/declareAction.js');
9
9
  var tokensCore = require('@tramvai/tokens-core');
10
10
  var dippy = require('@tinkoff/dippy');
11
+ var deferred = require('./utils/deferred.js');
11
12
 
12
13
 
13
14
 
@@ -65,6 +66,7 @@ Object.defineProperty(exports, 'walkOfModules', {
65
66
  enumerable: true,
66
67
  get: function () { return dippy.walkOfModules; }
67
68
  });
69
+ exports.Deferred = deferred.Deferred;
68
70
  Object.keys(tokensCore).forEach(function (k) {
69
71
  if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
70
72
  enumerable: true,
@@ -0,0 +1,8 @@
1
+ export declare class Deferred<T> {
2
+ status: 'pending' | 'resolved' | 'rejected';
3
+ promise: Promise<T>;
4
+ resolve: (value: T) => void;
5
+ reject: (reason?: unknown) => void;
6
+ constructor();
7
+ }
8
+ //# sourceMappingURL=deferred.d.ts.map
@@ -0,0 +1,25 @@
1
+ import noop from '@tinkoff/utils/function/noop';
2
+
3
+ class Deferred {
4
+ constructor() {
5
+ this.status = 'pending';
6
+ this.resolve = noop;
7
+ this.reject = noop;
8
+ this.promise = new Promise((resolve, reject) => {
9
+ this.resolve = (value) => {
10
+ if (this.status === 'pending') {
11
+ this.status = 'resolved';
12
+ resolve(value);
13
+ }
14
+ };
15
+ this.reject = (reason) => {
16
+ if (this.status === 'pending') {
17
+ this.status = 'rejected';
18
+ reject(reason);
19
+ }
20
+ };
21
+ });
22
+ }
23
+ }
24
+
25
+ export { Deferred };
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var noop = require('@tinkoff/utils/function/noop');
6
+
7
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
+
9
+ var noop__default = /*#__PURE__*/_interopDefaultLegacy(noop);
10
+
11
+ class Deferred {
12
+ constructor() {
13
+ this.status = 'pending';
14
+ this.resolve = noop__default["default"];
15
+ this.reject = noop__default["default"];
16
+ this.promise = new Promise((resolve, reject) => {
17
+ this.resolve = (value) => {
18
+ if (this.status === 'pending') {
19
+ this.status = 'resolved';
20
+ resolve(value);
21
+ }
22
+ };
23
+ this.reject = (reason) => {
24
+ if (this.status === 'pending') {
25
+ this.status = 'rejected';
26
+ reject(reason);
27
+ }
28
+ };
29
+ });
30
+ }
31
+ }
32
+
33
+ exports.Deferred = Deferred;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/core",
3
- "version": "3.4.6",
3
+ "version": "3.7.0",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -19,9 +19,9 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "@tinkoff/utils": "^2.1.2",
22
- "@tramvai/tokens-common": "3.4.6",
23
- "@tramvai/tokens-core": "3.4.6",
24
- "@tramvai/types-actions-state-context": "3.4.6",
22
+ "@tramvai/tokens-common": "3.7.0",
23
+ "@tramvai/tokens-core": "3.7.0",
24
+ "@tramvai/types-actions-state-context": "3.7.0",
25
25
  "@tinkoff/dippy": "0.9.1",
26
26
  "node-abort-controller": "^3.0.1",
27
27
  "tslib": "^2.4.0"