@alterior/common 3.9.1 → 3.13.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.
- package/dist/base64.d.ts +6 -6
- package/dist/base64.js +52 -52
- package/dist/base64.js.map +1 -1
- package/dist/base64.test.d.ts +1 -1
- package/dist/cache.d.ts +84 -84
- package/dist/cache.js +148 -148
- package/dist/cache.js.map +1 -1
- package/dist/cache.test.d.ts +1 -1
- package/dist/check-native-async.d.ts +1 -1
- package/dist/check-native-async.js +27 -28
- package/dist/check-native-async.js.map +1 -1
- package/dist/clone.d.ts +23 -23
- package/dist/clone.js +59 -60
- package/dist/clone.js.map +1 -1
- package/dist/clone.test.d.ts +1 -1
- package/dist/coalesce.d.ts +5 -5
- package/dist/coalesce.js +15 -16
- package/dist/coalesce.js.map +1 -1
- package/dist/coalesce.test.d.ts +1 -1
- package/dist/colors.d.ts +62 -62
- package/dist/colors.js +66 -66
- package/dist/console.d.ts +31 -31
- package/dist/console.d.ts.map +1 -1
- package/dist/console.js +65 -86
- package/dist/console.js.map +1 -1
- package/dist/constructor.d.ts +6 -6
- package/dist/constructor.js +2 -2
- package/dist/decorators.d.ts +1 -1
- package/dist/decorators.d.ts.map +1 -1
- package/dist/decorators.js +6 -7
- package/dist/decorators.js.map +1 -1
- package/dist/environment.d.ts +11 -11
- package/dist/environment.d.ts.map +1 -1
- package/dist/environment.js +27 -27
- package/dist/environment.js.map +1 -1
- package/dist/errors.d.ts +66 -66
- package/dist/errors.js +133 -133
- package/dist/errors.test.d.ts +1 -1
- package/dist/get-param-names.d.ts +5 -5
- package/dist/get-param-names.js +48 -49
- package/dist/get-param-names.js.map +1 -1
- package/dist/index.d.ts +20 -20
- package/dist/index.js +23 -23
- package/dist/is-constructor.d.ts +12 -12
- package/dist/is-constructor.js +28 -29
- package/dist/is-constructor.js.map +1 -1
- package/dist/is-constructor.test.d.ts +1 -1
- package/dist/lazy-promise.d.ts +14 -14
- package/dist/lazy-promise.js +32 -32
- package/dist/lazy-promise.js.map +1 -1
- package/dist/lazy-subject.d.ts +22 -22
- package/dist/lazy-subject.js +22 -23
- package/dist/lazy-subject.js.map +1 -1
- package/dist/locks.d.ts +23 -23
- package/dist/locks.js +76 -76
- package/dist/locks.js.map +1 -1
- package/dist/locks.test.d.ts +1 -1
- package/dist/locks.test.js.map +1 -1
- package/dist/padding.d.ts +22 -22
- package/dist/padding.js +42 -43
- package/dist/padding.js.map +1 -1
- package/dist/presentation.d.ts +49 -49
- package/dist/presentation.d.ts.map +1 -1
- package/dist/presentation.js +132 -132
- package/dist/presentation.js.map +1 -1
- package/dist/presentation.test.d.ts +1 -1
- package/dist/presentation.test.js.map +1 -1
- package/dist/serializer.d.ts +8 -8
- package/dist/serializer.js +23 -24
- package/dist/serializer.js.map +1 -1
- package/dist/test.d.ts +2 -2
- package/dist/time.d.ts +9 -9
- package/dist/time.js +22 -22
- package/dist/time.js.map +1 -1
- package/dist/timeout.d.ts +13 -13
- package/dist/timeout.js +27 -28
- package/dist/timeout.js.map +1 -1
- package/dist/zones.d.ts +46 -46
- package/dist/zones.js +139 -139
- package/dist/zones.js.map +1 -1
- package/dist.esm/base64.d.ts +6 -6
- package/dist.esm/base64.js +48 -48
- package/dist.esm/base64.js.map +1 -1
- package/dist.esm/base64.test.d.ts +1 -1
- package/dist.esm/cache.d.ts +84 -84
- package/dist.esm/cache.js +144 -144
- package/dist.esm/cache.js.map +1 -1
- package/dist.esm/cache.test.d.ts +1 -1
- package/dist.esm/check-native-async.d.ts +1 -1
- package/dist.esm/check-native-async.js +24 -24
- package/dist.esm/check-native-async.js.map +1 -1
- package/dist.esm/clone.d.ts +23 -23
- package/dist.esm/clone.js +53 -53
- package/dist.esm/clone.js.map +1 -1
- package/dist.esm/clone.test.d.ts +1 -1
- package/dist.esm/coalesce.d.ts +5 -5
- package/dist.esm/coalesce.js +12 -12
- package/dist.esm/coalesce.js.map +1 -1
- package/dist.esm/coalesce.test.d.ts +1 -1
- package/dist.esm/colors.d.ts +62 -62
- package/dist.esm/colors.js +63 -63
- package/dist.esm/console.d.ts +31 -31
- package/dist.esm/console.d.ts.map +1 -1
- package/dist.esm/console.js +60 -80
- package/dist.esm/console.js.map +1 -1
- package/dist.esm/constructor.d.ts +6 -6
- package/dist.esm/constructor.js +1 -1
- package/dist.esm/decorators.d.ts +1 -1
- package/dist.esm/decorators.d.ts.map +1 -1
- package/dist.esm/decorators.js +3 -3
- package/dist.esm/environment.d.ts +11 -11
- package/dist.esm/environment.d.ts.map +1 -1
- package/dist.esm/environment.js +24 -24
- package/dist.esm/environment.js.map +1 -1
- package/dist.esm/errors.d.ts +66 -66
- package/dist.esm/errors.js +115 -115
- package/dist.esm/errors.test.d.ts +1 -1
- package/dist.esm/get-param-names.d.ts +5 -5
- package/dist.esm/get-param-names.js +45 -45
- package/dist.esm/get-param-names.js.map +1 -1
- package/dist.esm/index.d.ts +20 -20
- package/dist.esm/index.js +20 -20
- package/dist.esm/is-constructor.d.ts +12 -12
- package/dist.esm/is-constructor.js +24 -24
- package/dist.esm/is-constructor.js.map +1 -1
- package/dist.esm/is-constructor.test.d.ts +1 -1
- package/dist.esm/lazy-promise.d.ts +14 -14
- package/dist.esm/lazy-promise.js +28 -28
- package/dist.esm/lazy-promise.js.map +1 -1
- package/dist.esm/lazy-subject.d.ts +22 -22
- package/dist.esm/lazy-subject.js +19 -19
- package/dist.esm/locks.d.ts +23 -23
- package/dist.esm/locks.js +71 -71
- package/dist.esm/locks.js.map +1 -1
- package/dist.esm/locks.test.d.ts +1 -1
- package/dist.esm/locks.test.js.map +1 -1
- package/dist.esm/padding.d.ts +22 -22
- package/dist.esm/padding.js +37 -37
- package/dist.esm/presentation.d.ts +49 -49
- package/dist.esm/presentation.d.ts.map +1 -1
- package/dist.esm/presentation.js +126 -126
- package/dist.esm/presentation.js.map +1 -1
- package/dist.esm/presentation.test.d.ts +1 -1
- package/dist.esm/presentation.test.js.map +1 -1
- package/dist.esm/serializer.d.ts +8 -8
- package/dist.esm/serializer.js +20 -20
- package/dist.esm/test.d.ts +2 -2
- package/dist.esm/time.d.ts +9 -9
- package/dist.esm/time.js +19 -19
- package/dist.esm/time.js.map +1 -1
- package/dist.esm/timeout.d.ts +13 -13
- package/dist.esm/timeout.js +23 -23
- package/dist.esm/tsconfig.esm.tsbuildinfo +1 -0
- package/dist.esm/zones.d.ts +46 -46
- package/dist.esm/zones.js +135 -135
- package/dist.esm/zones.js.map +1 -1
- package/package.json +11 -8
- package/src/console.ts +2 -22
- package/src/environment.ts +2 -0
- package/tsconfig.esm.json +0 -3
- package/tsconfig.json +0 -2
- package/tsconfig.tsbuildinfo +1 -3791
package/dist/lazy-promise.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LazyPromise = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* A promise that lets you wait until someone actually requests the result of the promise to kick off
|
|
6
|
-
* the action being promised. This lets you return the promise before you start executing the async action.
|
|
7
|
-
*/
|
|
8
|
-
class LazyPromise extends Promise {
|
|
9
|
-
constructor(fulfiller) {
|
|
10
|
-
super((resolve, reject) => {
|
|
11
|
-
this._resolve = resolve;
|
|
12
|
-
this._reject = reject;
|
|
13
|
-
});
|
|
14
|
-
this.fulfiller = fulfiller;
|
|
15
|
-
}
|
|
16
|
-
fulfill() {
|
|
17
|
-
if (!this.realPromise) {
|
|
18
|
-
this.realPromise = this.fulfiller()
|
|
19
|
-
.then(v => this._resolve(v))
|
|
20
|
-
.catch(e => this._reject(e));
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
then(onfulfilled, onrejected) {
|
|
24
|
-
this.fulfill();
|
|
25
|
-
return super.then(onfulfilled, onrejected);
|
|
26
|
-
}
|
|
27
|
-
catch(onrejected) {
|
|
28
|
-
this.fulfill();
|
|
29
|
-
return super.catch(onrejected);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
exports.LazyPromise = LazyPromise;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LazyPromise = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* A promise that lets you wait until someone actually requests the result of the promise to kick off
|
|
6
|
+
* the action being promised. This lets you return the promise before you start executing the async action.
|
|
7
|
+
*/
|
|
8
|
+
class LazyPromise extends Promise {
|
|
9
|
+
constructor(fulfiller) {
|
|
10
|
+
super((resolve, reject) => {
|
|
11
|
+
this._resolve = resolve;
|
|
12
|
+
this._reject = reject;
|
|
13
|
+
});
|
|
14
|
+
this.fulfiller = fulfiller;
|
|
15
|
+
}
|
|
16
|
+
fulfill() {
|
|
17
|
+
if (!this.realPromise) {
|
|
18
|
+
this.realPromise = this.fulfiller()
|
|
19
|
+
.then(v => this._resolve(v))
|
|
20
|
+
.catch(e => this._reject(e));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
then(onfulfilled, onrejected) {
|
|
24
|
+
this.fulfill();
|
|
25
|
+
return super.then(onfulfilled, onrejected);
|
|
26
|
+
}
|
|
27
|
+
catch(onrejected) {
|
|
28
|
+
this.fulfill();
|
|
29
|
+
return super.catch(onrejected);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.LazyPromise = LazyPromise;
|
|
33
33
|
//# sourceMappingURL=lazy-promise.js.map
|
package/dist/lazy-promise.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazy-promise.js","sourceRoot":"","sources":["../src/lazy-promise.ts"],"names":[],"mappings":";;;AACA;;;GAGG;AACH,MAAa,WAAe,SAAQ,OAAU;IAC1C,YACY,SAA4B;QAEpC,KAAK,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACtB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;YACxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QAC1B,CAAC,CAAC,CAAC;QALK,cAAS,GAAT,SAAS,CAAmB;IAOxC,CAAC;IAKD,OAAO;QACH,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;
|
|
1
|
+
{"version":3,"file":"lazy-promise.js","sourceRoot":"","sources":["../src/lazy-promise.ts"],"names":[],"mappings":";;;AACA;;;GAGG;AACH,MAAa,WAAe,SAAQ,OAAU;IAC1C,YACY,SAA4B;QAEpC,KAAK,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACtB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;YACxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QAC1B,CAAC,CAAC,CAAC;QALK,cAAS,GAAT,SAAS,CAAmB;IAOxC,CAAC;IAKD,OAAO;QACH,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACpB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,SAAS,EAAE;iBAC9B,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;iBAC3B,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAC/B;QACL,CAAC;IACL,CAAC;IAID,IAAI,CAAiC,WAAiF,EAAE,UAAmF;QACvM,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,OAAO,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IAC/C,CAAC;IAED,KAAK,CAAkB,UAAiF;QACpG,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,OAAO,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACnC,CAAC;CACJ;AAlCD,kCAkCC"}
|
package/dist/lazy-subject.d.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { Subject, Observable } from 'rxjs';
|
|
2
|
-
/**
|
|
3
|
-
* Options for the lazySubject() utility
|
|
4
|
-
*/
|
|
5
|
-
export interface LazySubjectOptions<T> {
|
|
6
|
-
/**
|
|
7
|
-
* Function that is called when the observable is subscribed to after
|
|
8
|
-
* having no subscribers
|
|
9
|
-
*/
|
|
10
|
-
start: (subject: Subject<T>) => void;
|
|
11
|
-
/**
|
|
12
|
-
* Function that is called when the observable moves from having subscribers
|
|
13
|
-
* to having no subscribers.
|
|
14
|
-
*/
|
|
15
|
-
stop: () => void;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Utility for creating a subject observable which can run arbitrary code when the first
|
|
19
|
-
* subscribe() happens and when the last unsubscribe() happens.
|
|
20
|
-
* @param options
|
|
21
|
-
*/
|
|
22
|
-
export declare function lazySubject<T>(options: LazySubjectOptions<T>): Observable<T>;
|
|
1
|
+
import { Subject, Observable } from 'rxjs';
|
|
2
|
+
/**
|
|
3
|
+
* Options for the lazySubject() utility
|
|
4
|
+
*/
|
|
5
|
+
export interface LazySubjectOptions<T> {
|
|
6
|
+
/**
|
|
7
|
+
* Function that is called when the observable is subscribed to after
|
|
8
|
+
* having no subscribers
|
|
9
|
+
*/
|
|
10
|
+
start: (subject: Subject<T>) => void;
|
|
11
|
+
/**
|
|
12
|
+
* Function that is called when the observable moves from having subscribers
|
|
13
|
+
* to having no subscribers.
|
|
14
|
+
*/
|
|
15
|
+
stop: () => void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Utility for creating a subject observable which can run arbitrary code when the first
|
|
19
|
+
* subscribe() happens and when the last unsubscribe() happens.
|
|
20
|
+
* @param options
|
|
21
|
+
*/
|
|
22
|
+
export declare function lazySubject<T>(options: LazySubjectOptions<T>): Observable<T>;
|
|
23
23
|
//# sourceMappingURL=lazy-subject.d.ts.map
|
package/dist/lazy-subject.js
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.lazySubject =
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
/**
|
|
7
|
-
* Utility for creating a subject observable which can run arbitrary code when the first
|
|
8
|
-
* subscribe() happens and when the last unsubscribe() happens.
|
|
9
|
-
* @param options
|
|
10
|
-
*/
|
|
11
|
-
function lazySubject(options) {
|
|
12
|
-
let obs = new rxjs_1.Observable(observer => {
|
|
13
|
-
let subject = new rxjs_1.Subject();
|
|
14
|
-
let subscription = subject.subscribe(observer);
|
|
15
|
-
options.start(subject);
|
|
16
|
-
return () => {
|
|
17
|
-
subscription.unsubscribe();
|
|
18
|
-
options.stop();
|
|
19
|
-
};
|
|
20
|
-
});
|
|
21
|
-
return obs.pipe((0, operators_1.publish)()).refCount();
|
|
22
|
-
}
|
|
23
|
-
exports.lazySubject = lazySubject;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.lazySubject = lazySubject;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
/**
|
|
7
|
+
* Utility for creating a subject observable which can run arbitrary code when the first
|
|
8
|
+
* subscribe() happens and when the last unsubscribe() happens.
|
|
9
|
+
* @param options
|
|
10
|
+
*/
|
|
11
|
+
function lazySubject(options) {
|
|
12
|
+
let obs = new rxjs_1.Observable(observer => {
|
|
13
|
+
let subject = new rxjs_1.Subject();
|
|
14
|
+
let subscription = subject.subscribe(observer);
|
|
15
|
+
options.start(subject);
|
|
16
|
+
return () => {
|
|
17
|
+
subscription.unsubscribe();
|
|
18
|
+
options.stop();
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
return obs.pipe((0, operators_1.publish)()).refCount();
|
|
22
|
+
}
|
|
24
23
|
//# sourceMappingURL=lazy-subject.js.map
|
package/dist/lazy-subject.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazy-subject.js","sourceRoot":"","sources":["../src/lazy-subject.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lazy-subject.js","sourceRoot":"","sources":["../src/lazy-subject.ts"],"names":[],"mappings":";;AAyBA,kCAcC;AAvCD,+BAAkE;AAClE,8CAAyC;AAmBzC;;;;GAIG;AACH,SAAgB,WAAW,CAAI,OAA+B;IAE1D,IAAI,GAAG,GAAG,IAAI,iBAAU,CAAC,QAAQ,CAAC,EAAE;QAChC,IAAI,OAAO,GAAG,IAAI,cAAO,EAAK,CAAC;QAC/B,IAAI,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QAE/C,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACvB,OAAO,GAAG,EAAE;YACR,YAAY,CAAC,WAAW,EAAE,CAAC;YAC3B,OAAO,CAAC,IAAI,EAAE,CAAC;QACnB,CAAC,CAAC;IACN,CAAC,CAAC,CAAC;IAEH,OAAkC,GAAG,CAAC,IAAI,CAAC,IAAA,mBAAO,GAAE,CAAE,CAAC,QAAQ,EAAE,CAAC;AACtE,CAAC"}
|
package/dist/locks.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Provides a mechanism for ensuring that multiple function calls do not overlap, even if they are asynchronous.
|
|
3
|
-
* NOTE: This does not include macrotasks (ie setTimeout/setInterval/etc). If you require that, see ZoneLock.
|
|
4
|
-
*/
|
|
5
|
-
export declare class Lock {
|
|
6
|
-
constructor();
|
|
7
|
-
private _ready;
|
|
8
|
-
private static _namedLocks;
|
|
9
|
-
static forToken<T extends Lock>(this: {
|
|
10
|
-
new (): T;
|
|
11
|
-
}, token: any): T;
|
|
12
|
-
protected executeCallback(cb: any): Promise<any>;
|
|
13
|
-
run(cb: Function): Promise<any>;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Provides a mechanism for ensuring that multiple function calls do not overlap, even if they are asynchronous
|
|
17
|
-
* or they spin off macrotasks (ie setTimeout/setInterval/etc). Zone.js is used to accomplish this. For a lighter
|
|
18
|
-
* lock that does not track macrotasks see Lock.
|
|
19
|
-
*/
|
|
20
|
-
export declare class ZoneLock extends Lock {
|
|
21
|
-
constructor();
|
|
22
|
-
protected executeCallback(cb: any): Promise<unknown>;
|
|
23
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Provides a mechanism for ensuring that multiple function calls do not overlap, even if they are asynchronous.
|
|
3
|
+
* NOTE: This does not include macrotasks (ie setTimeout/setInterval/etc). If you require that, see ZoneLock.
|
|
4
|
+
*/
|
|
5
|
+
export declare class Lock {
|
|
6
|
+
constructor();
|
|
7
|
+
private _ready;
|
|
8
|
+
private static _namedLocks;
|
|
9
|
+
static forToken<T extends Lock>(this: {
|
|
10
|
+
new (): T;
|
|
11
|
+
}, token: any): T;
|
|
12
|
+
protected executeCallback(cb: any): Promise<any>;
|
|
13
|
+
run(cb: Function): Promise<any>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Provides a mechanism for ensuring that multiple function calls do not overlap, even if they are asynchronous
|
|
17
|
+
* or they spin off macrotasks (ie setTimeout/setInterval/etc). Zone.js is used to accomplish this. For a lighter
|
|
18
|
+
* lock that does not track macrotasks see Lock.
|
|
19
|
+
*/
|
|
20
|
+
export declare class ZoneLock extends Lock {
|
|
21
|
+
constructor();
|
|
22
|
+
protected executeCallback(cb: any): Promise<unknown>;
|
|
23
|
+
}
|
|
24
24
|
//# sourceMappingURL=locks.d.ts.map
|
package/dist/locks.js
CHANGED
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ZoneLock = exports.Lock = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const zones_1 = require("./zones");
|
|
6
|
-
/**
|
|
7
|
-
* Provides a mechanism for ensuring that multiple function calls do not overlap, even if they are asynchronous.
|
|
8
|
-
* NOTE: This does not include macrotasks (ie setTimeout/setInterval/etc). If you require that, see ZoneLock.
|
|
9
|
-
*/
|
|
10
|
-
class Lock {
|
|
11
|
-
constructor() {
|
|
12
|
-
}
|
|
13
|
-
static forToken(token) {
|
|
14
|
-
let prop = Object.getOwnPropertyDescriptor(this, '_namedLocks');
|
|
15
|
-
let map;
|
|
16
|
-
if (!prop) {
|
|
17
|
-
map = new Map();
|
|
18
|
-
Object.defineProperty(this, '_namedLocks', {
|
|
19
|
-
enumerable: false,
|
|
20
|
-
value: map
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
map = prop.value;
|
|
25
|
-
}
|
|
26
|
-
let lock = map.get(token);
|
|
27
|
-
if (!lock) {
|
|
28
|
-
lock = new this();
|
|
29
|
-
map.set(token, lock);
|
|
30
|
-
}
|
|
31
|
-
return lock;
|
|
32
|
-
}
|
|
33
|
-
executeCallback(cb) {
|
|
34
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
return yield cb();
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
run(cb) {
|
|
39
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
let ready = this._ready;
|
|
41
|
-
let value = undefined;
|
|
42
|
-
let error = undefined;
|
|
43
|
-
this._ready = new Promise((resolve) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
yield ready;
|
|
45
|
-
try {
|
|
46
|
-
value = yield this.executeCallback(cb);
|
|
47
|
-
}
|
|
48
|
-
catch (e) {
|
|
49
|
-
error = e;
|
|
50
|
-
}
|
|
51
|
-
resolve();
|
|
52
|
-
}));
|
|
53
|
-
yield this._ready;
|
|
54
|
-
if (error !== undefined)
|
|
55
|
-
throw error;
|
|
56
|
-
return value;
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
exports.Lock = Lock;
|
|
61
|
-
/**
|
|
62
|
-
* Provides a mechanism for ensuring that multiple function calls do not overlap, even if they are asynchronous
|
|
63
|
-
* or they spin off macrotasks (ie setTimeout/setInterval/etc). Zone.js is used to accomplish this. For a lighter
|
|
64
|
-
* lock that does not track macrotasks see Lock.
|
|
65
|
-
*/
|
|
66
|
-
class ZoneLock extends Lock {
|
|
67
|
-
constructor() {
|
|
68
|
-
super();
|
|
69
|
-
}
|
|
70
|
-
executeCallback(cb) {
|
|
71
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
72
|
-
return yield zones_1.AsyncZone.run(cb);
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
exports.ZoneLock = ZoneLock;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZoneLock = exports.Lock = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const zones_1 = require("./zones");
|
|
6
|
+
/**
|
|
7
|
+
* Provides a mechanism for ensuring that multiple function calls do not overlap, even if they are asynchronous.
|
|
8
|
+
* NOTE: This does not include macrotasks (ie setTimeout/setInterval/etc). If you require that, see ZoneLock.
|
|
9
|
+
*/
|
|
10
|
+
class Lock {
|
|
11
|
+
constructor() {
|
|
12
|
+
}
|
|
13
|
+
static forToken(token) {
|
|
14
|
+
let prop = Object.getOwnPropertyDescriptor(this, '_namedLocks');
|
|
15
|
+
let map;
|
|
16
|
+
if (!prop) {
|
|
17
|
+
map = new Map();
|
|
18
|
+
Object.defineProperty(this, '_namedLocks', {
|
|
19
|
+
enumerable: false,
|
|
20
|
+
value: map
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
map = prop.value;
|
|
25
|
+
}
|
|
26
|
+
let lock = map.get(token);
|
|
27
|
+
if (!lock) {
|
|
28
|
+
lock = new this();
|
|
29
|
+
map.set(token, lock);
|
|
30
|
+
}
|
|
31
|
+
return lock;
|
|
32
|
+
}
|
|
33
|
+
executeCallback(cb) {
|
|
34
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
return yield cb();
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
run(cb) {
|
|
39
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
let ready = this._ready;
|
|
41
|
+
let value = undefined;
|
|
42
|
+
let error = undefined;
|
|
43
|
+
this._ready = new Promise((resolve) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
yield ready;
|
|
45
|
+
try {
|
|
46
|
+
value = yield this.executeCallback(cb);
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
error = e;
|
|
50
|
+
}
|
|
51
|
+
resolve();
|
|
52
|
+
}));
|
|
53
|
+
yield this._ready;
|
|
54
|
+
if (error !== undefined)
|
|
55
|
+
throw error;
|
|
56
|
+
return value;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.Lock = Lock;
|
|
61
|
+
/**
|
|
62
|
+
* Provides a mechanism for ensuring that multiple function calls do not overlap, even if they are asynchronous
|
|
63
|
+
* or they spin off macrotasks (ie setTimeout/setInterval/etc). Zone.js is used to accomplish this. For a lighter
|
|
64
|
+
* lock that does not track macrotasks see Lock.
|
|
65
|
+
*/
|
|
66
|
+
class ZoneLock extends Lock {
|
|
67
|
+
constructor() {
|
|
68
|
+
super();
|
|
69
|
+
}
|
|
70
|
+
executeCallback(cb) {
|
|
71
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
return yield zones_1.AsyncZone.run(cb);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.ZoneLock = ZoneLock;
|
|
77
77
|
//# sourceMappingURL=locks.js.map
|
package/dist/locks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locks.js","sourceRoot":"","sources":["../src/locks.ts"],"names":[],"mappings":";;;;AAAA,mCAAoC;AAEpC;;;GAGG;AACH,MAAa,IAAI;IACb;IACA,CAAC;IAKD,MAAM,CAAC,QAA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AO,CAAC,CAAM,OAAO,EAAC,EAAE;gBACtC,MAAM,KAAK,CAAC;gBAEZ,IAAI,CAAC;oBACD,KAAK,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;gBAC3C,CAAC;gBAAC,OAAO,CAAC,EAAE,CAAC;oBACT,KAAK,GAAG,CAAC,CAAC;gBACd,CAAC;gBACD,OAAO,EAAE,CAAC;YACd,CAAC,CAAA,CAAC,CAAC;YAEH,MAAM,IAAI,CAAC,MAAM,CAAC;YAElB,IAAI,KAAK,KAAK,SAAS;gBACnB,MAAM,KAAK,CAAC;YAEhB,OAAO,KAAK,CAAC;QACjB,CAAC;KAAA;CACJ;AA5DD,oBA4DC;AAED;;;;GAIG;AACH,MAAa,QAAS,SAAQ,IAAI;IAC9B;QACI,KAAK,EAAE,CAAC;IACZ,CAAC;IAEe,eAAe,CAAC,EAAE;;YAC9B,OAAO,MAAM,iBAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACnC,CAAC;KAAA;CACJ;AARD,4BAQC"}
|
package/dist/locks.test.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=locks.test.d.ts.map
|
package/dist/locks.test.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locks.test.js","sourceRoot":"","sources":["../src/locks.test.ts"],"names":[],"mappings":";;;AAAA,mCAA+B;AAC/B,mCAAyC;AACzC,uCAAoC;AACpC,+BAA8B;AAE9B,IAAA,cAAK,EAAC,QAAQ,CAAC,EAAE;IACb,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QAClB,EAAE,CAAC,8BAA8B,EAAE,GAAS,EAAE;YAC1C,KAAK,IAAI,IAAI,GAAG,CAAC,EAAE,OAAO,GAAG,CAAC,EAAE,IAAI,GAAG,OAAO,EAAE,EAAE,IAAI,EAAE;
|
|
1
|
+
{"version":3,"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,CAAC;oBAC1D,CAAC,CAAA,CAAC,CAAC,CAAC;gBACR,CAAC;gBAED,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBACxB,IAAA,aAAM,EAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;YAC1C,CAAC;QACL,CAAC,CAAA,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
package/dist/padding.d.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pad the given string until its at least `length` characters long by adding spaces to the end.
|
|
3
|
-
*
|
|
4
|
-
* @param str
|
|
5
|
-
* @param length
|
|
6
|
-
* @returns
|
|
7
|
-
*/
|
|
8
|
-
export declare function rightPad(str: string, length: number): string;
|
|
9
|
-
/**
|
|
10
|
-
* Pad the given string until its at least `length` characters long by adding spaces to the beginning.
|
|
11
|
-
* @param str
|
|
12
|
-
* @param length
|
|
13
|
-
* @returns
|
|
14
|
-
*/
|
|
15
|
-
export declare function leftPad(str: string, length: number): string;
|
|
16
|
-
/**
|
|
17
|
-
* Pad the given number (creating a string) until its at least `length` digits long by adding zeros to the beginning.
|
|
18
|
-
* @param number
|
|
19
|
-
* @param digits
|
|
20
|
-
* @returns
|
|
21
|
-
*/
|
|
22
|
-
export declare function zeroPad(number: any, digits?: number): string;
|
|
1
|
+
/**
|
|
2
|
+
* Pad the given string until its at least `length` characters long by adding spaces to the end.
|
|
3
|
+
*
|
|
4
|
+
* @param str
|
|
5
|
+
* @param length
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare function rightPad(str: string, length: number): string;
|
|
9
|
+
/**
|
|
10
|
+
* Pad the given string until its at least `length` characters long by adding spaces to the beginning.
|
|
11
|
+
* @param str
|
|
12
|
+
* @param length
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
export declare function leftPad(str: string, length: number): string;
|
|
16
|
+
/**
|
|
17
|
+
* Pad the given number (creating a string) until its at least `length` digits long by adding zeros to the beginning.
|
|
18
|
+
* @param number
|
|
19
|
+
* @param digits
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
export declare function zeroPad(number: any, digits?: number): string;
|
|
23
23
|
//# sourceMappingURL=padding.d.ts.map
|
package/dist/padding.js
CHANGED
|
@@ -1,44 +1,43 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* @
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*
|
|
21
|
-
* @param
|
|
22
|
-
* @
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Pad the given number (creating a string) until its at least `length` digits long by adding zeros to the beginning.
|
|
33
|
-
* @param number
|
|
34
|
-
* @param digits
|
|
35
|
-
* @returns
|
|
36
|
-
*/
|
|
37
|
-
function zeroPad(number, digits = 2) {
|
|
38
|
-
let str = `${number}`;
|
|
39
|
-
while (str.length < digits)
|
|
40
|
-
str = '0' + str;
|
|
41
|
-
return str;
|
|
42
|
-
}
|
|
43
|
-
exports.zeroPad = zeroPad;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rightPad = rightPad;
|
|
4
|
+
exports.leftPad = leftPad;
|
|
5
|
+
exports.zeroPad = zeroPad;
|
|
6
|
+
/**
|
|
7
|
+
* Pad the given string until its at least `length` characters long by adding spaces to the end.
|
|
8
|
+
*
|
|
9
|
+
* @param str
|
|
10
|
+
* @param length
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
function rightPad(str, length) {
|
|
14
|
+
str = String(str);
|
|
15
|
+
while (str.length < length)
|
|
16
|
+
str += ' ';
|
|
17
|
+
return str;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Pad the given string until its at least `length` characters long by adding spaces to the beginning.
|
|
21
|
+
* @param str
|
|
22
|
+
* @param length
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
function leftPad(str, length) {
|
|
26
|
+
str = String(str);
|
|
27
|
+
while (str.length < length)
|
|
28
|
+
str = ' ' + str;
|
|
29
|
+
return str;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Pad the given number (creating a string) until its at least `length` digits long by adding zeros to the beginning.
|
|
33
|
+
* @param number
|
|
34
|
+
* @param digits
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
function zeroPad(number, digits = 2) {
|
|
38
|
+
let str = `${number}`;
|
|
39
|
+
while (str.length < digits)
|
|
40
|
+
str = '0' + str;
|
|
41
|
+
return str;
|
|
42
|
+
}
|
|
44
43
|
//# sourceMappingURL=padding.js.map
|
package/dist/padding.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"padding.js","sourceRoot":"","sources":["../src/padding.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"padding.js","sourceRoot":"","sources":["../src/padding.ts"],"names":[],"mappings":";;AAOA,4BAOC;AAQD,0BAOC;AAQD,0BAMC;AA3CD;;;;;;GAMG;AACH,SAAgB,QAAQ,CAAC,GAAW,EAAE,MAAc;IAChD,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAElB,OAAO,GAAG,CAAC,MAAM,GAAG,MAAM;QACtB,GAAG,IAAI,GAAG,CAAC;IAEf,OAAO,GAAG,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,SAAgB,OAAO,CAAC,GAAW,EAAE,MAAc;IAC/C,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAElB,OAAO,GAAG,CAAC,MAAM,GAAG,MAAM;QACtB,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;IAEpB,OAAO,GAAG,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,SAAgB,OAAO,CAAC,MAAW,EAAE,MAAM,GAAG,CAAC;IAC3C,IAAI,GAAG,GAAG,GAAG,MAAM,EAAE,CAAC;IACtB,OAAO,GAAG,CAAC,MAAM,GAAG,MAAM;QACtB,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;IAEpB,OAAO,GAAG,CAAC;AACf,CAAC"}
|
package/dist/presentation.d.ts
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import { Constructor } from "./constructor";
|
|
2
|
-
export declare const EXPOSE_PROTOTYPE_STORAGE_KEY = "@alterior/common:Expose";
|
|
3
|
-
export interface PresentedPropertyOptions {
|
|
4
|
-
useProperty?: string;
|
|
5
|
-
class?: Constructor<Presentation<any>>;
|
|
6
|
-
defaultValue?: any;
|
|
7
|
-
}
|
|
8
|
-
export interface PresentedProperty {
|
|
9
|
-
propertyKey: string;
|
|
10
|
-
options: PresentedPropertyOptions;
|
|
11
|
-
designType?: any;
|
|
12
|
-
}
|
|
13
|
-
export declare class PresentationSchema<T> {
|
|
14
|
-
readonly type: Constructor<Presentation<T>>;
|
|
15
|
-
constructor(type: Constructor<Presentation<T>>);
|
|
16
|
-
private populate;
|
|
17
|
-
properties: PresentedProperty[];
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Allows for transforming data from one form to another using declarative rules.
|
|
21
|
-
* To use, you must declare a subclass which has one or more properties annotated
|
|
22
|
-
* with the `@Expose()` decorator. When the presentation is converted to JSON,
|
|
23
|
-
* the property values from the `instance` given during instantiation will be used
|
|
24
|
-
* within the JSON. If any property declaration within the `Presentation<T>` subclass
|
|
25
|
-
* has a property type annotation for a type that extends `Presentation<T>`, a
|
|
26
|
-
* new instance of that type will be constructed and passed the property value from
|
|
27
|
-
* the given `instance`. This allows you to control the presentation of subobjects.
|
|
28
|
-
*/
|
|
29
|
-
export declare class Presentation<T> {
|
|
30
|
-
readonly instance: T;
|
|
31
|
-
constructor(instance: T);
|
|
32
|
-
/**
|
|
33
|
-
* Construct a new set of presentations with the type of calling class
|
|
34
|
-
* for the items within the given array.
|
|
35
|
-
*
|
|
36
|
-
* @param this
|
|
37
|
-
* @param array
|
|
38
|
-
*/
|
|
39
|
-
static from<T extends Presentation<U>, U>(this: Constructor<T>, array: U[]): T[];
|
|
40
|
-
static get properties(): PresentedProperty[];
|
|
41
|
-
toJSON(): {};
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* When used on properties declared within a subclass of `Presentation<T>`,
|
|
45
|
-
* specifies that the property should be included in the final JSON presentation.
|
|
46
|
-
*
|
|
47
|
-
* @see Presentation<T>
|
|
48
|
-
*/
|
|
49
|
-
export declare function Expose(options?: PresentedPropertyOptions): (target: Object, propertyKey: string, descriptor?: PropertyDescriptor) => void;
|
|
1
|
+
import { Constructor } from "./constructor";
|
|
2
|
+
export declare const EXPOSE_PROTOTYPE_STORAGE_KEY = "@alterior/common:Expose";
|
|
3
|
+
export interface PresentedPropertyOptions {
|
|
4
|
+
useProperty?: string;
|
|
5
|
+
class?: Constructor<Presentation<any>>;
|
|
6
|
+
defaultValue?: any;
|
|
7
|
+
}
|
|
8
|
+
export interface PresentedProperty {
|
|
9
|
+
propertyKey: string;
|
|
10
|
+
options: PresentedPropertyOptions;
|
|
11
|
+
designType?: any;
|
|
12
|
+
}
|
|
13
|
+
export declare class PresentationSchema<T> {
|
|
14
|
+
readonly type: Constructor<Presentation<T>>;
|
|
15
|
+
constructor(type: Constructor<Presentation<T>>);
|
|
16
|
+
private populate;
|
|
17
|
+
properties: PresentedProperty[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Allows for transforming data from one form to another using declarative rules.
|
|
21
|
+
* To use, you must declare a subclass which has one or more properties annotated
|
|
22
|
+
* with the `@Expose()` decorator. When the presentation is converted to JSON,
|
|
23
|
+
* the property values from the `instance` given during instantiation will be used
|
|
24
|
+
* within the JSON. If any property declaration within the `Presentation<T>` subclass
|
|
25
|
+
* has a property type annotation for a type that extends `Presentation<T>`, a
|
|
26
|
+
* new instance of that type will be constructed and passed the property value from
|
|
27
|
+
* the given `instance`. This allows you to control the presentation of subobjects.
|
|
28
|
+
*/
|
|
29
|
+
export declare class Presentation<T> {
|
|
30
|
+
readonly instance: T;
|
|
31
|
+
constructor(instance: T);
|
|
32
|
+
/**
|
|
33
|
+
* Construct a new set of presentations with the type of calling class
|
|
34
|
+
* for the items within the given array.
|
|
35
|
+
*
|
|
36
|
+
* @param this
|
|
37
|
+
* @param array
|
|
38
|
+
*/
|
|
39
|
+
static from<T extends Presentation<U>, U>(this: Constructor<T>, array: U[]): T[];
|
|
40
|
+
static get properties(): PresentedProperty[];
|
|
41
|
+
toJSON(): {};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* When used on properties declared within a subclass of `Presentation<T>`,
|
|
45
|
+
* specifies that the property should be included in the final JSON presentation.
|
|
46
|
+
*
|
|
47
|
+
* @see Presentation<T>
|
|
48
|
+
*/
|
|
49
|
+
export declare function Expose(options?: PresentedPropertyOptions): (target: Object, propertyKey: string, descriptor?: PropertyDescriptor) => void;
|
|
50
50
|
//# sourceMappingURL=presentation.d.ts.map
|