@woosh/meep-engine 2.81.4 → 2.83.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/build/meep.cjs +4398 -4421
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +4398 -4421
- package/editor/ecs/component/editors/primitive/ArrayEditor.js +2 -2
- package/editor/enableEditor.js +1 -1
- package/editor/view/EditorView.js +25 -25
- package/editor/view/ecs/components/particles/ParticleEmitterController.js +11 -11
- package/editor/view/node-graph/NodeView.js +7 -7
- package/package.json +1 -1
- package/samples/terrain/editor.js +19 -18
- package/src/core/cache/Cache.js +4 -2
- package/src/core/cache/Cache.spec.js +1 -1
- package/src/core/collection/RingBuffer.js +6 -0
- package/src/core/collection/array/arraySetDiff.js +8 -2
- package/src/core/collection/array/groupArrayBy.js +1 -1
- package/src/core/collection/array/weightedRandomFromArray.spec.js +3 -1
- package/src/core/collection/heap/FastBinaryHeap.spec.js +3 -2
- package/src/core/collection/list/List.js +8 -17
- package/src/core/collection/list/List.spec.js +55 -0
- package/src/core/collection/map/HashMap.spec.js +3 -1
- package/src/core/collection/set/HashSet.spec.js +23 -0
- package/src/core/events/signal/signal_aggregate_by_time_window.js +1 -1
- package/src/core/fsm/simple/SimpleStateMachine.js +2 -1
- package/src/core/function/chain.js +19 -0
- package/src/core/function/makeReturnValue.js +8 -0
- package/src/core/function/noop.js +6 -0
- package/src/core/function/objectsEqual.js +14 -0
- package/src/core/function/passThrough.js +9 -0
- package/src/core/function/returnEmptyArray.js +7 -0
- package/src/core/function/returnFalse.js +7 -0
- package/src/core/function/returnOne.js +7 -0
- package/src/core/function/returnTrue.js +7 -0
- package/src/core/function/returnZero.js +7 -0
- package/src/core/function/strictEquals.js +10 -0
- package/src/core/geom/3d/tetrahedra/validate_tetrahedral_mesh.js +2 -2
- package/src/core/geom/3d/topology/struct/prototypeBinaryTopology.js +5 -4
- package/src/core/lang/reactive/AbstractCachingParser.js +2 -1
- package/src/core/math/random/randomFloatBetween.spec.js +2 -1
- package/src/core/math/random/randomIntegerBetween.spec.js +2 -1
- package/src/core/model/node-graph/Connection.js +2 -1
- package/src/core/model/node-graph/node/parameter/NodeParameterDescription.js +2 -2
- package/src/core/model/object/ObjectPoolFactory.js +2 -1
- package/src/core/model/stat/Stat.js +4 -4
- package/src/core/process/PromiseWatcher.spec.js +1 -1
- package/src/core/process/task/Task.js +2 -1
- package/src/engine/EngineHarness.js +2 -1
- package/src/engine/achievements/gateway/StorageAchievementGateway.js +1 -1
- package/src/engine/asset/AssetManager.js +14 -14
- package/src/engine/asset/loaders/ArrayBufferLoader.js +1 -1
- package/src/engine/ecs/EntityComponentDataset.spec.js +2 -2
- package/src/engine/ecs/EntityManager.js +2 -1
- package/src/engine/ecs/EntityObserver.spec.js +4 -4
- package/src/engine/ecs/System.js +2 -2
- package/src/engine/ecs/dynamic_actions/DynamicActorSystem.js +2 -1
- package/src/engine/ecs/ik/IKProblem.js +1 -1
- package/src/engine/ecs/storage/binary/collection/BinaryCollectionDeSerializer.js +2 -1
- package/src/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.js +2 -1
- package/src/engine/ecs/terrain/ecs/TerrainSystem.js +2 -1
- package/src/engine/ecs/terrain/tiles/TerrainTileManager.js +2 -1
- package/src/engine/ecs/terrain/util/obtainTerrain.js +1 -1
- package/src/engine/ecs/terrain/util/paintTerrainOverlayViaLookupTable.js +3 -3
- package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +15 -8
- package/src/engine/graphics/ecs/highlight/plugin/OutlineRenderPlugin.js +7 -7
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +2 -1
- package/src/engine/graphics/material/SplatMaterial.js +1 -15
- package/src/engine/graphics/render/layers/RenderLayer.js +1 -1
- package/src/engine/graphics/render/utils/ThreeBypassRenderer.js +2 -1
- package/src/engine/graphics/render/visibility/VisibilityFilter.js +2 -1
- package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +2 -1
- package/src/engine/graphics/texture/atlas/ManagedTextureAtlas.js +5 -5
- package/src/engine/graphics/texture/cubemap/load_environment_map.js +2 -2
- package/src/engine/graphics/texture/makeOnePixelTexture.js +5 -3
- package/src/engine/graphics/texture/virtual/VirtualTexturePage.js +2 -1
- package/src/engine/graphics/texture/whitePixelTexture.js +9 -0
- package/src/engine/intelligence/behavior/ecs/BehaviorSystem.spec.js +5 -5
- package/src/engine/intelligence/blackboard/BlackboardDynamicStorageAdapter.js +3 -3
- package/src/engine/intelligence/mcts/MonteCarlo.js +3 -3
- package/src/engine/knowledge/database/StaticKnowledgeDataTable.js +3 -3
- package/src/engine/network/PriorityFetch.js +2 -2
- package/src/engine/options/Option.js +2 -2
- package/src/engine/options/Option.spec.js +1 -1
- package/src/engine/options/OptionGroup.js +2 -2
- package/src/engine/options/OptionGroup.spec.js +2 -2
- package/src/engine/save/Storage.js +2 -1
- package/src/engine/save/StorageBackedList.js +2 -1
- package/src/engine/save/storage/InMemoryStorage.js +2 -2
- package/src/engine/scene/transitionToScene.js +2 -1
- package/src/engine/sound/ecs/SoundListenerSystem.js +7 -7
- package/src/engine/sound/ecs/emitter/loadSoundTrackAsset.js +3 -3
- package/src/engine/ui/DraggableAspect.js +2 -2
- package/src/engine/ui/GUIEngine.js +17 -17
- package/src/engine/ui/notification/AnimatedObjectEmitter.js +3 -3
- package/src/engine/ui/notification/NotificationManager.js +4 -4
- package/src/generation/grid/generation/discrete/GridTaskConnectRooms.js +9 -9
- package/src/generation/grid/generation/util/buildPathFromDistanceMap.js +1 -1
- package/src/generation/markers/actions/util/GridCellActionDebugBreak.js +1 -1
- package/src/view/common/LabelView.js +9 -9
- package/src/view/common/ListView.js +3 -2
- package/src/view/common/VirtualListView.js +7 -6
- package/src/view/common/dnd/DropTarget.js +2 -2
- package/src/view/elements/DropDownSelectionView.js +2 -2
- package/src/view/elements/image/ImageView.js +4 -4
- package/src/view/elements/progress/SmoothProgressBar.js +4 -4
- package/src/view/elements/radial/RadialMenuElementDefinition.js +1 -1
- package/src/view/elements/tiles2d/TileGrid.js +8 -8
- package/src/view/elements/video/VideoView.js +5 -5
- package/src/view/math/FunctionGraphView.js +1 -1
- package/src/view/tooltip/gml/TooltipParser.js +6 -5
- package/src/core/collection/map/AsyncLoadingCache.js +0 -50
- package/src/core/collection/map/AsyncRemoteHashMap.js +0 -358
- package/src/core/function/Functions.js +0 -103
|
@@ -1,358 +0,0 @@
|
|
|
1
|
-
import { assert } from "../../assert.js";
|
|
2
|
-
import { BinaryBuffer } from "../../binary/BinaryBuffer.js";
|
|
3
|
-
import { AbstractAsyncMap } from "./AbstractAsyncMap.js";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @template Key,Value
|
|
7
|
-
*/
|
|
8
|
-
export class AsyncRemoteHashMap extends AbstractAsyncMap {
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* @param keyHashFunction
|
|
13
|
-
* @param keyEqualityFunction
|
|
14
|
-
* @param {BinaryClassSerializationAdapter} keySerializationAdapter
|
|
15
|
-
* @param {BinaryClassSerializationAdapter} valueSerializationAdapter
|
|
16
|
-
* @param storageKeyPrefix
|
|
17
|
-
* @param {Storage} storage
|
|
18
|
-
*/
|
|
19
|
-
constructor({
|
|
20
|
-
keyHashFunction,
|
|
21
|
-
keyEqualityFunction,
|
|
22
|
-
keySerializationAdapter,
|
|
23
|
-
valueSerializationAdapter,
|
|
24
|
-
storageKeyPrefix,
|
|
25
|
-
storage
|
|
26
|
-
}) {
|
|
27
|
-
super();
|
|
28
|
-
|
|
29
|
-
assert.isString(storageKeyPrefix, 'storageKeyPrefix');
|
|
30
|
-
|
|
31
|
-
this._keyHashFunction = keyHashFunction;
|
|
32
|
-
this._keyEqualityFunction = keyEqualityFunction;
|
|
33
|
-
this._keySerializationAdapter = keySerializationAdapter;
|
|
34
|
-
this._valueSerializationAdapter = valueSerializationAdapter;
|
|
35
|
-
this._storageKeyPrefix = storageKeyPrefix;
|
|
36
|
-
this._storage = storage;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
*
|
|
40
|
-
* @type {Map<number,Promise>}
|
|
41
|
-
* @private
|
|
42
|
-
*/
|
|
43
|
-
this._bucket_locks = new Map();
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
*
|
|
48
|
-
* @param {Storage} storage
|
|
49
|
-
*/
|
|
50
|
-
attach_storage(storage) {
|
|
51
|
-
this._storage = storage;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
detach_storage() {
|
|
55
|
-
this._storage = null;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
async __get_bucket_lock(hash) {
|
|
59
|
-
let source_lock = this._bucket_locks.get(hash);
|
|
60
|
-
if (source_lock === undefined) {
|
|
61
|
-
source_lock = Promise.resolve();
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
let is_resolved = false;
|
|
65
|
-
const lock_object = {
|
|
66
|
-
release() {
|
|
67
|
-
is_resolved = true;
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const release_promise = new Promise((resolve, reject) => {
|
|
72
|
-
lock_object.release = resolve;
|
|
73
|
-
|
|
74
|
-
if (is_resolved) {
|
|
75
|
-
resolve();
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
const new_lock = source_lock.then(() => release_promise);
|
|
80
|
-
|
|
81
|
-
this._bucket_locks.set(hash, new_lock);
|
|
82
|
-
|
|
83
|
-
await source_lock;
|
|
84
|
-
|
|
85
|
-
return lock_object;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* @param {number} hash
|
|
90
|
-
* @return {Promise<ArrayBuffer|undefined>}
|
|
91
|
-
* @private
|
|
92
|
-
*/
|
|
93
|
-
__get_bucket_binary(hash) {
|
|
94
|
-
return this._storage.promiseLoadBinary(this.__compute_bucket_storage_key(hash)).catch(() => {
|
|
95
|
-
return undefined;
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
__compute_bucket_storage_key(hash) {
|
|
100
|
-
return `${this._storageKeyPrefix}/${hash}`;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
*
|
|
105
|
-
* @param {number} hash
|
|
106
|
-
* @param {ArrayBuffer} bucket
|
|
107
|
-
* @return {Promise}
|
|
108
|
-
* @private
|
|
109
|
-
*/
|
|
110
|
-
__set_bucket_binary(hash, bucket) {
|
|
111
|
-
return this._storage.promiseStoreBinary(this.__compute_bucket_storage_key(hash), bucket);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
*
|
|
116
|
-
* @param {Key} key
|
|
117
|
-
* @param {Value|undefined} value
|
|
118
|
-
* @param {ArrayBuffer} buffer
|
|
119
|
-
* @return {ArrayBuffer}
|
|
120
|
-
* @private
|
|
121
|
-
*/
|
|
122
|
-
__set_value_by_key_in_bucket(key, value, buffer) {
|
|
123
|
-
const source = new BinaryBuffer();
|
|
124
|
-
source.fromArrayBuffer(buffer);
|
|
125
|
-
|
|
126
|
-
const record_count = buffer.byteLength >= 2 ? source.readUint16() : 0;
|
|
127
|
-
|
|
128
|
-
let new_record_count = record_count;
|
|
129
|
-
|
|
130
|
-
// first attempt to find the key
|
|
131
|
-
const existing_value_address = this.__get_value_offset_from_bucket_by_key(key, buffer);
|
|
132
|
-
|
|
133
|
-
if (existing_value_address === -1) {
|
|
134
|
-
new_record_count++;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const destination = new BinaryBuffer();
|
|
138
|
-
destination.writeUint16(new_record_count);
|
|
139
|
-
|
|
140
|
-
let destination_data_offset = 2 + 16 * new_record_count;
|
|
141
|
-
let write_cursor = 0;
|
|
142
|
-
// copy old record over
|
|
143
|
-
for (let i = 0; i < record_count; i++) {
|
|
144
|
-
source.position = 2 + i * 16;
|
|
145
|
-
|
|
146
|
-
const key_position = source.readUint32();
|
|
147
|
-
const key_length = source.readUint32();
|
|
148
|
-
const value_position = source.readUint32();
|
|
149
|
-
const value_length = source.readUint32();
|
|
150
|
-
|
|
151
|
-
if (existing_value_address !== -1 && value_position === existing_value_address) {
|
|
152
|
-
// skip
|
|
153
|
-
continue;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// write key + value
|
|
157
|
-
destination.position = 2 + write_cursor * 16;
|
|
158
|
-
|
|
159
|
-
// write header section
|
|
160
|
-
destination.writeUint32(destination_data_offset);
|
|
161
|
-
destination.writeUint32(key_length);
|
|
162
|
-
destination.writeUint32(destination_data_offset + key_length);
|
|
163
|
-
destination.writeUint32(value_length);
|
|
164
|
-
|
|
165
|
-
destination.position = destination_data_offset;
|
|
166
|
-
source.position = key_position;
|
|
167
|
-
BinaryBuffer.copyBytes(source, destination, key_length);
|
|
168
|
-
|
|
169
|
-
destination_data_offset += key_length;
|
|
170
|
-
|
|
171
|
-
destination.position = destination_data_offset;
|
|
172
|
-
source.position = value_position;
|
|
173
|
-
BinaryBuffer.copyBytes(source, destination, value_length);
|
|
174
|
-
|
|
175
|
-
destination_data_offset += value_length;
|
|
176
|
-
|
|
177
|
-
write_cursor++;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const inserted_key_address = destination_data_offset;
|
|
181
|
-
const inserted_key_length = this.__encode_object(destination, inserted_key_address, key, this._keySerializationAdapter);
|
|
182
|
-
|
|
183
|
-
destination_data_offset += inserted_key_length;
|
|
184
|
-
const inserted_value_address = destination_data_offset;
|
|
185
|
-
const inserted_value_length = this.__encode_object(destination, inserted_value_address, value, this._valueSerializationAdapter);
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
// write section for the new value
|
|
189
|
-
destination.position = 2 + 16 * write_cursor;
|
|
190
|
-
destination.writeUint32(inserted_key_address);
|
|
191
|
-
destination.writeUint32(inserted_key_length);
|
|
192
|
-
destination.writeUint32(inserted_value_address);
|
|
193
|
-
destination.writeUint32(inserted_value_length);
|
|
194
|
-
|
|
195
|
-
// restore position
|
|
196
|
-
destination.position = inserted_value_address + inserted_value_length;
|
|
197
|
-
|
|
198
|
-
destination.trim();
|
|
199
|
-
|
|
200
|
-
return destination.data;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
*
|
|
205
|
-
* @param {Key} key
|
|
206
|
-
* @param {ArrayBuffer} buffer
|
|
207
|
-
* @return {number} -1 if not found, otherwise address within the buffer where the value can be read
|
|
208
|
-
* @private
|
|
209
|
-
*/
|
|
210
|
-
__get_value_offset_from_bucket_by_key(key, buffer) {
|
|
211
|
-
const binary = new BinaryBuffer();
|
|
212
|
-
binary.fromArrayBuffer(buffer);
|
|
213
|
-
|
|
214
|
-
if (binary.length < 2) {
|
|
215
|
-
return -1;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
const record_count = binary.readUint16();
|
|
219
|
-
|
|
220
|
-
if (record_count === 0) {
|
|
221
|
-
return -1;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
const key_offsets = new Uint32Array(record_count);
|
|
225
|
-
const value_offsets = new Uint32Array(record_count);
|
|
226
|
-
|
|
227
|
-
// read record offsets
|
|
228
|
-
for (let i = 0; i < record_count; i++) {
|
|
229
|
-
const key_offset = binary.readUint32();
|
|
230
|
-
const key_length = binary.readUint32();
|
|
231
|
-
|
|
232
|
-
const value_offset = binary.readUint32();
|
|
233
|
-
const value_length = binary.readUint32();
|
|
234
|
-
|
|
235
|
-
key_offsets[i] = key_offset;
|
|
236
|
-
value_offsets[i] = value_offset;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// read key
|
|
240
|
-
for (let i = 0; i < record_count; i++) {
|
|
241
|
-
const key_address = key_offsets[i];
|
|
242
|
-
|
|
243
|
-
const stored_key = this.__decode_object(binary, key_address, this._keySerializationAdapter);
|
|
244
|
-
|
|
245
|
-
if (this._keyEqualityFunction(stored_key, key)) {
|
|
246
|
-
return value_offsets[i]
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
return -1;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
*
|
|
255
|
-
* @param {BinaryBuffer} buffer
|
|
256
|
-
* @param {number} address
|
|
257
|
-
* @param {BinaryClassSerializationAdapter} adapter
|
|
258
|
-
* @return {Value}
|
|
259
|
-
* @private
|
|
260
|
-
*/
|
|
261
|
-
__decode_object(buffer, address, adapter) {
|
|
262
|
-
|
|
263
|
-
buffer.position = address;
|
|
264
|
-
|
|
265
|
-
const ValueKlass = adapter.getClass();
|
|
266
|
-
|
|
267
|
-
const value = new ValueKlass();
|
|
268
|
-
|
|
269
|
-
adapter.deserialize(buffer, value);
|
|
270
|
-
|
|
271
|
-
return value;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* @template T
|
|
276
|
-
* @param {BinaryBuffer} buffer
|
|
277
|
-
* @param {number} address
|
|
278
|
-
* @param {T} value
|
|
279
|
-
* @param {BinaryClassSerializationAdapter} adapter
|
|
280
|
-
* @returns {number} bytes written
|
|
281
|
-
* @private
|
|
282
|
-
*/
|
|
283
|
-
__encode_object(buffer, address, value, adapter) {
|
|
284
|
-
buffer.position = address;
|
|
285
|
-
|
|
286
|
-
adapter.serialize(buffer, value);
|
|
287
|
-
|
|
288
|
-
const bytes_written = buffer.position - address;
|
|
289
|
-
|
|
290
|
-
return bytes_written;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
*
|
|
295
|
-
* @param {BinaryBuffer} buffer
|
|
296
|
-
* @param {number} address
|
|
297
|
-
* @return {Value}
|
|
298
|
-
* @private
|
|
299
|
-
*/
|
|
300
|
-
__decode_value(buffer, address) {
|
|
301
|
-
return this.__decode_object(buffer, address, this._valueSerializationAdapter);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
*
|
|
306
|
-
* @param {Key} key
|
|
307
|
-
* @return {Promise<Value|undefined>}
|
|
308
|
-
*/
|
|
309
|
-
async get(key) {
|
|
310
|
-
// hash the key to identify bucket to load
|
|
311
|
-
const key_hash = this._keyHashFunction(key);
|
|
312
|
-
|
|
313
|
-
const lock = await this.__get_bucket_lock(key_hash);
|
|
314
|
-
|
|
315
|
-
const bucket_buffer = await this.__get_bucket_binary(key_hash);
|
|
316
|
-
|
|
317
|
-
lock.release();
|
|
318
|
-
|
|
319
|
-
if (bucket_buffer === undefined) {
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
const value_address = this.__get_value_offset_from_bucket_by_key(key, bucket_buffer);
|
|
324
|
-
|
|
325
|
-
if (value_address === -1) {
|
|
326
|
-
return;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
const binary = new BinaryBuffer();
|
|
330
|
-
binary.fromArrayBuffer(bucket_buffer);
|
|
331
|
-
|
|
332
|
-
return this.__decode_value(binary, value_address);
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
*
|
|
337
|
-
* @param {Key} key
|
|
338
|
-
* @param {Value} value
|
|
339
|
-
* @return {Promise<void>}
|
|
340
|
-
*/
|
|
341
|
-
async set(key, value) {
|
|
342
|
-
const key_hash = this._keyHashFunction(key);
|
|
343
|
-
|
|
344
|
-
const lock = await this.__get_bucket_lock(key_hash);
|
|
345
|
-
|
|
346
|
-
let bucket_buffer = await this.__get_bucket_binary(key_hash);
|
|
347
|
-
|
|
348
|
-
if (bucket_buffer === undefined) {
|
|
349
|
-
bucket_buffer = new ArrayBuffer(0);
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
const updated_buffer = this.__set_value_by_key_in_bucket(key, value, bucket_buffer);
|
|
353
|
-
|
|
354
|
-
await this.__set_bucket_binary(key_hash, updated_buffer);
|
|
355
|
-
|
|
356
|
-
lock.release();
|
|
357
|
-
}
|
|
358
|
-
}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Collection of useful pure function. Saves having to allocate memory for new anonymous or arrow function. They also come with useful names.
|
|
3
|
-
* @author Alex Goldring
|
|
4
|
-
* @copyright Alex Goldring 2018
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* No-operation function. Does nothing. Useful when a callback is required to avoid checks for a missing function.
|
|
9
|
-
* @param {*} arguments
|
|
10
|
-
*/
|
|
11
|
-
export function noop() {
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Returns boolean true value.
|
|
16
|
-
* @returns {boolean} always true
|
|
17
|
-
*/
|
|
18
|
-
export function returnTrue() {
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Returns boolean false value.
|
|
24
|
-
* @returns {boolean} always false
|
|
25
|
-
*/
|
|
26
|
-
export function returnFalse() {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
*
|
|
32
|
-
* @returns {number} always 0
|
|
33
|
-
*/
|
|
34
|
-
export function returnZero() {
|
|
35
|
-
return 0;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
*
|
|
40
|
-
* @returns {number} always 1
|
|
41
|
-
*/
|
|
42
|
-
export function returnOne() {
|
|
43
|
-
return 1;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* @template T
|
|
49
|
-
* @returns {T[]}
|
|
50
|
-
*/
|
|
51
|
-
export function returnEmptyArray() {
|
|
52
|
-
return [];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* @template T
|
|
57
|
-
* @param {T} v
|
|
58
|
-
* @returns {function():T}
|
|
59
|
-
*/
|
|
60
|
-
export function makeReturnValue(v) {
|
|
61
|
-
return () => v;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @template A
|
|
66
|
-
* @param {A} a
|
|
67
|
-
* @returns {A}
|
|
68
|
-
*/
|
|
69
|
-
export function passThrough(a) {
|
|
70
|
-
return a;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* @template A
|
|
75
|
-
* @param {A} a
|
|
76
|
-
* @param {A} b
|
|
77
|
-
* @returns {boolean}
|
|
78
|
-
*/
|
|
79
|
-
export function strictEquals(a, b) {
|
|
80
|
-
return a === b;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
*
|
|
85
|
-
* @param {...function} processes
|
|
86
|
-
* @returns {function(*): *}
|
|
87
|
-
*/
|
|
88
|
-
export function chainFunctions(...processes) {
|
|
89
|
-
const numProcesses = processes.length;
|
|
90
|
-
|
|
91
|
-
return function chain(v) {
|
|
92
|
-
let result = v;
|
|
93
|
-
|
|
94
|
-
for (let i = 0; i < numProcesses; i++) {
|
|
95
|
-
const process = processes[i];
|
|
96
|
-
result = process(result);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return result;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|