gingersnap 0.22.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/_virtual/_tslib.cjs +102 -0
- package/_virtual/_tslib.mjs +93 -0
- package/data/AtomicValue.d.ts +15 -0
- package/data/bus.cjs +179 -0
- package/data/bus.d.ts +72 -0
- package/data/bus.mjs +177 -0
- package/data/decoders/index.d.ts +4 -0
- package/data/decoders/json.cjs +12 -0
- package/data/decoders/json.d.ts +7 -0
- package/data/decoders/json.mjs +10 -0
- package/data/decoders/msgpack.cjs +14 -0
- package/data/decoders/msgpack.d.ts +7 -0
- package/data/decoders/msgpack.mjs +12 -0
- package/data/decoders/protobuf.d.ts +13 -0
- package/data/decoders/string.cjs +12 -0
- package/data/decoders/string.d.ts +7 -0
- package/data/decoders/string.mjs +10 -0
- package/data/decoders/type.d.ts +7 -0
- package/data/decoders.cjs +11 -0
- package/data/decoders.mjs +3 -0
- package/data/model/credentials.cjs +114 -0
- package/data/model/credentials.d.ts +61 -0
- package/data/model/credentials.mjs +109 -0
- package/data/model/extra.cjs +88 -0
- package/data/model/extra.d.ts +5 -0
- package/data/model/extra.mjs +66 -0
- package/data/model/index.d.ts +6 -0
- package/data/model/model.cjs +541 -0
- package/data/model/model.d.ts +207 -0
- package/data/model/model.mjs +518 -0
- package/data/model/plugin.cjs +96 -0
- package/data/model/plugin.d.ts +38 -0
- package/data/model/plugin.mjs +72 -0
- package/data/model/property.cjs +310 -0
- package/data/model/property.d.ts +83 -0
- package/data/model/property.mjs +278 -0
- package/data/model/types.cjs +32 -0
- package/data/model/types.d.ts +28 -0
- package/data/model/types.mjs +32 -0
- package/data/model.cjs +43 -0
- package/data/model.mjs +6 -0
- package/data/signal.cjs +47 -0
- package/data/signal.d.ts +17 -0
- package/data/signal.mjs +45 -0
- package/data/store/index.d.ts +4 -0
- package/data/store/json.cjs +58 -0
- package/data/store/json.d.ts +18 -0
- package/data/store/json.mjs +56 -0
- package/data/store/manager.cjs +206 -0
- package/data/store/manager.d.ts +44 -0
- package/data/store/manager.mjs +203 -0
- package/data/store/web.cjs +92 -0
- package/data/store/web.d.ts +25 -0
- package/data/store/web.mjs +89 -0
- package/data/value.cjs +66 -0
- package/data/value.mjs +64 -0
- package/data-structures/array/CyclicalList.cjs +57 -0
- package/data-structures/array/CyclicalList.d.ts +12 -0
- package/data-structures/array/CyclicalList.mjs +55 -0
- package/data-structures/array/Pair.cjs +30 -0
- package/data-structures/array/Pair.d.ts +17 -0
- package/data-structures/array/Pair.mjs +27 -0
- package/data-structures/array/Stack.cjs +96 -0
- package/data-structures/array/Stack.d.ts +41 -0
- package/data-structures/array/Stack.mjs +94 -0
- package/data-structures/array/Triple.cjs +34 -0
- package/data-structures/array/Triple.d.ts +19 -0
- package/data-structures/array/Triple.mjs +31 -0
- package/data-structures/array/Tuple.d.ts +8 -0
- package/data-structures/array/index.d.ts +5 -0
- package/data-structures/array.cjs +15 -0
- package/data-structures/array.mjs +4 -0
- package/data-structures/object/BufferQueue.cjs +98 -0
- package/data-structures/object/BufferQueue.d.ts +21 -0
- package/data-structures/object/BufferQueue.mjs +77 -0
- package/data-structures/object/CyclicalObject.cjs +155 -0
- package/data-structures/object/CyclicalObject.d.ts +74 -0
- package/data-structures/object/CyclicalObject.mjs +134 -0
- package/data-structures/object/Queue.cjs +178 -0
- package/data-structures/object/Queue.d.ts +31 -0
- package/data-structures/object/Queue.mjs +176 -0
- package/data-structures/object/SimpleQueue.cjs +53 -0
- package/data-structures/object/SimpleQueue.d.ts +13 -0
- package/data-structures/object/SimpleQueue.mjs +51 -0
- package/data-structures/object/TimeableObject.cjs +73 -0
- package/data-structures/object/TimeableObject.d.ts +30 -0
- package/data-structures/object/TimeableObject.mjs +71 -0
- package/data-structures/object/WaitableObject.cjs +61 -0
- package/data-structures/object/WaitableObject.d.ts +29 -0
- package/data-structures/object/WaitableObject.mjs +59 -0
- package/data-structures/object/WatchableObject.cjs +251 -0
- package/data-structures/object/WatchableObject.d.ts +88 -0
- package/data-structures/object/WatchableObject.mjs +230 -0
- package/data-structures/object/index.d.ts +7 -0
- package/data-structures/object.cjs +23 -0
- package/data-structures/object.mjs +7 -0
- package/errors/AbortError.cjs +9 -0
- package/errors/AbortError.d.ts +5 -0
- package/errors/AbortError.mjs +7 -0
- package/errors/CallExecutionError.cjs +13 -0
- package/errors/CallExecutionError.d.ts +7 -0
- package/errors/CallExecutionError.mjs +11 -0
- package/errors/FutureCancelled.cjs +11 -0
- package/errors/FutureCancelled.d.ts +6 -0
- package/errors/FutureCancelled.mjs +9 -0
- package/errors/FutureError.cjs +11 -0
- package/errors/FutureError.d.ts +6 -0
- package/errors/FutureError.mjs +9 -0
- package/errors/IllegalArgumentsError.cjs +13 -0
- package/errors/IllegalArgumentsError.d.ts +7 -0
- package/errors/IllegalArgumentsError.mjs +11 -0
- package/errors/IllegalOperationError.cjs +6 -0
- package/errors/IllegalOperationError.d.ts +2 -0
- package/errors/IllegalOperationError.mjs +4 -0
- package/errors/InvalidType.cjs +6 -0
- package/errors/InvalidType.d.ts +2 -0
- package/errors/InvalidType.mjs +4 -0
- package/errors/InvalidValue.cjs +11 -0
- package/errors/InvalidValue.d.ts +4 -0
- package/errors/InvalidValue.mjs +9 -0
- package/errors/MissingArgumentsError.cjs +13 -0
- package/errors/MissingArgumentsError.d.ts +7 -0
- package/errors/MissingArgumentsError.mjs +11 -0
- package/errors/NetworkError.cjs +13 -0
- package/errors/NetworkError.d.ts +8 -0
- package/errors/NetworkError.mjs +11 -0
- package/errors/NoSuchElement.cjs +6 -0
- package/errors/NoSuchElement.d.ts +2 -0
- package/errors/NoSuchElement.mjs +4 -0
- package/errors/NotImplemented.cjs +9 -0
- package/errors/NotImplemented.d.ts +5 -0
- package/errors/NotImplemented.mjs +7 -0
- package/errors/ParsingError.cjs +10 -0
- package/errors/ParsingError.d.ts +5 -0
- package/errors/ParsingError.mjs +8 -0
- package/errors/QueueEmptyError.cjs +6 -0
- package/errors/QueueEmptyError.d.ts +2 -0
- package/errors/QueueEmptyError.mjs +4 -0
- package/errors/QueueFullError.cjs +6 -0
- package/errors/QueueFullError.d.ts +2 -0
- package/errors/QueueFullError.mjs +4 -0
- package/errors/StackEmptyError.cjs +6 -0
- package/errors/StackEmptyError.d.ts +2 -0
- package/errors/StackEmptyError.mjs +4 -0
- package/errors/StackFullError.cjs +6 -0
- package/errors/StackFullError.d.ts +2 -0
- package/errors/StackFullError.mjs +4 -0
- package/errors/StreamEnded.cjs +6 -0
- package/errors/StreamEnded.d.ts +2 -0
- package/errors/StreamEnded.mjs +4 -0
- package/errors/TimeoutError.cjs +11 -0
- package/errors/TimeoutError.d.ts +6 -0
- package/errors/TimeoutError.mjs +9 -0
- package/errors/ValueDestroyedError.cjs +6 -0
- package/errors/ValueDestroyedError.d.ts +2 -0
- package/errors/ValueDestroyedError.mjs +4 -0
- package/errors/VerificationError.cjs +9 -0
- package/errors/VerificationError.d.ts +5 -0
- package/errors/VerificationError.mjs +7 -0
- package/errors/index.d.ts +18 -0
- package/errors.cjs +41 -0
- package/errors.mjs +18 -0
- package/files.cjs +201 -0
- package/files.d.ts +31 -0
- package/files.mjs +180 -0
- package/functools/index.d.ts +31 -0
- package/functools.cjs +371 -0
- package/functools.mjs +334 -0
- package/future/future.cjs +570 -0
- package/future/future.d.ts +208 -0
- package/future/future.mjs +548 -0
- package/future/group.cjs +180 -0
- package/future/group.d.ts +82 -0
- package/future/group.mjs +159 -0
- package/future/index.d.ts +3 -0
- package/future/result.cjs +19 -0
- package/future/result.d.ts +18 -0
- package/future/result.mjs +17 -0
- package/future.cjs +11 -0
- package/future.mjs +3 -0
- package/managers/context.d.ts +8 -0
- package/managers/index.d.ts +1 -0
- package/managers.cjs +2 -0
- package/managers.mjs +1 -0
- package/mocks.cjs +301 -0
- package/mocks.d.ts +125 -0
- package/mocks.mjs +293 -0
- package/networking/EventSourceService.cjs +104 -0
- package/networking/EventSourceService.d.ts +11 -0
- package/networking/EventSourceService.mjs +83 -0
- package/networking/NetworkService.cjs +394 -0
- package/networking/NetworkService.d.ts +97 -0
- package/networking/NetworkService.mjs +373 -0
- package/networking/SocketService.cjs +218 -0
- package/networking/SocketService.d.ts +23 -0
- package/networking/SocketService.mjs +197 -0
- package/networking/decorators/index.d.ts +4 -0
- package/networking/decorators/options.cjs +289 -0
- package/networking/decorators/options.d.ts +148 -0
- package/networking/decorators/options.mjs +242 -0
- package/networking/decorators/requests.cjs +80 -0
- package/networking/decorators/requests.d.ts +34 -0
- package/networking/decorators/requests.mjs +52 -0
- package/networking/decorators/socket.cjs +81 -0
- package/networking/decorators/socket.d.ts +13 -0
- package/networking/decorators/socket.mjs +51 -0
- package/networking/http.cjs +69 -0
- package/networking/http.d.ts +66 -0
- package/networking/http.mjs +69 -0
- package/networking/index.d.ts +39 -0
- package/networking/request.cjs +18 -0
- package/networking/request.d.ts +9 -0
- package/networking/request.mjs +16 -0
- package/networking/types.cjs +37 -0
- package/networking/types.d.ts +132 -0
- package/networking/types.mjs +35 -0
- package/networking.cjs +91 -0
- package/networking.mjs +33 -0
- package/package.json +1 -0
- package/reflection/injector.cjs +43 -0
- package/reflection/injector.d.ts +3 -0
- package/reflection/injector.mjs +40 -0
- package/socket.cjs +239 -0
- package/socket.d.ts +65 -0
- package/socket.mjs +237 -0
- package/store.cjs +12 -0
- package/store.mjs +3 -0
- package/stream/call.cjs +157 -0
- package/stream/call.d.ts +66 -0
- package/stream/call.mjs +154 -0
- package/stream/collector.cjs +217 -0
- package/stream/collector.d.ts +14 -0
- package/stream/collector.mjs +215 -0
- package/stream/index.d.ts +257 -0
- package/stream/observable.cjs +110 -0
- package/stream/observable.d.ts +65 -0
- package/stream/observable.mjs +106 -0
- package/stream/state.cjs +10 -0
- package/stream/state.d.ts +5 -0
- package/stream/state.mjs +8 -0
- package/stream.cjs +1153 -0
- package/stream.mjs +1132 -0
- package/synchronize.cjs +106 -0
- package/synchronize.d.ts +54 -0
- package/synchronize.mjs +103 -0
- package/typing/types.d.ts +24 -0
- package/typing.cjs +2 -0
- package/typing.mjs +1 -0
- package/utils/parser.cjs +37 -0
- package/utils/parser.d.ts +7 -0
- package/utils/parser.mjs +16 -0
package/synchronize.cjs
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var future = require('./future/future.cjs');
|
|
4
|
+
require('ramda');
|
|
5
|
+
require('./stream.cjs');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* An event that is awaitable
|
|
9
|
+
*/
|
|
10
|
+
class FutureEvent {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.__internal__ = new EventTarget();
|
|
13
|
+
this.ready = false;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Checks if the event happened
|
|
17
|
+
*/
|
|
18
|
+
get isSet() {
|
|
19
|
+
return this.ready;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Waits for the event to occur
|
|
23
|
+
* @param period
|
|
24
|
+
*/
|
|
25
|
+
wait(period) {
|
|
26
|
+
const future$1 = future.Future.of((resolve, reject, signal) => {
|
|
27
|
+
if (!this.isSet) {
|
|
28
|
+
const readyCallback = () => resolve(this);
|
|
29
|
+
signal.onabort = () => this.__internal__.removeEventListener("ready", readyCallback);
|
|
30
|
+
this.__internal__.addEventListener("ready", readyCallback, { once: true });
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
resolve(this);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
if (period)
|
|
37
|
+
return future.Future.waitFor(future$1, period);
|
|
38
|
+
return future$1;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Notifies all listeners that the event has been triggered
|
|
42
|
+
*/
|
|
43
|
+
set() {
|
|
44
|
+
this.ready = true;
|
|
45
|
+
this.__internal__.dispatchEvent(new Event("ready"));
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Resets the event signals, returns to a 'waiting for event' state
|
|
49
|
+
*/
|
|
50
|
+
clear() {
|
|
51
|
+
this.ready = false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A mutex lock for asynchronous operations
|
|
56
|
+
*/
|
|
57
|
+
class Lock {
|
|
58
|
+
constructor() {
|
|
59
|
+
this.__locked__ = false;
|
|
60
|
+
this.evt = new FutureEvent();
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Checks if the current lock has been acquired
|
|
64
|
+
*/
|
|
65
|
+
get locked() {
|
|
66
|
+
return this.__locked__;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Acquire and release the lock irrespective of the provided function failing.
|
|
70
|
+
* The function can also return data to the invoker of the with() context
|
|
71
|
+
* @param functor
|
|
72
|
+
*/
|
|
73
|
+
with(functor) {
|
|
74
|
+
return this.acquire()
|
|
75
|
+
.thenApply(functor)
|
|
76
|
+
.finally(() => this.release());
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Attempts to acquire the lock
|
|
80
|
+
* @param waitPeriod
|
|
81
|
+
*/
|
|
82
|
+
acquire(waitPeriod) {
|
|
83
|
+
if (this.locked) {
|
|
84
|
+
return this.evt.wait(waitPeriod).thenApply(() => {
|
|
85
|
+
if (this.locked)
|
|
86
|
+
return this.acquire(waitPeriod);
|
|
87
|
+
this.evt.clear();
|
|
88
|
+
this.__locked__ = true;
|
|
89
|
+
return this;
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
this.evt.clear();
|
|
93
|
+
this.__locked__ = true;
|
|
94
|
+
return future.Future.completed(this);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Releases the lock, allowing the next waiting call to acquire the lock
|
|
98
|
+
*/
|
|
99
|
+
release() {
|
|
100
|
+
this.__locked__ = false;
|
|
101
|
+
this.evt.set();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
exports.FutureEvent = FutureEvent;
|
|
106
|
+
exports.Lock = Lock;
|
package/synchronize.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Future, FutureResult, WaitPeriod } from "./future";
|
|
2
|
+
import { ContextManager } from "./managers";
|
|
3
|
+
/**
|
|
4
|
+
* An event that is awaitable
|
|
5
|
+
*/
|
|
6
|
+
export declare class FutureEvent {
|
|
7
|
+
private readonly __internal__;
|
|
8
|
+
private ready;
|
|
9
|
+
constructor();
|
|
10
|
+
/**
|
|
11
|
+
* Checks if the event happened
|
|
12
|
+
*/
|
|
13
|
+
get isSet(): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Waits for the event to occur
|
|
16
|
+
* @param period
|
|
17
|
+
*/
|
|
18
|
+
wait(period?: WaitPeriod): Future<FutureEvent>;
|
|
19
|
+
/**
|
|
20
|
+
* Notifies all listeners that the event has been triggered
|
|
21
|
+
*/
|
|
22
|
+
set(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Resets the event signals, returns to a 'waiting for event' state
|
|
25
|
+
*/
|
|
26
|
+
clear(): void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A mutex lock for asynchronous operations
|
|
30
|
+
*/
|
|
31
|
+
export declare class Lock implements ContextManager<Lock> {
|
|
32
|
+
private __locked__;
|
|
33
|
+
private readonly evt;
|
|
34
|
+
constructor();
|
|
35
|
+
/**
|
|
36
|
+
* Checks if the current lock has been acquired
|
|
37
|
+
*/
|
|
38
|
+
get locked(): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Acquire and release the lock irrespective of the provided function failing.
|
|
41
|
+
* The function can also return data to the invoker of the with() context
|
|
42
|
+
* @param functor
|
|
43
|
+
*/
|
|
44
|
+
with<K>(functor: (value: FutureResult<Lock>) => K): Future<import("./future/result").InferredFutureResult<K>>;
|
|
45
|
+
/**
|
|
46
|
+
* Attempts to acquire the lock
|
|
47
|
+
* @param waitPeriod
|
|
48
|
+
*/
|
|
49
|
+
acquire(waitPeriod?: WaitPeriod): Future<Lock>;
|
|
50
|
+
/**
|
|
51
|
+
* Releases the lock, allowing the next waiting call to acquire the lock
|
|
52
|
+
*/
|
|
53
|
+
release(): void;
|
|
54
|
+
}
|
package/synchronize.mjs
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { Future } from './future/future.mjs';
|
|
2
|
+
import 'ramda';
|
|
3
|
+
import './stream.mjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* An event that is awaitable
|
|
7
|
+
*/
|
|
8
|
+
class FutureEvent {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.__internal__ = new EventTarget();
|
|
11
|
+
this.ready = false;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Checks if the event happened
|
|
15
|
+
*/
|
|
16
|
+
get isSet() {
|
|
17
|
+
return this.ready;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Waits for the event to occur
|
|
21
|
+
* @param period
|
|
22
|
+
*/
|
|
23
|
+
wait(period) {
|
|
24
|
+
const future = Future.of((resolve, reject, signal) => {
|
|
25
|
+
if (!this.isSet) {
|
|
26
|
+
const readyCallback = () => resolve(this);
|
|
27
|
+
signal.onabort = () => this.__internal__.removeEventListener("ready", readyCallback);
|
|
28
|
+
this.__internal__.addEventListener("ready", readyCallback, { once: true });
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
resolve(this);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
if (period)
|
|
35
|
+
return Future.waitFor(future, period);
|
|
36
|
+
return future;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Notifies all listeners that the event has been triggered
|
|
40
|
+
*/
|
|
41
|
+
set() {
|
|
42
|
+
this.ready = true;
|
|
43
|
+
this.__internal__.dispatchEvent(new Event("ready"));
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Resets the event signals, returns to a 'waiting for event' state
|
|
47
|
+
*/
|
|
48
|
+
clear() {
|
|
49
|
+
this.ready = false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A mutex lock for asynchronous operations
|
|
54
|
+
*/
|
|
55
|
+
class Lock {
|
|
56
|
+
constructor() {
|
|
57
|
+
this.__locked__ = false;
|
|
58
|
+
this.evt = new FutureEvent();
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Checks if the current lock has been acquired
|
|
62
|
+
*/
|
|
63
|
+
get locked() {
|
|
64
|
+
return this.__locked__;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Acquire and release the lock irrespective of the provided function failing.
|
|
68
|
+
* The function can also return data to the invoker of the with() context
|
|
69
|
+
* @param functor
|
|
70
|
+
*/
|
|
71
|
+
with(functor) {
|
|
72
|
+
return this.acquire()
|
|
73
|
+
.thenApply(functor)
|
|
74
|
+
.finally(() => this.release());
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Attempts to acquire the lock
|
|
78
|
+
* @param waitPeriod
|
|
79
|
+
*/
|
|
80
|
+
acquire(waitPeriod) {
|
|
81
|
+
if (this.locked) {
|
|
82
|
+
return this.evt.wait(waitPeriod).thenApply(() => {
|
|
83
|
+
if (this.locked)
|
|
84
|
+
return this.acquire(waitPeriod);
|
|
85
|
+
this.evt.clear();
|
|
86
|
+
this.__locked__ = true;
|
|
87
|
+
return this;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
this.evt.clear();
|
|
91
|
+
this.__locked__ = true;
|
|
92
|
+
return Future.completed(this);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Releases the lock, allowing the next waiting call to acquire the lock
|
|
96
|
+
*/
|
|
97
|
+
release() {
|
|
98
|
+
this.__locked__ = false;
|
|
99
|
+
this.evt.set();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export { FutureEvent, Lock };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { WaitableObject, WatchableObject } from "../data-structures/object";
|
|
2
|
+
import { Stream } from "../stream";
|
|
3
|
+
import { Future } from "../future";
|
|
4
|
+
import { InferredFutureResult } from "../future/result";
|
|
5
|
+
import { ExecutorState } from "../stream/state";
|
|
6
|
+
export interface ObjectOf<T> {
|
|
7
|
+
[string: string]: T;
|
|
8
|
+
}
|
|
9
|
+
export type AnyObject = {
|
|
10
|
+
[string: string]: AnyDataType;
|
|
11
|
+
} | Map<string, AnyDataType>;
|
|
12
|
+
export type AnyDataType = AnyObject | Blob | void | Response | AnyObject[] | string | string[] | number | number[] | boolean | undefined | null | Date | RegExp | Map<any, any> | WaitableObject<any, any> | WatchableObject<any, any> | boolean[] | File | File[];
|
|
13
|
+
export type AnyType = AnyDataType | Function | Promise<AnyDataType>;
|
|
14
|
+
export type Flattened<T> = T extends Array<infer U> ? Flattened<U> : T;
|
|
15
|
+
export type InferStreamResult<T> = T extends Stream<infer U> ? InferStreamResult<U> : T extends Future<infer U> ? InferredFutureResult<U> : T extends ExecutorState<infer U> ? U : T;
|
|
16
|
+
export type FlagExcludedType<Base, Type> = {
|
|
17
|
+
[Key in keyof Base]: Base[Key] extends Type ? never : Key;
|
|
18
|
+
};
|
|
19
|
+
export type AllowedNames<Base, Type> = FlagExcludedType<Base, Type>[keyof Base];
|
|
20
|
+
export type OmitType<Base, Type> = Pick<Base, AllowedNames<Base, Type>>;
|
|
21
|
+
export type InferErrorResult<T, K> = T extends undefined | null ? K : T;
|
|
22
|
+
export type UnaryFunctor<K, V> = (v: K) => V;
|
|
23
|
+
export type BinaryFunctor<K1, K2, V> = (v1: K1, v2: K2) => V;
|
|
24
|
+
export type TernaryFunctor<K1, K2, K3, V> = (v1: K1, v2: K2, v3: K3) => V;
|
package/typing.cjs
ADDED
package/typing.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/utils/parser.cjs
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var R = require('ramda');
|
|
4
|
+
|
|
5
|
+
function _interopNamespaceDefault(e) {
|
|
6
|
+
var n = Object.create(null);
|
|
7
|
+
if (e) {
|
|
8
|
+
Object.keys(e).forEach(function (k) {
|
|
9
|
+
if (k !== 'default') {
|
|
10
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
11
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return e[k]; }
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
n.default = e;
|
|
19
|
+
return Object.freeze(n);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var R__namespace = /*#__PURE__*/_interopNamespaceDefault(R);
|
|
23
|
+
|
|
24
|
+
const parse = R__namespace.curry((mapping, data) => {
|
|
25
|
+
if (typeof data === "string") {
|
|
26
|
+
return mapping.string(data);
|
|
27
|
+
}
|
|
28
|
+
else if (mapping.supportArray && (Array.isArray(data) || data instanceof Array)) {
|
|
29
|
+
return data.map((v) => parse(mapping, v));
|
|
30
|
+
}
|
|
31
|
+
else if (!(Array.isArray(data) || data instanceof Array) && typeof data === "object") {
|
|
32
|
+
return mapping.object(data);
|
|
33
|
+
}
|
|
34
|
+
return mapping.default(data);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
exports.parse = parse;
|
package/utils/parser.mjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as R from 'ramda';
|
|
2
|
+
|
|
3
|
+
const parse = R.curry((mapping, data) => {
|
|
4
|
+
if (typeof data === "string") {
|
|
5
|
+
return mapping.string(data);
|
|
6
|
+
}
|
|
7
|
+
else if (mapping.supportArray && (Array.isArray(data) || data instanceof Array)) {
|
|
8
|
+
return data.map((v) => parse(mapping, v));
|
|
9
|
+
}
|
|
10
|
+
else if (!(Array.isArray(data) || data instanceof Array) && typeof data === "object") {
|
|
11
|
+
return mapping.object(data);
|
|
12
|
+
}
|
|
13
|
+
return mapping.default(data);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export { parse };
|