@daiso-tech/core 0.15.0 → 0.17.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/cjs/_module.js +2 -2
- package/dist/cjs/_module.js.map +1 -1
- package/dist/cjs/async/_module.js +1 -1
- package/dist/cjs/async/_module.js.map +1 -1
- package/dist/cjs/async/backof-policies/_module.js +1 -0
- package/dist/cjs/async/backof-policies/_module.js.map +1 -1
- package/dist/cjs/async/utilities/_module.js +3 -0
- package/dist/cjs/async/utilities/_module.js.map +1 -1
- package/dist/cjs/async/utilities/lazy-promise/lazy-promise.js +21 -12
- package/dist/cjs/async/utilities/lazy-promise/lazy-promise.js.map +1 -1
- package/dist/cjs/cache/contracts/cache.events.js +168 -0
- package/dist/cjs/cache/contracts/cache.events.js.map +1 -1
- package/dist/cjs/cache/implementations/_shared/_module.js +1 -0
- package/dist/cjs/cache/implementations/_shared/_module.js.map +1 -1
- package/dist/cjs/cache/implementations/_shared/cache-adapter.test-suite.js +256 -177
- package/dist/cjs/cache/implementations/_shared/cache-adapter.test-suite.js.map +1 -1
- package/dist/cjs/cache/implementations/_shared/cache.test-suite.js +23 -2
- package/dist/cjs/cache/implementations/_shared/cache.test-suite.js.map +1 -1
- package/dist/cjs/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.js +63 -20
- package/dist/cjs/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.js.map +1 -1
- package/dist/cjs/cache/implementations/adapters/libsql-cache-adapter/_module.js +2 -1
- package/dist/cjs/cache/implementations/adapters/libsql-cache-adapter/_module.js.map +1 -1
- package/dist/cjs/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter-settings.js +56 -0
- package/dist/cjs/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter-settings.js.map +1 -0
- package/dist/cjs/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js +30 -16
- package/dist/cjs/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js.map +1 -1
- package/dist/cjs/cache/implementations/adapters/memory-cache-adapter/_module.js +1 -0
- package/dist/cjs/cache/implementations/adapters/memory-cache-adapter/_module.js.map +1 -1
- package/dist/cjs/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter-settings.js +26 -0
- package/dist/cjs/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter-settings.js.map +1 -0
- package/dist/cjs/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js +66 -39
- package/dist/cjs/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js.map +1 -1
- package/dist/cjs/cache/implementations/adapters/mongodb-cache-adapter/_module.js +2 -1
- package/dist/cjs/cache/implementations/adapters/mongodb-cache-adapter/_module.js.map +1 -1
- package/dist/cjs/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-settings.js +44 -0
- package/dist/cjs/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-settings.js.map +1 -0
- package/dist/cjs/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js +78 -28
- package/dist/cjs/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js.map +1 -1
- package/dist/cjs/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.js +10 -1
- package/dist/cjs/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.js.map +1 -1
- package/dist/cjs/cache/implementations/adapters/redis-cache-adapter/_module.js +1 -0
- package/dist/cjs/cache/implementations/adapters/redis-cache-adapter/_module.js.map +1 -1
- package/dist/cjs/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-settings.js +32 -0
- package/dist/cjs/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-settings.js.map +1 -0
- package/dist/cjs/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js +55 -23
- package/dist/cjs/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js.map +1 -1
- package/dist/cjs/cache/implementations/adapters/sqlite-cache-adapter/_module.js +1 -0
- package/dist/cjs/cache/implementations/adapters/sqlite-cache-adapter/_module.js.map +1 -1
- package/dist/cjs/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter-settings.js +56 -0
- package/dist/cjs/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter-settings.js.map +1 -0
- package/dist/cjs/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js +31 -17
- package/dist/cjs/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js.map +1 -1
- package/dist/cjs/cache/implementations/derivables/_module.js +3 -2
- package/dist/cjs/cache/implementations/derivables/_module.js.map +1 -1
- package/dist/cjs/cache/implementations/derivables/cache-factory-settings.js +65 -0
- package/dist/cjs/cache/implementations/derivables/cache-factory-settings.js.map +1 -0
- package/dist/cjs/cache/implementations/derivables/cache-factory.js +29 -18
- package/dist/cjs/cache/implementations/derivables/cache-factory.js.map +1 -1
- package/dist/cjs/cache/implementations/derivables/cache-settings.js +56 -0
- package/dist/cjs/cache/implementations/derivables/cache-settings.js.map +1 -0
- package/dist/cjs/cache/implementations/derivables/cache.js +334 -79
- package/dist/cjs/cache/implementations/derivables/cache.js.map +1 -1
- package/dist/cjs/collection/implementations/async-iterable-collection/_shared/async-merge-iterable.js +14 -7
- package/dist/cjs/collection/implementations/async-iterable-collection/_shared/async-merge-iterable.js.map +1 -1
- package/dist/cjs/collection/implementations/async-iterable-collection/_shared/async-retry-iterable.js +1 -1
- package/dist/cjs/collection/implementations/async-iterable-collection/_shared/async-retry-iterable.js.map +1 -1
- package/dist/cjs/collection/implementations/async-iterable-collection/_shared/async-take-until-abort-iterable.js +1 -1
- package/dist/cjs/collection/implementations/async-iterable-collection/_shared/async-take-until-abort-iterable.js.map +1 -1
- package/dist/cjs/collection/implementations/async-iterable-collection/_shared/async-take-until-timeout-iterable.js +1 -1
- package/dist/cjs/collection/implementations/async-iterable-collection/_shared/async-take-until-timeout-iterable.js.map +1 -1
- package/dist/cjs/collection/implementations/async-iterable-collection/async-iterable-collection.js +62 -41
- package/dist/cjs/collection/implementations/async-iterable-collection/async-iterable-collection.js.map +1 -1
- package/dist/cjs/collection/implementations/iterable-collection/_shared/merge-iterable.js +6 -7
- package/dist/cjs/collection/implementations/iterable-collection/_shared/merge-iterable.js.map +1 -1
- package/dist/cjs/collection/implementations/iterable-collection/iterable-collection.js +11 -2
- package/dist/cjs/collection/implementations/iterable-collection/iterable-collection.js.map +1 -1
- package/dist/cjs/collection/implementations/list-collection/list-collection.js +13 -0
- package/dist/cjs/collection/implementations/list-collection/list-collection.js.map +1 -1
- package/dist/cjs/event-bus/contracts/_module.js +2 -2
- package/dist/cjs/event-bus/contracts/_module.js.map +1 -1
- package/dist/cjs/event-bus/contracts/_shared.js +7 -0
- package/dist/cjs/event-bus/contracts/_shared.js.map +1 -1
- package/dist/cjs/event-bus/implementations/_shared/event-bus-adapter.test-suite.js +98 -38
- package/dist/cjs/event-bus/implementations/_shared/event-bus-adapter.test-suite.js.map +1 -1
- package/dist/cjs/event-bus/implementations/_shared/event-bus.test-suite.js +197 -125
- package/dist/cjs/event-bus/implementations/_shared/event-bus.test-suite.js.map +1 -1
- package/dist/cjs/event-bus/implementations/adapters/_module.js +1 -1
- package/dist/cjs/event-bus/implementations/adapters/_module.js.map +1 -1
- package/dist/cjs/event-bus/implementations/adapters/memory-event-bus-adapter/_module.js +2 -1
- package/dist/cjs/event-bus/implementations/adapters/memory-event-bus-adapter/_module.js.map +1 -1
- package/dist/cjs/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter-settings.js +26 -0
- package/dist/cjs/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter-settings.js.map +1 -0
- package/dist/cjs/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js +29 -11
- package/dist/cjs/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js.map +1 -1
- package/dist/cjs/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.js +9 -3
- package/dist/cjs/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.js.map +1 -1
- package/dist/cjs/{serializer/implementations/_shared/test-utilities → event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter}/_module.js +2 -1
- package/dist/cjs/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/_module.js.map +1 -0
- package/dist/cjs/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter-settings.js +38 -0
- package/dist/cjs/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter-settings.js.map +1 -0
- package/dist/cjs/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.js +56 -0
- package/dist/cjs/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.js.map +1 -0
- package/dist/cjs/event-bus/implementations/derivables/_module.js +3 -1
- package/dist/cjs/event-bus/implementations/derivables/_module.js.map +1 -1
- package/dist/cjs/event-bus/implementations/derivables/event-bus-factory-settings.js +59 -0
- package/dist/cjs/event-bus/implementations/derivables/event-bus-factory-settings.js.map +1 -0
- package/dist/cjs/event-bus/implementations/derivables/event-bus-factory.js +28 -17
- package/dist/cjs/event-bus/implementations/derivables/event-bus-factory.js.map +1 -1
- package/dist/cjs/event-bus/implementations/derivables/event-bus-settings.js +56 -0
- package/dist/cjs/event-bus/implementations/derivables/event-bus-settings.js.map +1 -0
- package/dist/cjs/event-bus/implementations/derivables/event-bus.js +106 -37
- package/dist/cjs/event-bus/implementations/derivables/event-bus.js.map +1 -1
- package/dist/cjs/serde/contracts/_module.js +23 -0
- package/dist/cjs/serde/contracts/_module.js.map +1 -0
- package/dist/cjs/serde/contracts/deserializer.contract.js +3 -0
- package/dist/cjs/serde/contracts/deserializer.contract.js.map +1 -0
- package/dist/cjs/serde/contracts/flexible-serde.contract.js +3 -0
- package/dist/cjs/serde/contracts/flexible-serde.contract.js.map +1 -0
- package/dist/cjs/serde/contracts/serde.contract.js +3 -0
- package/dist/cjs/serde/contracts/serde.contract.js.map +1 -0
- package/dist/cjs/{serializer/contracts/serializer.errors.js → serde/contracts/serde.errors.js} +7 -7
- package/dist/cjs/serde/contracts/serde.errors.js.map +1 -0
- package/dist/cjs/serde/contracts/serializable.contract.js +3 -0
- package/dist/cjs/serde/contracts/serializable.contract.js.map +1 -0
- package/dist/cjs/serde/contracts/serializer.contract.js.map +1 -0
- package/dist/cjs/{serializer → serde}/implementations/_module.js +6 -5
- package/dist/cjs/serde/implementations/_module.js.map +1 -0
- package/dist/cjs/{serializer/contracts → serde/implementations/_shared/test-utilities}/_module.js +2 -2
- package/dist/cjs/serde/implementations/_shared/test-utilities/_module.js.map +1 -0
- package/dist/cjs/serde/implementations/_shared/test-utilities/flexible-serde.test-suite.js +53 -0
- package/dist/cjs/serde/implementations/_shared/test-utilities/flexible-serde.test-suite.js.map +1 -0
- package/dist/cjs/{serializer/implementations/_shared/test-utilities/serializer.test-suite.js → serde/implementations/_shared/test-utilities/serde.test-suite.js} +68 -93
- package/dist/cjs/serde/implementations/_shared/test-utilities/serde.test-suite.js.map +1 -0
- package/dist/cjs/{serializer/implementations/sql-serializer → serde/implementations/mongodb-serde}/_module.js +1 -1
- package/dist/cjs/serde/implementations/mongodb-serde/_module.js.map +1 -0
- package/dist/cjs/serde/implementations/mongodb-serde/mongodb-serde.js +36 -0
- package/dist/cjs/serde/implementations/mongodb-serde/mongodb-serde.js.map +1 -0
- package/dist/cjs/{serializer/implementations/redis-serializer → serde/implementations/no-op-serde}/_module.js +1 -1
- package/dist/cjs/serde/implementations/no-op-serde/_module.js.map +1 -0
- package/dist/cjs/serde/implementations/no-op-serde/no-op-serde.js +16 -0
- package/dist/cjs/serde/implementations/no-op-serde/no-op-serde.js.map +1 -0
- package/dist/cjs/{serializer/implementations/mongodb-serializer → serde/implementations/redis-serde}/_module.js +1 -1
- package/dist/cjs/serde/implementations/redis-serde/_module.js.map +1 -0
- package/dist/cjs/serde/implementations/redis-serde/redis-serde.js +37 -0
- package/dist/cjs/serde/implementations/redis-serde/redis-serde.js.map +1 -0
- package/dist/cjs/{event-bus/implementations/adapters/redis-event-bus-adapter → serde/implementations/sql-serde}/_module.js +1 -1
- package/dist/cjs/serde/implementations/sql-serde/_module.js.map +1 -0
- package/dist/cjs/serde/implementations/sql-serde/sql-serde.js +37 -0
- package/dist/cjs/serde/implementations/sql-serde/sql-serde.js.map +1 -0
- package/dist/cjs/serde/implementations/super-json-serde/_module.js +18 -0
- package/dist/cjs/serde/implementations/super-json-serde/_module.js.map +1 -0
- package/dist/cjs/{serializer/implementations/super-json-serializer/super-json-serializer.js → serde/implementations/super-json-serde/super-json-serde.js} +77 -100
- package/dist/cjs/serde/implementations/super-json-serde/super-json-serde.js.map +1 -0
- package/dist/cjs/utilities/contracts/_module.js +1 -0
- package/dist/cjs/utilities/contracts/_module.js.map +1 -1
- package/dist/cjs/utilities/contracts/buildable.contract.js +3 -0
- package/dist/cjs/utilities/contracts/buildable.contract.js.map +1 -0
- package/dist/cjs/utilities/errors.js +10 -10
- package/dist/cjs/utilities/errors.js.map +1 -1
- package/dist/cjs/utilities/functions.js +9 -5
- package/dist/cjs/utilities/functions.js.map +1 -1
- package/dist/cjs/utilities/time-span/time-span.js +8 -0
- package/dist/cjs/utilities/time-span/time-span.js.map +1 -1
- package/dist/esm/_module.js +2 -2
- package/dist/esm/_module.js.map +1 -1
- package/dist/esm/async/_module.js +1 -1
- package/dist/esm/async/_module.js.map +1 -1
- package/dist/esm/async/backof-policies/_module.js +1 -0
- package/dist/esm/async/backof-policies/_module.js.map +1 -1
- package/dist/esm/async/utilities/_module.js +3 -0
- package/dist/esm/async/utilities/_module.js.map +1 -1
- package/dist/esm/async/utilities/lazy-promise/lazy-promise.js +21 -12
- package/dist/esm/async/utilities/lazy-promise/lazy-promise.js.map +1 -1
- package/dist/esm/cache/contracts/cache.events.js +158 -0
- package/dist/esm/cache/contracts/cache.events.js.map +1 -1
- package/dist/esm/cache/implementations/_shared/_module.js +1 -0
- package/dist/esm/cache/implementations/_shared/_module.js.map +1 -1
- package/dist/esm/cache/implementations/_shared/cache-adapter.test-suite.js +256 -177
- package/dist/esm/cache/implementations/_shared/cache-adapter.test-suite.js.map +1 -1
- package/dist/esm/cache/implementations/_shared/cache.test-suite.js +23 -2
- package/dist/esm/cache/implementations/_shared/cache.test-suite.js.map +1 -1
- package/dist/esm/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.js +64 -21
- package/dist/esm/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.js.map +1 -1
- package/dist/esm/cache/implementations/adapters/libsql-cache-adapter/_module.js +2 -1
- package/dist/esm/cache/implementations/adapters/libsql-cache-adapter/_module.js.map +1 -1
- package/dist/esm/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter-settings.js +52 -0
- package/dist/esm/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter-settings.js.map +1 -0
- package/dist/esm/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js +29 -15
- package/dist/esm/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js.map +1 -1
- package/dist/esm/cache/implementations/adapters/memory-cache-adapter/_module.js +1 -0
- package/dist/esm/cache/implementations/adapters/memory-cache-adapter/_module.js.map +1 -1
- package/dist/esm/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter-settings.js +22 -0
- package/dist/esm/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter-settings.js.map +1 -0
- package/dist/esm/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js +66 -39
- package/dist/esm/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js.map +1 -1
- package/dist/esm/cache/implementations/adapters/mongodb-cache-adapter/_module.js +2 -1
- package/dist/esm/cache/implementations/adapters/mongodb-cache-adapter/_module.js.map +1 -1
- package/dist/esm/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-settings.js +40 -0
- package/dist/esm/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-settings.js.map +1 -0
- package/dist/esm/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js +78 -25
- package/dist/esm/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js.map +1 -1
- package/dist/esm/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.js +10 -1
- package/dist/esm/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.js.map +1 -1
- package/dist/esm/cache/implementations/adapters/redis-cache-adapter/_module.js +1 -0
- package/dist/esm/cache/implementations/adapters/redis-cache-adapter/_module.js.map +1 -1
- package/dist/esm/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-settings.js +28 -0
- package/dist/esm/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-settings.js.map +1 -0
- package/dist/esm/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js +55 -23
- package/dist/esm/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js.map +1 -1
- package/dist/esm/cache/implementations/adapters/sqlite-cache-adapter/_module.js +1 -0
- package/dist/esm/cache/implementations/adapters/sqlite-cache-adapter/_module.js.map +1 -1
- package/dist/esm/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter-settings.js +52 -0
- package/dist/esm/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter-settings.js.map +1 -0
- package/dist/esm/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js +29 -15
- package/dist/esm/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js.map +1 -1
- package/dist/esm/cache/implementations/derivables/_module.js +3 -2
- package/dist/esm/cache/implementations/derivables/_module.js.map +1 -1
- package/dist/esm/cache/implementations/derivables/cache-factory-settings.js +61 -0
- package/dist/esm/cache/implementations/derivables/cache-factory-settings.js.map +1 -0
- package/dist/esm/cache/implementations/derivables/cache-factory.js +30 -19
- package/dist/esm/cache/implementations/derivables/cache-factory.js.map +1 -1
- package/dist/esm/cache/implementations/derivables/cache-settings.js +52 -0
- package/dist/esm/cache/implementations/derivables/cache-settings.js.map +1 -0
- package/dist/esm/cache/implementations/derivables/cache.js +333 -78
- package/dist/esm/cache/implementations/derivables/cache.js.map +1 -1
- package/dist/esm/collection/implementations/async-iterable-collection/_shared/async-merge-iterable.js +14 -7
- package/dist/esm/collection/implementations/async-iterable-collection/_shared/async-merge-iterable.js.map +1 -1
- package/dist/esm/collection/implementations/async-iterable-collection/_shared/async-retry-iterable.js +1 -1
- package/dist/esm/collection/implementations/async-iterable-collection/_shared/async-retry-iterable.js.map +1 -1
- package/dist/esm/collection/implementations/async-iterable-collection/_shared/async-take-until-abort-iterable.js +1 -1
- package/dist/esm/collection/implementations/async-iterable-collection/_shared/async-take-until-abort-iterable.js.map +1 -1
- package/dist/esm/collection/implementations/async-iterable-collection/_shared/async-take-until-timeout-iterable.js +1 -1
- package/dist/esm/collection/implementations/async-iterable-collection/_shared/async-take-until-timeout-iterable.js.map +1 -1
- package/dist/esm/collection/implementations/async-iterable-collection/async-iterable-collection.js +62 -41
- package/dist/esm/collection/implementations/async-iterable-collection/async-iterable-collection.js.map +1 -1
- package/dist/esm/collection/implementations/iterable-collection/_shared/merge-iterable.js +6 -7
- package/dist/esm/collection/implementations/iterable-collection/_shared/merge-iterable.js.map +1 -1
- package/dist/esm/collection/implementations/iterable-collection/iterable-collection.js +11 -2
- package/dist/esm/collection/implementations/iterable-collection/iterable-collection.js.map +1 -1
- package/dist/esm/collection/implementations/list-collection/list-collection.js +13 -0
- package/dist/esm/collection/implementations/list-collection/list-collection.js.map +1 -1
- package/dist/esm/event-bus/contracts/_module.js +2 -2
- package/dist/esm/event-bus/contracts/_module.js.map +1 -1
- package/dist/esm/event-bus/contracts/_shared.js +5 -0
- package/dist/esm/event-bus/contracts/_shared.js.map +1 -1
- package/dist/esm/event-bus/implementations/_shared/event-bus-adapter.test-suite.js +96 -36
- package/dist/esm/event-bus/implementations/_shared/event-bus-adapter.test-suite.js.map +1 -1
- package/dist/esm/event-bus/implementations/_shared/event-bus.test-suite.js +195 -123
- package/dist/esm/event-bus/implementations/_shared/event-bus.test-suite.js.map +1 -1
- package/dist/esm/event-bus/implementations/adapters/_module.js +1 -1
- package/dist/esm/event-bus/implementations/adapters/_module.js.map +1 -1
- package/dist/esm/event-bus/implementations/adapters/memory-event-bus-adapter/_module.js +2 -1
- package/dist/esm/event-bus/implementations/adapters/memory-event-bus-adapter/_module.js.map +1 -1
- package/dist/esm/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter-settings.js +22 -0
- package/dist/esm/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter-settings.js.map +1 -0
- package/dist/esm/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js +29 -11
- package/dist/esm/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js.map +1 -1
- package/dist/esm/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.js +9 -3
- package/dist/esm/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.js.map +1 -1
- package/dist/esm/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/_module.js +3 -0
- package/dist/esm/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/_module.js.map +1 -0
- package/dist/esm/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter-settings.js +34 -0
- package/dist/esm/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter-settings.js.map +1 -0
- package/dist/esm/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.js +52 -0
- package/dist/esm/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.js.map +1 -0
- package/dist/esm/event-bus/implementations/derivables/_module.js +3 -1
- package/dist/esm/event-bus/implementations/derivables/_module.js.map +1 -1
- package/dist/esm/event-bus/implementations/derivables/event-bus-factory-settings.js +55 -0
- package/dist/esm/event-bus/implementations/derivables/event-bus-factory-settings.js.map +1 -0
- package/dist/esm/event-bus/implementations/derivables/event-bus-factory.js +29 -18
- package/dist/esm/event-bus/implementations/derivables/event-bus-factory.js.map +1 -1
- package/dist/esm/event-bus/implementations/derivables/event-bus-settings.js +52 -0
- package/dist/esm/event-bus/implementations/derivables/event-bus-settings.js.map +1 -0
- package/dist/esm/event-bus/implementations/derivables/event-bus.js +108 -39
- package/dist/esm/event-bus/implementations/derivables/event-bus.js.map +1 -1
- package/dist/esm/serde/contracts/_module.js +7 -0
- package/dist/esm/serde/contracts/_module.js.map +1 -0
- package/dist/esm/serde/contracts/deserializer.contract.js +1 -0
- package/dist/esm/serde/contracts/deserializer.contract.js.map +1 -0
- package/dist/esm/serde/contracts/flexible-serde.contract.js +1 -0
- package/dist/esm/serde/contracts/flexible-serde.contract.js.map +1 -0
- package/dist/esm/serde/contracts/serde.contract.js +1 -0
- package/dist/esm/serde/contracts/serde.contract.js.map +1 -0
- package/dist/esm/{serializer/contracts/serializer.errors.js → serde/contracts/serde.errors.js} +5 -5
- package/dist/esm/serde/contracts/serde.errors.js.map +1 -0
- package/dist/esm/serde/contracts/serializable.contract.js +1 -0
- package/dist/esm/serde/contracts/serializable.contract.js.map +1 -0
- package/dist/esm/serde/contracts/serializer.contract.js.map +1 -0
- package/dist/esm/serde/implementations/_module.js +7 -0
- package/dist/esm/serde/implementations/_module.js.map +1 -0
- package/dist/esm/serde/implementations/_shared/test-utilities/_module.js +3 -0
- package/dist/esm/serde/implementations/_shared/test-utilities/_module.js.map +1 -0
- package/dist/esm/serde/implementations/_shared/test-utilities/flexible-serde.test-suite.js +50 -0
- package/dist/esm/serde/implementations/_shared/test-utilities/flexible-serde.test-suite.js.map +1 -0
- package/dist/esm/{serializer/implementations/_shared/test-utilities/serializer.test-suite.js → serde/implementations/_shared/test-utilities/serde.test-suite.js} +67 -92
- package/dist/esm/serde/implementations/_shared/test-utilities/serde.test-suite.js.map +1 -0
- package/dist/esm/serde/implementations/mongodb-serde/_module.js +2 -0
- package/dist/esm/serde/implementations/mongodb-serde/_module.js.map +1 -0
- package/dist/esm/{serializer/implementations/mongodb-serializer/mongodb-serializer.js → serde/implementations/mongodb-serde/mongodb-serde.js} +10 -10
- package/dist/esm/serde/implementations/mongodb-serde/mongodb-serde.js.map +1 -0
- package/dist/esm/serde/implementations/no-op-serde/_module.js +2 -0
- package/dist/esm/serde/implementations/no-op-serde/_module.js.map +1 -0
- package/dist/esm/serde/implementations/no-op-serde/no-op-serde.js +12 -0
- package/dist/esm/serde/implementations/no-op-serde/no-op-serde.js.map +1 -0
- package/dist/esm/serde/implementations/redis-serde/_module.js +2 -0
- package/dist/esm/serde/implementations/redis-serde/_module.js.map +1 -0
- package/dist/esm/{serializer/implementations/sql-serializer/sql-serializer.js → serde/implementations/redis-serde/redis-serde.js} +10 -10
- package/dist/esm/serde/implementations/redis-serde/redis-serde.js.map +1 -0
- package/dist/esm/serde/implementations/sql-serde/_module.js +2 -0
- package/dist/esm/serde/implementations/sql-serde/_module.js.map +1 -0
- package/dist/esm/{serializer/implementations/redis-serializer/redis-serializer.js → serde/implementations/sql-serde/sql-serde.js} +10 -10
- package/dist/esm/serde/implementations/sql-serde/sql-serde.js.map +1 -0
- package/dist/esm/serde/implementations/super-json-serde/_module.js +2 -0
- package/dist/esm/serde/implementations/super-json-serde/_module.js.map +1 -0
- package/dist/esm/{serializer/implementations/super-json-serializer/super-json-serializer.js → serde/implementations/super-json-serde/super-json-serde.js} +55 -55
- package/dist/esm/serde/implementations/super-json-serde/super-json-serde.js.map +1 -0
- package/dist/esm/utilities/contracts/_module.js +1 -0
- package/dist/esm/utilities/contracts/_module.js.map +1 -1
- package/dist/esm/utilities/contracts/buildable.contract.js +1 -0
- package/dist/esm/utilities/contracts/buildable.contract.js.map +1 -0
- package/dist/esm/utilities/errors.js +7 -7
- package/dist/esm/utilities/errors.js.map +1 -1
- package/dist/esm/utilities/functions.js +7 -4
- package/dist/esm/utilities/functions.js.map +1 -1
- package/dist/esm/utilities/time-span/time-span.js +8 -0
- package/dist/esm/utilities/time-span/time-span.js.map +1 -1
- package/dist/types/_module.d.ts +2 -2
- package/dist/types/async/_module.d.ts +1 -1
- package/dist/types/async/backof-policies/_module.d.ts +1 -1
- package/dist/types/async/utilities/_module.d.ts +3 -0
- package/dist/types/async/utilities/lazy-promise/lazy-promise.d.ts +66 -39
- package/dist/types/cache/contracts/cache-adapter.contract.d.ts +20 -6
- package/dist/types/cache/contracts/cache-factory.contract.d.ts +12 -25
- package/dist/types/cache/contracts/cache.contract.d.ts +382 -22
- package/dist/types/cache/contracts/cache.events.d.ts +156 -42
- package/dist/types/cache/implementations/_shared/_module.d.ts +1 -0
- package/dist/types/cache/implementations/_shared/cache-adapter.test-suite.d.ts +21 -12
- package/dist/types/cache/implementations/_shared/cache.test-suite.d.ts +21 -15
- package/dist/types/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.d.ts +15 -8
- package/dist/types/cache/implementations/adapters/libsql-cache-adapter/_module.d.ts +2 -1
- package/dist/types/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter-settings.d.ts +48 -0
- package/dist/types/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.d.ts +54 -36
- package/dist/types/cache/implementations/adapters/memory-cache-adapter/_module.d.ts +1 -0
- package/dist/types/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter-settings.d.ts +27 -0
- package/dist/types/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.d.ts +50 -20
- package/dist/types/cache/implementations/adapters/mongodb-cache-adapter/_module.d.ts +2 -1
- package/dist/types/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-settings.d.ts +51 -0
- package/dist/types/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.d.ts +66 -41
- package/dist/types/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.d.ts +6 -3
- package/dist/types/cache/implementations/adapters/redis-cache-adapter/_module.d.ts +1 -0
- package/dist/types/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-settings.d.ts +32 -0
- package/dist/types/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.d.ts +51 -29
- package/dist/types/cache/implementations/adapters/sqlite-cache-adapter/_module.d.ts +1 -0
- package/dist/types/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter-settings.d.ts +48 -0
- package/dist/types/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.d.ts +54 -34
- package/dist/types/cache/implementations/derivables/_module.d.ts +3 -2
- package/dist/types/cache/implementations/derivables/cache-factory-settings.d.ts +77 -0
- package/dist/types/cache/implementations/derivables/cache-factory.d.ts +59 -45
- package/dist/types/cache/implementations/derivables/cache-settings.d.ts +68 -0
- package/dist/types/cache/implementations/derivables/cache.d.ts +83 -62
- package/dist/types/collection/contracts/async-collection.contract.d.ts +1247 -666
- package/dist/types/collection/contracts/collection.contract.d.ts +1195 -638
- package/dist/types/collection/implementations/async-iterable-collection/_shared/async-merge-iterable.d.ts +4 -5
- package/dist/types/collection/implementations/async-iterable-collection/_shared/async-retry-iterable.d.ts +1 -1
- package/dist/types/collection/implementations/async-iterable-collection/async-iterable-collection.d.ts +194 -3
- package/dist/types/collection/implementations/iterable-collection/_shared/merge-iterable.d.ts +4 -5
- package/dist/types/collection/implementations/iterable-collection/iterable-collection.d.ts +141 -1
- package/dist/types/collection/implementations/list-collection/list-collection.d.ts +141 -1
- package/dist/types/event-bus/contracts/_module.d.ts +2 -2
- package/dist/types/event-bus/contracts/_shared.d.ts +11 -0
- package/dist/types/event-bus/contracts/event-bus-adapter.contract.d.ts +9 -8
- package/dist/types/event-bus/contracts/event-bus-factory.contract.d.ts +38 -32
- package/dist/types/event-bus/contracts/event-bus.contract.d.ts +52 -37
- package/dist/types/event-bus/implementations/_shared/event-bus-adapter.test-suite.d.ts +22 -10
- package/dist/types/event-bus/implementations/_shared/event-bus.test-suite.d.ts +16 -13
- package/dist/types/event-bus/implementations/adapters/_module.d.ts +1 -1
- package/dist/types/event-bus/implementations/adapters/memory-event-bus-adapter/_module.d.ts +2 -1
- package/dist/types/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter-settings.d.ts +28 -0
- package/dist/types/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.d.ts +53 -22
- package/dist/types/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.d.ts +7 -4
- package/dist/types/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/_module.d.ts +2 -0
- package/dist/types/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter-settings.d.ts +36 -0
- package/dist/types/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.d.ts +62 -0
- package/dist/types/event-bus/implementations/derivables/_module.d.ts +3 -1
- package/dist/types/event-bus/implementations/derivables/event-bus-factory-settings.d.ts +70 -0
- package/dist/types/event-bus/implementations/derivables/event-bus-factory.d.ts +40 -24
- package/dist/types/event-bus/implementations/derivables/event-bus-settings.d.ts +58 -0
- package/dist/types/event-bus/implementations/derivables/event-bus.d.ts +31 -45
- package/dist/types/serde/contracts/_module.d.ts +6 -0
- package/dist/types/serde/contracts/deserializer.contract.d.ts +13 -0
- package/dist/types/serde/contracts/flexible-serde.contract.d.ts +56 -0
- package/dist/types/serde/contracts/serde.contract.d.ts +10 -0
- package/dist/types/{serializer/contracts/serializer.errors.d.ts → serde/contracts/serde.errors.d.ts} +4 -4
- package/dist/types/serde/contracts/serializable.contract.d.ts +10 -0
- package/dist/types/serde/contracts/serializer.contract.d.ts +10 -0
- package/dist/types/serde/implementations/_module.d.ts +6 -0
- package/dist/types/serde/implementations/_shared/test-utilities/_module.d.ts +2 -0
- package/dist/types/serde/implementations/_shared/test-utilities/flexible-serde.test-suite.d.ts +17 -0
- package/dist/types/serde/implementations/_shared/test-utilities/serde.test-suite.d.ts +17 -0
- package/dist/types/serde/implementations/mongodb-serde/_module.d.ts +1 -0
- package/dist/types/serde/implementations/mongodb-serde/mongodb-serde.d.ts +13 -0
- package/dist/types/serde/implementations/no-op-serde/_module.d.ts +1 -0
- package/dist/types/serde/implementations/no-op-serde/no-op-serde.d.ts +13 -0
- package/dist/types/serde/implementations/redis-serde/_module.d.ts +1 -0
- package/dist/types/serde/implementations/redis-serde/redis-serde.d.ts +13 -0
- package/dist/types/serde/implementations/sql-serde/_module.d.ts +1 -0
- package/dist/types/serde/implementations/sql-serde/sql-serde.d.ts +13 -0
- package/dist/types/serde/implementations/super-json-serde/_module.d.ts +1 -0
- package/dist/types/serde/implementations/super-json-serde/super-json-serde.d.ts +25 -0
- package/dist/types/utilities/contracts/_module.d.ts +1 -0
- package/dist/types/utilities/contracts/buildable.contract.d.ts +9 -0
- package/dist/types/utilities/errors.d.ts +3 -3
- package/dist/types/utilities/functions.d.ts +5 -1
- package/dist/types/utilities/time-span/time-span.d.ts +10 -1
- package/dist/types/utilities/types.d.ts +0 -1
- package/package.json +3 -9
- package/dist/cjs/cache/implementations/derivables/base-cache.js +0 -270
- package/dist/cjs/cache/implementations/derivables/base-cache.js.map +0 -1
- package/dist/cjs/event-bus/implementations/adapters/redis-event-bus-adapter/_module.js.map +0 -1
- package/dist/cjs/event-bus/implementations/adapters/redis-event-bus-adapter/redis-event-bus-adapter.js +0 -44
- package/dist/cjs/event-bus/implementations/adapters/redis-event-bus-adapter/redis-event-bus-adapter.js.map +0 -1
- package/dist/cjs/event-bus/implementations/derivables/base-event-bus.js +0 -47
- package/dist/cjs/event-bus/implementations/derivables/base-event-bus.js.map +0 -1
- package/dist/cjs/event-bus/implementations/derivables/with-namespace-event-bus-adapter.js +0 -42
- package/dist/cjs/event-bus/implementations/derivables/with-namespace-event-bus-adapter.js.map +0 -1
- package/dist/cjs/serializer/contracts/_module.js.map +0 -1
- package/dist/cjs/serializer/contracts/serializer.contract.js.map +0 -1
- package/dist/cjs/serializer/contracts/serializer.errors.js.map +0 -1
- package/dist/cjs/serializer/implementations/_module.js.map +0 -1
- package/dist/cjs/serializer/implementations/_shared/test-utilities/_module.js.map +0 -1
- package/dist/cjs/serializer/implementations/_shared/test-utilities/serializer.test-suite.js.map +0 -1
- package/dist/cjs/serializer/implementations/mongodb-serializer/_module.js.map +0 -1
- package/dist/cjs/serializer/implementations/mongodb-serializer/mongodb-serializer.js +0 -36
- package/dist/cjs/serializer/implementations/mongodb-serializer/mongodb-serializer.js.map +0 -1
- package/dist/cjs/serializer/implementations/redis-serializer/_module.js.map +0 -1
- package/dist/cjs/serializer/implementations/redis-serializer/redis-serializer.js +0 -37
- package/dist/cjs/serializer/implementations/redis-serializer/redis-serializer.js.map +0 -1
- package/dist/cjs/serializer/implementations/sql-serializer/_module.js.map +0 -1
- package/dist/cjs/serializer/implementations/sql-serializer/sql-serializer.js +0 -37
- package/dist/cjs/serializer/implementations/sql-serializer/sql-serializer.js.map +0 -1
- package/dist/cjs/serializer/implementations/super-json-serializer/_module.js +0 -18
- package/dist/cjs/serializer/implementations/super-json-serializer/_module.js.map +0 -1
- package/dist/cjs/serializer/implementations/super-json-serializer/super-json-serializer.js.map +0 -1
- package/dist/esm/cache/implementations/derivables/base-cache.js +0 -266
- package/dist/esm/cache/implementations/derivables/base-cache.js.map +0 -1
- package/dist/esm/event-bus/implementations/adapters/redis-event-bus-adapter/_module.js +0 -2
- package/dist/esm/event-bus/implementations/adapters/redis-event-bus-adapter/_module.js.map +0 -1
- package/dist/esm/event-bus/implementations/adapters/redis-event-bus-adapter/redis-event-bus-adapter.js +0 -40
- package/dist/esm/event-bus/implementations/adapters/redis-event-bus-adapter/redis-event-bus-adapter.js.map +0 -1
- package/dist/esm/event-bus/implementations/derivables/base-event-bus.js +0 -43
- package/dist/esm/event-bus/implementations/derivables/base-event-bus.js.map +0 -1
- package/dist/esm/event-bus/implementations/derivables/with-namespace-event-bus-adapter.js +0 -38
- package/dist/esm/event-bus/implementations/derivables/with-namespace-event-bus-adapter.js.map +0 -1
- package/dist/esm/serializer/contracts/_module.js +0 -3
- package/dist/esm/serializer/contracts/_module.js.map +0 -1
- package/dist/esm/serializer/contracts/serializer.contract.js.map +0 -1
- package/dist/esm/serializer/contracts/serializer.errors.js.map +0 -1
- package/dist/esm/serializer/implementations/_module.js +0 -6
- package/dist/esm/serializer/implementations/_module.js.map +0 -1
- package/dist/esm/serializer/implementations/_shared/test-utilities/_module.js +0 -2
- package/dist/esm/serializer/implementations/_shared/test-utilities/_module.js.map +0 -1
- package/dist/esm/serializer/implementations/_shared/test-utilities/serializer.test-suite.js.map +0 -1
- package/dist/esm/serializer/implementations/mongodb-serializer/_module.js +0 -2
- package/dist/esm/serializer/implementations/mongodb-serializer/_module.js.map +0 -1
- package/dist/esm/serializer/implementations/mongodb-serializer/mongodb-serializer.js.map +0 -1
- package/dist/esm/serializer/implementations/redis-serializer/_module.js +0 -2
- package/dist/esm/serializer/implementations/redis-serializer/_module.js.map +0 -1
- package/dist/esm/serializer/implementations/redis-serializer/redis-serializer.js.map +0 -1
- package/dist/esm/serializer/implementations/sql-serializer/_module.js +0 -2
- package/dist/esm/serializer/implementations/sql-serializer/_module.js.map +0 -1
- package/dist/esm/serializer/implementations/sql-serializer/sql-serializer.js.map +0 -1
- package/dist/esm/serializer/implementations/super-json-serializer/_module.js +0 -2
- package/dist/esm/serializer/implementations/super-json-serializer/_module.js.map +0 -1
- package/dist/esm/serializer/implementations/super-json-serializer/super-json-serializer.js.map +0 -1
- package/dist/types/cache/implementations/derivables/base-cache.d.ts +0 -58
- package/dist/types/event-bus/implementations/adapters/redis-event-bus-adapter/_module.d.ts +0 -1
- package/dist/types/event-bus/implementations/adapters/redis-event-bus-adapter/redis-event-bus-adapter.d.ts +0 -43
- package/dist/types/event-bus/implementations/derivables/base-event-bus.d.ts +0 -23
- package/dist/types/event-bus/implementations/derivables/with-namespace-event-bus-adapter.d.ts +0 -16
- package/dist/types/serializer/contracts/_module.d.ts +0 -2
- package/dist/types/serializer/contracts/serializer.contract.d.ts +0 -16
- package/dist/types/serializer/implementations/_module.d.ts +0 -5
- package/dist/types/serializer/implementations/_shared/test-utilities/_module.d.ts +0 -1
- package/dist/types/serializer/implementations/_shared/test-utilities/serializer.test-suite.d.ts +0 -18
- package/dist/types/serializer/implementations/mongodb-serializer/_module.d.ts +0 -1
- package/dist/types/serializer/implementations/mongodb-serializer/mongodb-serializer.d.ts +0 -13
- package/dist/types/serializer/implementations/redis-serializer/_module.d.ts +0 -1
- package/dist/types/serializer/implementations/redis-serializer/redis-serializer.d.ts +0 -13
- package/dist/types/serializer/implementations/sql-serializer/_module.d.ts +0 -1
- package/dist/types/serializer/implementations/sql-serializer/sql-serializer.d.ts +0 -13
- package/dist/types/serializer/implementations/super-json-serializer/_module.d.ts +0 -1
- package/dist/types/serializer/implementations/super-json-serializer/super-json-serializer.d.ts +0 -37
- /package/dist/cjs/{serializer → serde}/contracts/serializer.contract.js +0 -0
- /package/dist/esm/{serializer → serde}/contracts/serializer.contract.js +0 -0
|
@@ -12,7 +12,7 @@ export type AsyncCollapse<TValue> = TValue extends Array<infer TItem> | Iterable
|
|
|
12
12
|
* @group Contracts
|
|
13
13
|
* @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
|
|
14
14
|
*/
|
|
15
|
-
export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
15
|
+
export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
16
16
|
/**
|
|
17
17
|
* The <i>toIterator</i> method converts the collection to a new iterator.
|
|
18
18
|
*/
|
|
@@ -33,12 +33,16 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
33
33
|
* The <i>filter</i> method filters the collection using <i>predicateFn</i>, keeping only those items that pass <i>predicateFn</i>.
|
|
34
34
|
* @example
|
|
35
35
|
* ```ts
|
|
36
|
-
* import {
|
|
36
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
37
37
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
38
|
+
* // Asume the inputed collection is empty.
|
|
39
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
40
|
+
* await collection
|
|
41
|
+
* .append([1, 2, 3, 4, 5, 6])
|
|
42
|
+
* .filter(item => 2 < item && item < 5)
|
|
43
|
+
* .toArray();
|
|
44
|
+
* // [3, 4]
|
|
45
|
+
* }
|
|
42
46
|
* ```
|
|
43
47
|
*/
|
|
44
48
|
filter<TOutput extends TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): IAsyncCollection<TOutput>;
|
|
@@ -46,12 +50,16 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
46
50
|
* The <i>reject</i> method filters the collection using <i>predicateFn</i>, keeping only those items that not pass <i>predicateFn</i>.
|
|
47
51
|
* @example
|
|
48
52
|
* ```ts
|
|
49
|
-
* import {
|
|
53
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
50
54
|
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
+
* // Asume the inputed collection is empty.
|
|
56
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
57
|
+
* await collection
|
|
58
|
+
* .append([1, 2, 3, 4, 5, 6])
|
|
59
|
+
* .reject(item => 2 < item && item < 5)
|
|
60
|
+
* .toArray();
|
|
61
|
+
* // [1, 2, 5, 6]
|
|
62
|
+
* }
|
|
55
63
|
* ```
|
|
56
64
|
*/
|
|
57
65
|
reject<TOutput extends TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): IAsyncCollection<Exclude<TInput, TOutput>>;
|
|
@@ -60,12 +68,16 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
60
68
|
* The <i>mapFn</i> is free to modify the item and return it, thus forming a new collection of modified items.
|
|
61
69
|
* @example
|
|
62
70
|
* ```ts
|
|
63
|
-
* import {
|
|
71
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
64
72
|
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
73
|
+
* // Asume the inputed collection is empty.
|
|
74
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
75
|
+
* await collection
|
|
76
|
+
* .append([1, 2, 3, 4, 5])
|
|
77
|
+
* .map(item => item * 2)
|
|
78
|
+
* .toArray();
|
|
79
|
+
* // [2, 4, 6, 8, 10]
|
|
80
|
+
* }
|
|
69
81
|
* ```
|
|
70
82
|
*/
|
|
71
83
|
map<TOutput>(mapFn: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput>): IAsyncCollection<TOutput>;
|
|
@@ -74,25 +86,34 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
74
86
|
* The final result of running the reducer across all items of the array is a single value.
|
|
75
87
|
* @example
|
|
76
88
|
* ```ts
|
|
77
|
-
* import {
|
|
89
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
78
90
|
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
91
|
+
* // Asume the inputed collection is empty.
|
|
92
|
+
* async function main(collection: IAsyncCollection<string>): Promise<void> {
|
|
93
|
+
* await collection
|
|
94
|
+
* .append([1, 2, 3])
|
|
95
|
+
* .reduce((sum, item) => sum + item);
|
|
96
|
+
* // 6
|
|
97
|
+
* }
|
|
82
98
|
* ```
|
|
83
99
|
* @example
|
|
84
100
|
* ```ts
|
|
85
|
-
* import {
|
|
101
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
86
102
|
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
103
|
+
* // Asume the inputed collection is empty.
|
|
104
|
+
* async function main(collection: IAsyncCollection<string>): Promise<void> {
|
|
105
|
+
* await collection
|
|
106
|
+
* .append(["a", "b", "c"])
|
|
107
|
+
* .entries()
|
|
108
|
+
* .reduce(
|
|
109
|
+
* (record, [key, value]) => ({
|
|
110
|
+
* ...record,
|
|
111
|
+
* [key]: value
|
|
112
|
+
* }),
|
|
113
|
+
* {} as Record<number, string>
|
|
114
|
+
* );
|
|
115
|
+
* // { 0: "a", 1: "b", 2: "c" }
|
|
116
|
+
* }
|
|
96
117
|
* ```
|
|
97
118
|
*/
|
|
98
119
|
reduce(reduceFn: AsyncReduce<TInput, IAsyncCollection<TInput>, TInput>): LazyPromise<TInput>;
|
|
@@ -103,19 +124,29 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
103
124
|
* @throws {TypeCollectionError}
|
|
104
125
|
* @example
|
|
105
126
|
* ```ts
|
|
106
|
-
* import {
|
|
127
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
107
128
|
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
129
|
+
* // Asume the inputed collection is empty.
|
|
130
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
131
|
+
* await collection
|
|
132
|
+
* .append([1, 2, 3, 4])
|
|
133
|
+
* .map(item => item.toString())
|
|
134
|
+
* .join();
|
|
135
|
+
* // "1,2,3,4"
|
|
136
|
+
* }
|
|
111
137
|
* ```
|
|
112
138
|
* @example
|
|
113
139
|
* ```ts
|
|
114
|
-
* import {
|
|
140
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
115
141
|
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
142
|
+
* // Asume the inputed collection is empty.
|
|
143
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
144
|
+
* await collection
|
|
145
|
+
* .append([1, 2, 3, 4])
|
|
146
|
+
* .map(item => item.toString())
|
|
147
|
+
* .join("_");
|
|
148
|
+
* // "1_2_3_4"
|
|
149
|
+
* }
|
|
119
150
|
* ```
|
|
120
151
|
*/
|
|
121
152
|
join(separator?: string): LazyPromise<Extract<TInput, string>>;
|
|
@@ -123,12 +154,16 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
123
154
|
* The <i>collapse</i> method collapses a collection of iterables into a single, flat collection.
|
|
124
155
|
* @example
|
|
125
156
|
* ```ts
|
|
126
|
-
* import {
|
|
157
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
127
158
|
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
159
|
+
* // Asume the inputed collection is empty.
|
|
160
|
+
* async function main(collection: IAsyncCollection<number[]>): Promise<void> {
|
|
161
|
+
* await collection
|
|
162
|
+
* .append([[1, 2], [3, 4]])
|
|
163
|
+
* .collapse()
|
|
164
|
+
* .toArray();
|
|
165
|
+
* // [1, 2, 3, 4]
|
|
166
|
+
* }
|
|
132
167
|
* ```
|
|
133
168
|
*/
|
|
134
169
|
collapse(): IAsyncCollection<AsyncCollapse<TInput>>;
|
|
@@ -137,11 +172,16 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
137
172
|
* It is identical to a <i>map</i> method followed by a <i>collapse</i> method.
|
|
138
173
|
* @example
|
|
139
174
|
* ```ts
|
|
140
|
-
* import {
|
|
175
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
141
176
|
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
177
|
+
* // Asume the inputed collection is empty.
|
|
178
|
+
* async function main(collection: IAsyncCollection<string[]>): Promise<void> {
|
|
179
|
+
* await collection
|
|
180
|
+
* .append([["a", "b"], ["c", "d"]])
|
|
181
|
+
* .flatMap(item => [item.length, ...item])
|
|
182
|
+
* .toArray();
|
|
183
|
+
* // [2, "a", "b", 2, "c", "d"]
|
|
184
|
+
* }
|
|
145
185
|
* ```
|
|
146
186
|
*/
|
|
147
187
|
flatMap<TOutput>(mapFn: AsyncMap<TInput, IAsyncCollection<TInput>, Iterable<TOutput>>): IAsyncCollection<TOutput>;
|
|
@@ -149,12 +189,16 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
149
189
|
* The <i>change</i> method changes only the items that passes <i>predicateFn</i> using <i>mapFn</i>.
|
|
150
190
|
* @example
|
|
151
191
|
* ```ts
|
|
152
|
-
* import {
|
|
192
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
153
193
|
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
194
|
+
* // Asume the inputed collection is empty.
|
|
195
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
196
|
+
* await collection
|
|
197
|
+
* .append([1, 2, 3, 4, 5])
|
|
198
|
+
* .change(item => item % 2 === 0, item => item * 2)
|
|
199
|
+
* .toArray();
|
|
200
|
+
* // [1, 4, 3, 8, 5]
|
|
201
|
+
* }
|
|
158
202
|
* ```
|
|
159
203
|
*/
|
|
160
204
|
change<TFilterOutput extends TInput, TMapOutput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>, TFilterOutput>, mapFn: AsyncMap<TFilterOutput, IAsyncCollection<TInput>, TMapOutput>): IAsyncCollection<TInput | TFilterOutput | TMapOutput>;
|
|
@@ -162,21 +206,29 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
162
206
|
* The <i>set</i> method changes a item by i>index</i> using <i>value</i>.
|
|
163
207
|
* @example
|
|
164
208
|
* ```ts
|
|
165
|
-
* import {
|
|
209
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
166
210
|
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
211
|
+
* // Asume the inputed collection is empty.
|
|
212
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
213
|
+
* await collection
|
|
214
|
+
* .append([1, 2, 3, 4, 5])
|
|
215
|
+
* .set(1, -1)
|
|
216
|
+
* .toArray();
|
|
217
|
+
* // [1, -1, 3, 4, 5]
|
|
218
|
+
* }
|
|
171
219
|
* ```
|
|
172
220
|
* @example
|
|
173
221
|
* ```ts
|
|
174
|
-
* import {
|
|
222
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
175
223
|
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
224
|
+
* // Asume the inputed collection is empty.
|
|
225
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
226
|
+
* await collection
|
|
227
|
+
* .append([1, 2, 3, 4, 5])
|
|
228
|
+
* .set(1, (prevValue) => prevValue - 2)
|
|
229
|
+
* .toArray();
|
|
230
|
+
* // [1, 0, 3, 4, 5]
|
|
231
|
+
* }
|
|
180
232
|
* ```
|
|
181
233
|
*/
|
|
182
234
|
set(index: number, value: TInput | AsyncMap<TInput, IAsyncCollection<TInput>, TInput>): IAsyncCollection<TInput>;
|
|
@@ -184,14 +236,18 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
184
236
|
* The <i>get</i> method returns the item by index. If the item is not found null will returned.
|
|
185
237
|
* @example
|
|
186
238
|
* ```ts
|
|
187
|
-
* import {
|
|
239
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
240
|
+
*
|
|
241
|
+
* // Asume the inputed collection is empty.
|
|
242
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
243
|
+
* collection = collection.append([1, 4, 2, 8, -2]);
|
|
188
244
|
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
* await collection.get(2);
|
|
245
|
+
* // Will be 2
|
|
246
|
+
* await collection.get(2);
|
|
192
247
|
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
248
|
+
* // Will be null
|
|
249
|
+
* await collection.get(5);
|
|
250
|
+
* }
|
|
195
251
|
* ```
|
|
196
252
|
*/
|
|
197
253
|
get(index: number): LazyPromise<TInput | null>;
|
|
@@ -200,14 +256,18 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
200
256
|
* @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
|
|
201
257
|
* @example
|
|
202
258
|
* ```ts
|
|
203
|
-
* import {
|
|
259
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
204
260
|
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
261
|
+
* // Asume the inputed collection is empty.
|
|
262
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
263
|
+
* collection = collection.append([1, 4, 2, 8, -2]);
|
|
208
264
|
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
265
|
+
* // Will be 2
|
|
266
|
+
* await collection.getOrFail(2);
|
|
267
|
+
*
|
|
268
|
+
* // An error will thrown
|
|
269
|
+
* await collection.getOrFail(5);
|
|
270
|
+
* }
|
|
211
271
|
* ```
|
|
212
272
|
*/
|
|
213
273
|
getOrFail(index: number): LazyPromise<TInput>;
|
|
@@ -215,12 +275,16 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
215
275
|
* The <i>page</i> method returns a new collection containing the items that would be present on <i> page </i> with custom <i> pageSize </i>.
|
|
216
276
|
* @example
|
|
217
277
|
* ```ts
|
|
218
|
-
* import {
|
|
278
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
219
279
|
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
280
|
+
* // Asume the inputed collection is empty.
|
|
281
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
282
|
+
* await collection
|
|
283
|
+
* .append([1, 2, 3, 4, 5, 6, 7, 8, 9])
|
|
284
|
+
* .page(2, 3)
|
|
285
|
+
* .toArray();
|
|
286
|
+
* // [4, 5, 6]
|
|
287
|
+
* }
|
|
224
288
|
* ```
|
|
225
289
|
*/
|
|
226
290
|
page(page: number, pageSize: number): IAsyncCollection<TInput>;
|
|
@@ -230,11 +294,15 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
230
294
|
* @throws {EmptyCollectionError} {@link EmptyCollectionError}
|
|
231
295
|
* @example
|
|
232
296
|
* ```ts
|
|
233
|
-
* import {
|
|
297
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
234
298
|
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
299
|
+
* // Asume the inputed collection is empty.
|
|
300
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
301
|
+
* await collection
|
|
302
|
+
* .append([1, 2, 3])
|
|
303
|
+
* .sum();
|
|
304
|
+
* // 6
|
|
305
|
+
* }
|
|
238
306
|
* ```
|
|
239
307
|
*/
|
|
240
308
|
sum(): LazyPromise<Extract<TInput, number>>;
|
|
@@ -244,11 +312,15 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
244
312
|
* @throws {EmptyCollectionError} {@link EmptyCollectionError}
|
|
245
313
|
* @example
|
|
246
314
|
* ```ts
|
|
247
|
-
* import {
|
|
315
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
248
316
|
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
317
|
+
* // Asume the inputed collection is empty.
|
|
318
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
319
|
+
* await collection
|
|
320
|
+
* .append([1, 2, 3])
|
|
321
|
+
* .average();
|
|
322
|
+
* // 2
|
|
323
|
+
* }
|
|
252
324
|
* ```
|
|
253
325
|
*/
|
|
254
326
|
average(): LazyPromise<Extract<TInput, number>>;
|
|
@@ -258,11 +330,15 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
258
330
|
* @throws {EmptyCollectionError} {@link EmptyCollectionError}
|
|
259
331
|
* @example
|
|
260
332
|
* ```ts
|
|
261
|
-
* import {
|
|
333
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
262
334
|
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
335
|
+
* // Asume the inputed collection is empty.
|
|
336
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
337
|
+
* await collection
|
|
338
|
+
* .append([1, 2, 3])
|
|
339
|
+
* .median();
|
|
340
|
+
* // 2
|
|
341
|
+
* }
|
|
266
342
|
* ```
|
|
267
343
|
*/
|
|
268
344
|
median(): LazyPromise<Extract<TInput, number>>;
|
|
@@ -272,11 +348,15 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
272
348
|
* @throws {EmptyCollectionError} {@link EmptyCollectionError}
|
|
273
349
|
* @example
|
|
274
350
|
* ```ts
|
|
275
|
-
* import {
|
|
351
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
276
352
|
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
353
|
+
* // Asume the inputed collection is empty.
|
|
354
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
355
|
+
* await collection
|
|
356
|
+
* .append([1, 2, 3])
|
|
357
|
+
* .min();
|
|
358
|
+
* // 1
|
|
359
|
+
* }
|
|
280
360
|
* ```
|
|
281
361
|
*/
|
|
282
362
|
min(): LazyPromise<Extract<TInput, number>>;
|
|
@@ -286,11 +366,15 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
286
366
|
* @throws {EmptyCollectionError} {@link EmptyCollectionError}
|
|
287
367
|
* @example
|
|
288
368
|
* ```ts
|
|
289
|
-
* import {
|
|
369
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
290
370
|
*
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
*
|
|
371
|
+
* // Asume the inputed collection is empty.
|
|
372
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
373
|
+
* await collection
|
|
374
|
+
* .append([1, 2, 3])
|
|
375
|
+
* .max();
|
|
376
|
+
* // 3
|
|
377
|
+
* }
|
|
294
378
|
* ```
|
|
295
379
|
*/
|
|
296
380
|
max(): LazyPromise<Extract<TInput, number>>;
|
|
@@ -299,11 +383,15 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
299
383
|
* @throws {EmptyCollectionError} {@link EmptyCollectionError}
|
|
300
384
|
* @example
|
|
301
385
|
* ```ts
|
|
302
|
-
* import {
|
|
386
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
303
387
|
*
|
|
304
|
-
*
|
|
305
|
-
*
|
|
306
|
-
*
|
|
388
|
+
* // Asume the inputed collection is empty.
|
|
389
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
390
|
+
* await collection
|
|
391
|
+
* .append([1, 1, 2, 2, 2, 3])
|
|
392
|
+
* .percentage(value => value === 1);
|
|
393
|
+
* // 33.333
|
|
394
|
+
* }
|
|
307
395
|
* ```
|
|
308
396
|
*/
|
|
309
397
|
percentage(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): LazyPromise<number>;
|
|
@@ -311,11 +399,15 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
311
399
|
* The <i>some</i> method determines whether at least one item in the collection matches <i>predicateFn</i>.
|
|
312
400
|
* @example
|
|
313
401
|
* ```ts
|
|
314
|
-
* import {
|
|
402
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
315
403
|
*
|
|
316
|
-
*
|
|
317
|
-
*
|
|
318
|
-
*
|
|
404
|
+
* // Asume the inputed collection is empty.
|
|
405
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
406
|
+
* await collection
|
|
407
|
+
* .append([0, 1, 2, 3, 4, 5])
|
|
408
|
+
* .some(item => item === 1);
|
|
409
|
+
* // true
|
|
410
|
+
* }
|
|
319
411
|
* ```
|
|
320
412
|
*/
|
|
321
413
|
some<TOutput extends TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): LazyPromise<boolean>;
|
|
@@ -323,11 +415,15 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
323
415
|
* The <i>every</i> method determines whether all items in the collection matches <i>predicateFn</i>.
|
|
324
416
|
* @example
|
|
325
417
|
* ```ts
|
|
326
|
-
* import {
|
|
418
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
327
419
|
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
330
|
-
*
|
|
420
|
+
* // Asume the inputed collection is empty.
|
|
421
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
422
|
+
* await collection
|
|
423
|
+
* .append([0, 1, 2, 3, 4, 5])
|
|
424
|
+
* .every(item => item < 6);
|
|
425
|
+
* // true
|
|
426
|
+
* }
|
|
331
427
|
* ```
|
|
332
428
|
*/
|
|
333
429
|
every<TOutput extends TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): LazyPromise<boolean>;
|
|
@@ -335,21 +431,29 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
335
431
|
* The <i>take</i> method takes the first <i>limit</i> items.
|
|
336
432
|
* @example
|
|
337
433
|
* ```ts
|
|
338
|
-
* import {
|
|
434
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
339
435
|
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
*
|
|
343
|
-
*
|
|
436
|
+
* // Asume the inputed collection is empty.
|
|
437
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
438
|
+
* await collection
|
|
439
|
+
* .append([0, 1, 2, 3, 4, 5])
|
|
440
|
+
* .take(3)
|
|
441
|
+
* .toArray();
|
|
442
|
+
* // [0, 1, 2]
|
|
443
|
+
* }
|
|
344
444
|
* ```
|
|
345
445
|
* @example
|
|
346
446
|
* ```ts
|
|
347
|
-
* import {
|
|
447
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
348
448
|
*
|
|
349
|
-
*
|
|
350
|
-
*
|
|
351
|
-
*
|
|
352
|
-
*
|
|
449
|
+
* // Asume the inputed collection is empty.
|
|
450
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
451
|
+
* await collection
|
|
452
|
+
* .append([0, 1, 2, 3, 4, 5])
|
|
453
|
+
* .take(-2)
|
|
454
|
+
* .toArray();
|
|
455
|
+
* // [0, 1, 2, 3]
|
|
456
|
+
* }
|
|
353
457
|
* ```
|
|
354
458
|
*/
|
|
355
459
|
take(limit: number): IAsyncCollection<TInput>;
|
|
@@ -357,12 +461,16 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
357
461
|
* The <i>takeUntil</i> method takes items until <i>predicateFn</i> returns true.
|
|
358
462
|
* @example
|
|
359
463
|
* ```ts
|
|
360
|
-
* import {
|
|
464
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
361
465
|
*
|
|
362
|
-
*
|
|
363
|
-
*
|
|
364
|
-
*
|
|
365
|
-
*
|
|
466
|
+
* // Asume the inputed collection is empty.
|
|
467
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
468
|
+
* await collection
|
|
469
|
+
* .append([1, 2, 3, 4])
|
|
470
|
+
* .takeUntil(item => item >= 3)
|
|
471
|
+
* .toArray();
|
|
472
|
+
* // [1, 2]
|
|
473
|
+
* }
|
|
366
474
|
* ```
|
|
367
475
|
*/
|
|
368
476
|
takeUntil(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): IAsyncCollection<TInput>;
|
|
@@ -370,12 +478,16 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
370
478
|
* The <i>takeWhile</i> method takes items until <i>predicateFn</i> returns false.
|
|
371
479
|
* @example
|
|
372
480
|
* ```ts
|
|
373
|
-
* import {
|
|
481
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
374
482
|
*
|
|
375
|
-
*
|
|
376
|
-
*
|
|
377
|
-
*
|
|
378
|
-
*
|
|
483
|
+
* // Asume the inputed collection is empty.
|
|
484
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
485
|
+
* await collection
|
|
486
|
+
* .append([1, 2, 3, 4])
|
|
487
|
+
* .takeWhile(item => item < 4)
|
|
488
|
+
* .toArray();
|
|
489
|
+
* // [1, 2, 3]
|
|
490
|
+
* }
|
|
379
491
|
* ```
|
|
380
492
|
*/
|
|
381
493
|
takeWhile(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): IAsyncCollection<TInput>;
|
|
@@ -383,11 +495,16 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
383
495
|
* The <i>skip</i> method skips the first <i>offset</i> items.
|
|
384
496
|
* @example
|
|
385
497
|
* ```ts
|
|
386
|
-
* import {
|
|
498
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
387
499
|
*
|
|
388
|
-
*
|
|
389
|
-
*
|
|
390
|
-
*
|
|
500
|
+
* // Asume the inputed collection is empty.
|
|
501
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
502
|
+
* await collection
|
|
503
|
+
* .append([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
|
|
504
|
+
* .skip(4)
|
|
505
|
+
* .toArray();
|
|
506
|
+
* // [5, 6, 7, 8, 9, 10]
|
|
507
|
+
* }
|
|
391
508
|
* ```
|
|
392
509
|
*/
|
|
393
510
|
skip(offset: number): IAsyncCollection<TInput>;
|
|
@@ -395,11 +512,16 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
395
512
|
* The <i>skipUntil</i> method skips items until <i>predicateFn</i> returns true.
|
|
396
513
|
* @example
|
|
397
514
|
* ```ts
|
|
398
|
-
* import {
|
|
515
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
399
516
|
*
|
|
400
|
-
*
|
|
401
|
-
*
|
|
402
|
-
*
|
|
517
|
+
* // Asume the inputed collection is empty.
|
|
518
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
519
|
+
* await collection
|
|
520
|
+
* .append([1, 2, 3, 4])
|
|
521
|
+
* .skipUntil(item => item >= 3)
|
|
522
|
+
* .toArray();
|
|
523
|
+
* // [3, 4]
|
|
524
|
+
* }
|
|
403
525
|
* ```
|
|
404
526
|
*/
|
|
405
527
|
skipUntil(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): IAsyncCollection<TInput>;
|
|
@@ -407,11 +529,16 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
407
529
|
* The <i>skipWhile</i> method skips items until <i>predicateFn</i> returns false.
|
|
408
530
|
* @example
|
|
409
531
|
* ```ts
|
|
410
|
-
* import {
|
|
532
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
411
533
|
*
|
|
412
|
-
*
|
|
413
|
-
*
|
|
414
|
-
*
|
|
534
|
+
* // Asume the inputed collection is empty.
|
|
535
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
536
|
+
* await collection
|
|
537
|
+
* .append([1, 2, 3, 4])
|
|
538
|
+
* .skipWhile(item => item <= 3)
|
|
539
|
+
* .toArray();
|
|
540
|
+
* // [4]
|
|
541
|
+
* }
|
|
415
542
|
* ```
|
|
416
543
|
*/
|
|
417
544
|
skipWhile(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): IAsyncCollection<TInput>;
|
|
@@ -419,13 +546,17 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
419
546
|
* The <i>when</i> method will execute <i>callback</i> when <i>condition</i> evaluates to true.
|
|
420
547
|
* @example
|
|
421
548
|
* ```ts
|
|
422
|
-
* import {
|
|
549
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
423
550
|
*
|
|
424
|
-
*
|
|
425
|
-
*
|
|
426
|
-
*
|
|
427
|
-
*
|
|
428
|
-
*
|
|
551
|
+
* // Asume the inputed collection is empty.
|
|
552
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
553
|
+
* await collection
|
|
554
|
+
* .append([1, 2, 3, 4])
|
|
555
|
+
* .when(true, collection => collection.append([-3]))
|
|
556
|
+
* .when(false, collection => collection.append([20]))
|
|
557
|
+
* .toArray();
|
|
558
|
+
* // [1, 2, 3, 4, -3]
|
|
559
|
+
* }
|
|
429
560
|
* ```
|
|
430
561
|
*/
|
|
431
562
|
when<TExtended = TInput>(condition: boolean, callback: AsyncModifier<IAsyncCollection<TInput>, IAsyncCollection<TExtended>>): IAsyncCollection<TInput | TExtended>;
|
|
@@ -433,21 +564,29 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
433
564
|
* The <i>whenEmpty</i> method will execute <i>callback</i> when the collection is empty.
|
|
434
565
|
* @example
|
|
435
566
|
* ```ts
|
|
436
|
-
* import {
|
|
567
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
437
568
|
*
|
|
438
|
-
*
|
|
439
|
-
*
|
|
440
|
-
*
|
|
441
|
-
*
|
|
569
|
+
* // Asume the inputed collection is empty.
|
|
570
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
571
|
+
* await collection
|
|
572
|
+
* .append([])
|
|
573
|
+
* .whenEmpty(collection => collection.append([-3]))
|
|
574
|
+
* .toArray();
|
|
575
|
+
* // [-3]
|
|
576
|
+
* }
|
|
442
577
|
* ```
|
|
443
578
|
* @example
|
|
444
579
|
* ```ts
|
|
445
|
-
* import {
|
|
580
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
446
581
|
*
|
|
447
|
-
*
|
|
448
|
-
*
|
|
449
|
-
*
|
|
450
|
-
*
|
|
582
|
+
* // Asume the inputed collection is empty.
|
|
583
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
584
|
+
* await collection
|
|
585
|
+
* .append([1])
|
|
586
|
+
* .whenEmpty(collection => collection.append([-3]))
|
|
587
|
+
* .toArray();
|
|
588
|
+
* // [1]
|
|
589
|
+
* }
|
|
451
590
|
* ```
|
|
452
591
|
*/
|
|
453
592
|
whenEmpty<TExtended = TInput>(callback: AsyncModifier<IAsyncCollection<TInput>, IAsyncCollection<TExtended>>): IAsyncCollection<TInput | TExtended>;
|
|
@@ -455,13 +594,17 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
455
594
|
* The <i>whenNot</i> method will execute <i>callback</i> when <i>condition</i> evaluates to false.
|
|
456
595
|
* @example
|
|
457
596
|
* ```ts
|
|
458
|
-
* import {
|
|
597
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
459
598
|
*
|
|
460
|
-
*
|
|
461
|
-
*
|
|
462
|
-
*
|
|
463
|
-
*
|
|
464
|
-
*
|
|
599
|
+
* // Asume the inputed collection is empty.
|
|
600
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
601
|
+
* await collection
|
|
602
|
+
* .append([1, 2, 3, 4])
|
|
603
|
+
* .whenNot(true, collection => collection.append([-3]))
|
|
604
|
+
* .whenNot(false, collection => collection.append([20]))
|
|
605
|
+
* .toArray();
|
|
606
|
+
* // [1, 2, 3, 4, 20]
|
|
607
|
+
* }
|
|
465
608
|
* ```
|
|
466
609
|
*/
|
|
467
610
|
whenNot<TExtended = TInput>(condition: boolean, callback: AsyncModifier<IAsyncCollection<TInput>, IAsyncCollection<TExtended>>): IAsyncCollection<TInput | TExtended>;
|
|
@@ -469,21 +612,28 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
469
612
|
* The <i>whenNotEmpty</i> method will execute <i>callback</i> when the collection is not empty.
|
|
470
613
|
* @example
|
|
471
614
|
* ```ts
|
|
472
|
-
* import {
|
|
615
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
473
616
|
*
|
|
474
|
-
*
|
|
475
|
-
*
|
|
476
|
-
*
|
|
477
|
-
*
|
|
617
|
+
* // Asume the inputed collection is empty.
|
|
618
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
619
|
+
* await collection
|
|
620
|
+
* .append([])
|
|
621
|
+
* .whenNotEmpty(collection => collection.append([-3])).toArray();
|
|
622
|
+
* // []
|
|
623
|
+
* }
|
|
478
624
|
* ```
|
|
479
625
|
* @example
|
|
480
626
|
* ```ts
|
|
481
|
-
* import {
|
|
627
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
482
628
|
*
|
|
483
|
-
*
|
|
484
|
-
*
|
|
485
|
-
*
|
|
486
|
-
*
|
|
629
|
+
* // Asume the inputed collection is empty.
|
|
630
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
631
|
+
* await collection
|
|
632
|
+
* .append([1])
|
|
633
|
+
* .whenNotEmpty(collection => collection.append([-3]))
|
|
634
|
+
* .toArray();
|
|
635
|
+
* // [1, -3]
|
|
636
|
+
* }
|
|
487
637
|
* ```
|
|
488
638
|
*/
|
|
489
639
|
whenNotEmpty<TExtended = TInput>(callback: AsyncModifier<IAsyncCollection<TInput>, IAsyncCollection<TExtended>>): IAsyncCollection<TInput | TExtended>;
|
|
@@ -492,22 +642,26 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
492
642
|
* This method is useful when you want compose multiple smaller functions.
|
|
493
643
|
* @example
|
|
494
644
|
* ```ts
|
|
495
|
-
* import {
|
|
496
|
-
*
|
|
497
|
-
*
|
|
498
|
-
* function
|
|
499
|
-
*
|
|
500
|
-
*
|
|
501
|
-
*
|
|
502
|
-
*
|
|
503
|
-
*
|
|
504
|
-
*
|
|
505
|
-
*
|
|
506
|
-
*
|
|
645
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
646
|
+
*
|
|
647
|
+
* // Asume the inputed collection is empty.
|
|
648
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
649
|
+
* function toNbrs<TInput>(
|
|
650
|
+
* collection: IAsyncCollection<TInput>,
|
|
651
|
+
* ): IAsyncCollection<number> {
|
|
652
|
+
* return collection
|
|
653
|
+
* .map((item) => Number(item))
|
|
654
|
+
* .reject((nbr) => Number.isNaN(nbr));
|
|
655
|
+
* }
|
|
656
|
+
* function nbrToStr(collection: IAsyncCollection<number>): number[] {
|
|
657
|
+
* return collection.repeat(2).toArray();
|
|
658
|
+
* }
|
|
659
|
+
* await collection
|
|
660
|
+
* .append([1, "2", "a", 1, 3, {}])
|
|
661
|
+
* .pipe(toNbrs)
|
|
662
|
+
* .then(nbrToStr);
|
|
663
|
+
* // [ 1, 2, 1, 3 ]
|
|
507
664
|
* }
|
|
508
|
-
* const piped = await collection.pipe(toNbrs).then(nbrToStr);
|
|
509
|
-
* console.log(piped);
|
|
510
|
-
* // [ 1, 2, 1, 3 ]
|
|
511
665
|
* ```
|
|
512
666
|
*/
|
|
513
667
|
pipe<TOutput = TInput>(callback: AsyncTransform<IAsyncCollection<TInput>, TOutput>): LazyPromise<TOutput>;
|
|
@@ -515,16 +669,20 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
515
669
|
* The <i>tap</i> method passes a copy of the original collection to <i>callback</i>, allowing you to do something with the items while not affecting the original collection.
|
|
516
670
|
* @example
|
|
517
671
|
* ```ts
|
|
518
|
-
* import {
|
|
672
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
519
673
|
*
|
|
520
|
-
*
|
|
521
|
-
*
|
|
522
|
-
*
|
|
523
|
-
*
|
|
524
|
-
*
|
|
525
|
-
*
|
|
526
|
-
*
|
|
527
|
-
*
|
|
674
|
+
* // Asume the inputed collection is empty.
|
|
675
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
676
|
+
* await collection
|
|
677
|
+
* .append([1, 2, 3, 4, 5, 6])
|
|
678
|
+
* .tap(collection => {
|
|
679
|
+
* collection
|
|
680
|
+
* .filter(value => value % 2 === 0)
|
|
681
|
+
* .forEach(value => console.log(value))
|
|
682
|
+
* })
|
|
683
|
+
* .toArray();
|
|
684
|
+
* // [1, 2, 3, 4, 5, 6]
|
|
685
|
+
* }
|
|
528
686
|
* ```
|
|
529
687
|
*/
|
|
530
688
|
tap(callback: AsyncTap<IAsyncCollection<TInput>>): IAsyncCollection<TInput>;
|
|
@@ -533,12 +691,17 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
533
691
|
* If <i>chunkSize</i> is not divisible with total number of items then the last chunk will contain the remaining items.
|
|
534
692
|
* @example
|
|
535
693
|
* ```ts
|
|
536
|
-
* import {
|
|
694
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
537
695
|
*
|
|
538
|
-
*
|
|
539
|
-
*
|
|
540
|
-
*
|
|
541
|
-
*
|
|
696
|
+
* // Asume the inputed collection is empty.
|
|
697
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
698
|
+
* await collection
|
|
699
|
+
* .append([1, 2, 3, 4, 5, 6, 7])
|
|
700
|
+
* .chunk(4)
|
|
701
|
+
* .map(chunk => chunk.toArray())
|
|
702
|
+
* .toArray();
|
|
703
|
+
* // [[1, 2, 3, 4], [5, 6, 7]]
|
|
704
|
+
* }
|
|
542
705
|
* ```
|
|
543
706
|
*/
|
|
544
707
|
chunk(chunkSize: number): IAsyncCollection<IAsyncCollection<TInput>>;
|
|
@@ -547,14 +710,19 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
547
710
|
* The chunk variable passed to the <i>predicateFn</i> may be used to inspect the previous item.
|
|
548
711
|
* @example
|
|
549
712
|
* ```ts
|
|
550
|
-
* import {
|
|
713
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
551
714
|
*
|
|
552
|
-
*
|
|
553
|
-
*
|
|
554
|
-
*
|
|
555
|
-
*
|
|
556
|
-
*
|
|
557
|
-
*
|
|
715
|
+
* // Asume the inputed collection is empty.
|
|
716
|
+
* async function main(collection: IAsyncCollection<string>): Promise<void> {
|
|
717
|
+
* await collection
|
|
718
|
+
* .append("AABBCCCD")
|
|
719
|
+
* .chunkWhile((value, index, chunk) => {
|
|
720
|
+
* return value === chunk.last();
|
|
721
|
+
* })
|
|
722
|
+
* .map(chunk => chunk.toArray())
|
|
723
|
+
* .toArray();
|
|
724
|
+
* // [["A", "A"], ["B", "B"], ["C", "C", "C"], ["D"]]
|
|
725
|
+
* }
|
|
558
726
|
* ```
|
|
559
727
|
*/
|
|
560
728
|
chunkWhile(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): IAsyncCollection<IAsyncCollection<TInput>>;
|
|
@@ -562,42 +730,62 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
562
730
|
* The <i>split</i> method breaks a collection evenly into <i>chunkAmount</i> of chunks.
|
|
563
731
|
* @example
|
|
564
732
|
* ```ts
|
|
565
|
-
* import {
|
|
733
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
566
734
|
*
|
|
567
|
-
*
|
|
568
|
-
*
|
|
569
|
-
*
|
|
570
|
-
*
|
|
735
|
+
* // Asume the inputed collection is empty.
|
|
736
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
737
|
+
* await collection
|
|
738
|
+
* .append([1, 2, 3, 4, 5])
|
|
739
|
+
* .split(3)
|
|
740
|
+
* .map(chunk => chunk.toArray())
|
|
741
|
+
* .toArray();
|
|
742
|
+
* // [[1, 2], [3, 4], [5]]
|
|
743
|
+
* }
|
|
571
744
|
* ```
|
|
572
745
|
* @example
|
|
573
746
|
* ```ts
|
|
574
|
-
* import {
|
|
747
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
575
748
|
*
|
|
576
|
-
*
|
|
577
|
-
*
|
|
578
|
-
*
|
|
579
|
-
*
|
|
749
|
+
* // Asume the inputed collection is empty.
|
|
750
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
751
|
+
* await collection
|
|
752
|
+
* .append([1, 2, 3, 4, 5, 6])
|
|
753
|
+
* .split(3)
|
|
754
|
+
* .map(chunk => chunk.toArray())
|
|
755
|
+
* .toArray();
|
|
756
|
+
* // [[1, 2], [3, 4], [5, 6]]
|
|
757
|
+
* }
|
|
580
758
|
* ```
|
|
581
759
|
* @example
|
|
582
760
|
* ```ts
|
|
583
|
-
* import {
|
|
761
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
584
762
|
*
|
|
585
|
-
*
|
|
586
|
-
*
|
|
587
|
-
*
|
|
588
|
-
*
|
|
763
|
+
* // Asume the inputed collection is empty.
|
|
764
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
765
|
+
* await collection
|
|
766
|
+
* .append([1, 2, 3, 4, 5, 6, 7])
|
|
767
|
+
* .split(3)
|
|
768
|
+
* .map(chunk => chunk.toArray())
|
|
769
|
+
* .toArray();
|
|
770
|
+
* // [[1, 2, 7], [3, 4], [5, 6]]
|
|
771
|
+
* }
|
|
589
772
|
*/
|
|
590
773
|
split(chunkAmount: number): IAsyncCollection<IAsyncCollection<TInput>>;
|
|
591
774
|
/**
|
|
592
775
|
* The <i>partition</i> method is used to separate items that pass <i>predicateFn</i> from those that do not.
|
|
593
776
|
* @example
|
|
594
777
|
* ```ts
|
|
595
|
-
* import {
|
|
778
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
596
779
|
*
|
|
597
|
-
*
|
|
598
|
-
*
|
|
599
|
-
*
|
|
600
|
-
*
|
|
780
|
+
* // Asume the inputed collection is empty.
|
|
781
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
782
|
+
* await collection
|
|
783
|
+
* .append([1, 2, 3, 4, 5, 6])
|
|
784
|
+
* .partition(item => item < 3)
|
|
785
|
+
* .map(chunk => chunk.toArray())
|
|
786
|
+
* .toArray();
|
|
787
|
+
* // [[1, 2], [3, 4, 5, 6]]
|
|
788
|
+
* }
|
|
601
789
|
* ```
|
|
602
790
|
*/
|
|
603
791
|
partition(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): IAsyncCollection<IAsyncCollection<TInput>>;
|
|
@@ -605,12 +793,17 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
605
793
|
* The <i>sliding</i> method returns a new collection of chunks representing a "sliding window" view of the items in the collection.
|
|
606
794
|
* @example
|
|
607
795
|
* ```ts
|
|
608
|
-
* import {
|
|
796
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
609
797
|
*
|
|
610
|
-
*
|
|
611
|
-
*
|
|
612
|
-
*
|
|
613
|
-
*
|
|
798
|
+
* // Asume the inputed collection is empty.
|
|
799
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
800
|
+
* await collection
|
|
801
|
+
* .append([1, 2, 3, 4, 5])
|
|
802
|
+
* .sliding(2)
|
|
803
|
+
* .map(chunk => chunk.toArray())
|
|
804
|
+
* .toArray();
|
|
805
|
+
* // [[1, 2], [2, 3], [3, 4], [4, 5]]
|
|
806
|
+
* }
|
|
614
807
|
* ```
|
|
615
808
|
*/
|
|
616
809
|
sliding(chunkSize: number, step?: number): IAsyncCollection<IAsyncCollection<TInput>>;
|
|
@@ -619,47 +812,53 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
619
812
|
* By default the equality check occurs on the item.
|
|
620
813
|
* @example
|
|
621
814
|
* ```ts
|
|
622
|
-
* import {
|
|
623
|
-
*
|
|
624
|
-
*
|
|
625
|
-
*
|
|
626
|
-
*
|
|
627
|
-
*
|
|
628
|
-
*
|
|
629
|
-
*
|
|
630
|
-
*
|
|
631
|
-
*
|
|
632
|
-
*
|
|
633
|
-
*
|
|
634
|
-
*
|
|
635
|
-
*
|
|
636
|
-
*
|
|
637
|
-
*
|
|
638
|
-
*
|
|
639
|
-
*
|
|
640
|
-
*
|
|
641
|
-
*
|
|
642
|
-
*
|
|
643
|
-
*
|
|
644
|
-
*
|
|
645
|
-
*
|
|
646
|
-
*
|
|
647
|
-
*
|
|
648
|
-
*
|
|
649
|
-
*
|
|
650
|
-
*
|
|
651
|
-
*
|
|
652
|
-
*
|
|
653
|
-
*
|
|
654
|
-
*
|
|
655
|
-
*
|
|
656
|
-
*
|
|
657
|
-
*
|
|
658
|
-
*
|
|
659
|
-
*
|
|
660
|
-
*
|
|
661
|
-
*
|
|
662
|
-
*
|
|
815
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
816
|
+
*
|
|
817
|
+
* // Asume the inputed collection is empty.
|
|
818
|
+
* async function main(collection: IAsyncCollection<string>): Promise<void> {
|
|
819
|
+
* await collection
|
|
820
|
+
* .append(["a", "a", "a", "b", "b", "c"])
|
|
821
|
+
* .groupBy()
|
|
822
|
+
* .map(([key, collection]) => [key, collection.toArray()])
|
|
823
|
+
* .toArray();
|
|
824
|
+
* // [
|
|
825
|
+
* // [
|
|
826
|
+
* // "a",
|
|
827
|
+
* // ["a", "a", "a"]
|
|
828
|
+
* // ],
|
|
829
|
+
* // [
|
|
830
|
+
* // "b",
|
|
831
|
+
* // ["b", "b"]
|
|
832
|
+
* // ],
|
|
833
|
+
* // [
|
|
834
|
+
* // "c",
|
|
835
|
+
* // ["c"]
|
|
836
|
+
* // ]
|
|
837
|
+
* // ]
|
|
838
|
+
* }
|
|
839
|
+
* ```
|
|
840
|
+
* @example
|
|
841
|
+
* ```ts
|
|
842
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
843
|
+
*
|
|
844
|
+
* // Asume the inputed collection is empty.
|
|
845
|
+
* async function main(collection: IAsyncCollection<string>): Promise<void> {
|
|
846
|
+
* await collection
|
|
847
|
+
* .append(["alice@gmail.com", "bob@yahoo.com", "carlos@gmail.com"])
|
|
848
|
+
* .groupBy(item => item.split("@")[1])
|
|
849
|
+
* .map(([key, collection]) => [key, collection.toArray()])
|
|
850
|
+
* .toArray();
|
|
851
|
+
* // [
|
|
852
|
+
* // [
|
|
853
|
+
* // "gmail.com",
|
|
854
|
+
* // ["alice@gmail.com", "carlos@gmail.com"]
|
|
855
|
+
* // ],
|
|
856
|
+
* // [
|
|
857
|
+
* // "yahoo.com",
|
|
858
|
+
* // ["bob@yahoo.com"]
|
|
859
|
+
* // ]
|
|
860
|
+
* // ]
|
|
861
|
+
* }
|
|
663
862
|
* ```
|
|
664
863
|
*/
|
|
665
864
|
groupBy<TOutput = TInput>(selectFn?: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput>): IAsyncCollection<[TOutput, IAsyncCollection<TInput>]>;
|
|
@@ -668,31 +867,37 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
668
867
|
* By default the equality check occurs on the item.
|
|
669
868
|
* @example
|
|
670
869
|
* ```ts
|
|
671
|
-
* import {
|
|
672
|
-
*
|
|
673
|
-
*
|
|
674
|
-
*
|
|
675
|
-
*
|
|
676
|
-
*
|
|
677
|
-
*
|
|
678
|
-
*
|
|
679
|
-
*
|
|
680
|
-
*
|
|
681
|
-
*
|
|
682
|
-
*
|
|
870
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
871
|
+
*
|
|
872
|
+
* // Asume the inputed collection is empty.
|
|
873
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
874
|
+
* await collection
|
|
875
|
+
* .append(["a", "a", "a", "b", "b", "c"])
|
|
876
|
+
* .countBy()
|
|
877
|
+
* .map(([key, collection]) => [key, collection.toArray()])
|
|
878
|
+
* .toArray();
|
|
879
|
+
* // [
|
|
880
|
+
* // ["a", 3],
|
|
881
|
+
* // ["b", 2],
|
|
882
|
+
* // ["c", 1]
|
|
883
|
+
* // ]
|
|
884
|
+
* }
|
|
683
885
|
* ```
|
|
684
886
|
* @example
|
|
685
887
|
* ```ts
|
|
686
|
-
* import {
|
|
888
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
687
889
|
*
|
|
688
|
-
*
|
|
689
|
-
*
|
|
690
|
-
*
|
|
691
|
-
*
|
|
692
|
-
*
|
|
693
|
-
*
|
|
694
|
-
*
|
|
695
|
-
*
|
|
890
|
+
* // Asume the inputed collection is empty.
|
|
891
|
+
* async function main(collection: IAsyncCollection<string>): Promise<void> {
|
|
892
|
+
* await collection
|
|
893
|
+
* .append(["alice@gmail.com", "bob@yahoo.com", "carlos@gmail.com"])
|
|
894
|
+
* .countBy(item => item.split("@")[1])
|
|
895
|
+
* .toArray();
|
|
896
|
+
* // [
|
|
897
|
+
* // ["gmail.com", 2],
|
|
898
|
+
* // ["yahoo.com", 1]
|
|
899
|
+
* // ]
|
|
900
|
+
* }
|
|
696
901
|
* ```
|
|
697
902
|
*/
|
|
698
903
|
countBy<TOutput = TInput>(selectFn?: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput>): IAsyncCollection<[TOutput, number]>;
|
|
@@ -701,30 +906,44 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
701
906
|
* By default the equality check occurs on the item.
|
|
702
907
|
* @example
|
|
703
908
|
* ```ts
|
|
704
|
-
* import {
|
|
909
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
910
|
+
*
|
|
911
|
+
* type Phone = {
|
|
912
|
+
* name: string;
|
|
913
|
+
* brand: string;
|
|
914
|
+
* type: string;
|
|
915
|
+
* };
|
|
705
916
|
*
|
|
706
|
-
*
|
|
707
|
-
*
|
|
708
|
-
*
|
|
917
|
+
* // Asume the inputed collection is empty.
|
|
918
|
+
* async function main(collection: IAsyncCollection<Phone>): Promise<void> {
|
|
919
|
+
* await collection
|
|
920
|
+
* .append([1, 1, 2, 2, 3, 4, 2])
|
|
921
|
+
* .unique()
|
|
922
|
+
* .toArray();
|
|
923
|
+
* // [1, 2, 3, 4]
|
|
924
|
+
* }
|
|
709
925
|
* ```
|
|
710
926
|
* @example
|
|
711
927
|
* ```ts
|
|
712
|
-
* import {
|
|
713
|
-
*
|
|
714
|
-
*
|
|
715
|
-
*
|
|
716
|
-
*
|
|
717
|
-
*
|
|
718
|
-
*
|
|
719
|
-
*
|
|
720
|
-
*
|
|
721
|
-
*
|
|
722
|
-
*
|
|
723
|
-
*
|
|
724
|
-
*
|
|
725
|
-
*
|
|
726
|
-
*
|
|
727
|
-
*
|
|
928
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
929
|
+
*
|
|
930
|
+
* // Asume the inputed collection is empty.
|
|
931
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
932
|
+
* await collection
|
|
933
|
+
* .append([
|
|
934
|
+
* { name: "iPhone 6", brand: "Apple", type: "phone" },
|
|
935
|
+
* { name: "iPhone 5", brand: "Apple", type: "phone" },
|
|
936
|
+
* { name: "Apple Watch", brand: "Apple", type: "watch" },
|
|
937
|
+
* { name: "Galaxy S6", brand: "Samsung", type: "phone" },
|
|
938
|
+
* { name: "Galaxy Gear", brand: "Samsung", type: "watch" },
|
|
939
|
+
* ])
|
|
940
|
+
* .unique(item => item.brand)
|
|
941
|
+
* .toArray();
|
|
942
|
+
* // [
|
|
943
|
+
* // { name: "iPhone 6", brand: "Apple", type: "phone" },
|
|
944
|
+
* // { name: "Galaxy S6", brand: "Samsung", type: "phone" },
|
|
945
|
+
* // ]
|
|
946
|
+
* }
|
|
728
947
|
* ```
|
|
729
948
|
*/
|
|
730
949
|
unique<TOutput = TInput>(selectFn?: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput>): IAsyncCollection<TInput>;
|
|
@@ -733,36 +952,50 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
733
952
|
* By default the equality check occurs on the item.
|
|
734
953
|
* @example
|
|
735
954
|
* ```ts
|
|
736
|
-
* import {
|
|
955
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
737
956
|
*
|
|
738
|
-
*
|
|
739
|
-
*
|
|
740
|
-
*
|
|
741
|
-
*
|
|
957
|
+
* // Asume the inputed collection is empty.
|
|
958
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
959
|
+
* await collection
|
|
960
|
+
* .append([1, 2, 2, 3, 4, 5])
|
|
961
|
+
* .difference([2, 4, 6, 8])
|
|
962
|
+
* .toArray();
|
|
963
|
+
* // [1, 3, 5]
|
|
964
|
+
* }
|
|
742
965
|
* ```
|
|
743
966
|
* @example
|
|
744
967
|
* ```ts
|
|
745
|
-
* import {
|
|
746
|
-
*
|
|
747
|
-
*
|
|
748
|
-
*
|
|
749
|
-
*
|
|
750
|
-
*
|
|
751
|
-
*
|
|
752
|
-
*
|
|
753
|
-
*
|
|
754
|
-
*
|
|
755
|
-
*
|
|
756
|
-
*
|
|
757
|
-
*
|
|
758
|
-
*
|
|
759
|
-
*
|
|
760
|
-
*
|
|
761
|
-
*
|
|
762
|
-
*
|
|
763
|
-
*
|
|
764
|
-
*
|
|
765
|
-
*
|
|
968
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
969
|
+
*
|
|
970
|
+
* type Phone = {
|
|
971
|
+
* name: string;
|
|
972
|
+
* brand: string;
|
|
973
|
+
* type: string;
|
|
974
|
+
* };
|
|
975
|
+
*
|
|
976
|
+
* // Asume the inputed collection is empty.
|
|
977
|
+
* async function main(collection: IAsyncCollection<Phone>): Promise<void> {
|
|
978
|
+
* await collection
|
|
979
|
+
* .append([
|
|
980
|
+
* { name: "iPhone 6", brand: "Apple", type: "phone" },
|
|
981
|
+
* { name: "iPhone 5", brand: "Apple", type: "phone" },
|
|
982
|
+
* { name: "Apple Watch", brand: "Apple", type: "watch" },
|
|
983
|
+
* { name: "Galaxy S6", brand: "Samsung", type: "phone" },
|
|
984
|
+
* { name: "Galaxy Gear", brand: "Samsung", type: "watch" },
|
|
985
|
+
* ])
|
|
986
|
+
* .difference(
|
|
987
|
+
* [
|
|
988
|
+
* { name: "Apple Watch", brand: "Apple", type: "watch" },
|
|
989
|
+
* ],
|
|
990
|
+
* (product) => product.type
|
|
991
|
+
* )
|
|
992
|
+
* .toArray();
|
|
993
|
+
* // [
|
|
994
|
+
* // { name: "iPhone 6", brand: "Apple", type: "phone" },
|
|
995
|
+
* // { name: "iPhone 5", brand: "Apple", type: "phone" },
|
|
996
|
+
* // { name: "Galaxy S6", brand: "Samsung", type: "phone" },
|
|
997
|
+
* // ]
|
|
998
|
+
* }
|
|
766
999
|
* ```
|
|
767
1000
|
*/
|
|
768
1001
|
difference<TOutput = TInput>(iterable: AsyncIterableValue<TInput>, selectFn?: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput>): IAsyncCollection<TInput>;
|
|
@@ -770,12 +1003,16 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
770
1003
|
* The <i>repeat</i> method will repeat the original collection <i>amount</i> times.
|
|
771
1004
|
* @example
|
|
772
1005
|
* ```ts
|
|
773
|
-
* import {
|
|
1006
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
774
1007
|
*
|
|
775
|
-
*
|
|
776
|
-
*
|
|
777
|
-
*
|
|
778
|
-
*
|
|
1008
|
+
* // Asume the inputed collection is empty.
|
|
1009
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1010
|
+
* await collection
|
|
1011
|
+
* .append([1, 2, 3])
|
|
1012
|
+
* .repeat(3)
|
|
1013
|
+
* .toArray();
|
|
1014
|
+
* // [1, 2, 3, 1, 2, 3, 1, 2, 3]
|
|
1015
|
+
* }
|
|
779
1016
|
* ```
|
|
780
1017
|
*/
|
|
781
1018
|
repeat(amount: number): IAsyncCollection<TInput>;
|
|
@@ -784,19 +1021,46 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
784
1021
|
* The padding is applied from the start of this collection.
|
|
785
1022
|
* @example
|
|
786
1023
|
* ```ts
|
|
787
|
-
* import {
|
|
788
|
-
*
|
|
789
|
-
* await new AsyncIterableCollection("abc").padStart(10, "foo").join("");
|
|
790
|
-
* // "foofoofabc"
|
|
1024
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
791
1025
|
*
|
|
792
|
-
*
|
|
793
|
-
*
|
|
794
|
-
*
|
|
795
|
-
*
|
|
796
|
-
*
|
|
797
|
-
*
|
|
798
|
-
*
|
|
799
|
-
*
|
|
1026
|
+
* // Asume the inputed collection is empty.
|
|
1027
|
+
* async function main(collection: IAsyncCollection<string>): Promise<void> {
|
|
1028
|
+
* await collection
|
|
1029
|
+
* .append("abc")
|
|
1030
|
+
* .padStart(10, "foo")
|
|
1031
|
+
* .join("");
|
|
1032
|
+
* // "foofoofabc"
|
|
1033
|
+
* }
|
|
1034
|
+
* ```
|
|
1035
|
+
* @example
|
|
1036
|
+
* ```ts
|
|
1037
|
+
* async function main(collection: IAsyncCollection<string>): Promise<void> {
|
|
1038
|
+
* await collection
|
|
1039
|
+
* .append("abc")
|
|
1040
|
+
* .padStart(6, "123465")
|
|
1041
|
+
* .join("");
|
|
1042
|
+
* // "123abc"
|
|
1043
|
+
* }
|
|
1044
|
+
* ```
|
|
1045
|
+
* @example
|
|
1046
|
+
* ```ts
|
|
1047
|
+
* async function main(collection: IAsyncCollection<string>): Promise<void> {
|
|
1048
|
+
* await collection
|
|
1049
|
+
* .append("abc")
|
|
1050
|
+
* .padStart(8, "0")
|
|
1051
|
+
* .join("");
|
|
1052
|
+
* // "00000abc"
|
|
1053
|
+
* }
|
|
1054
|
+
* ```
|
|
1055
|
+
* @example
|
|
1056
|
+
* ```ts
|
|
1057
|
+
* async function main(collection: IAsyncCollection<string>): Promise<void> {
|
|
1058
|
+
* await collection
|
|
1059
|
+
* .append("abc")
|
|
1060
|
+
* .padStart(1, "_")
|
|
1061
|
+
* .join("");
|
|
1062
|
+
* // "abc"
|
|
1063
|
+
* }
|
|
800
1064
|
* ```
|
|
801
1065
|
*/
|
|
802
1066
|
padStart<TExtended = TInput>(maxLength: number, fillItems: AsyncIterableValue<TExtended>): IAsyncCollection<TInput | TExtended>;
|
|
@@ -805,19 +1069,46 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
805
1069
|
* The padding is applied from the end of this collection.
|
|
806
1070
|
* @example
|
|
807
1071
|
* ```ts
|
|
808
|
-
* import {
|
|
809
|
-
*
|
|
810
|
-
* await new AsyncIterableCollection("abc").padEnd(10, "foo").join("");
|
|
811
|
-
* // "abcfoofoof"
|
|
1072
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
812
1073
|
*
|
|
813
|
-
*
|
|
814
|
-
*
|
|
815
|
-
*
|
|
816
|
-
*
|
|
817
|
-
*
|
|
818
|
-
*
|
|
819
|
-
*
|
|
820
|
-
*
|
|
1074
|
+
* // Asume the inputed collection is empty.
|
|
1075
|
+
* async function main(collection: IAsyncCollection<string>): Promise<void> {
|
|
1076
|
+
* await collection
|
|
1077
|
+
* .append("abc")
|
|
1078
|
+
* .padEnd(10, "foo")
|
|
1079
|
+
* .join("");
|
|
1080
|
+
* // "abcfoofoof"
|
|
1081
|
+
* }
|
|
1082
|
+
* ```
|
|
1083
|
+
* @example
|
|
1084
|
+
* ```ts
|
|
1085
|
+
* async function main(collection: IAsyncCollection<string>): Promise<void> {
|
|
1086
|
+
* await collection
|
|
1087
|
+
* .append("abc")
|
|
1088
|
+
* .padEnd(6, "123465")
|
|
1089
|
+
* .join("");
|
|
1090
|
+
* // "abc123"
|
|
1091
|
+
* }
|
|
1092
|
+
* ```
|
|
1093
|
+
* @example
|
|
1094
|
+
* ```ts
|
|
1095
|
+
* async function main(collection: IAsyncCollection<string>): Promise<void> {
|
|
1096
|
+
* await collection
|
|
1097
|
+
* .append("abc")
|
|
1098
|
+
* .padEnd(8, "0")
|
|
1099
|
+
* .join("");
|
|
1100
|
+
* // "abc00000"
|
|
1101
|
+
* }
|
|
1102
|
+
* ```
|
|
1103
|
+
* @example
|
|
1104
|
+
* ```ts
|
|
1105
|
+
* async function main(collection: IAsyncCollection<string>): Promise<void> {
|
|
1106
|
+
* await collection
|
|
1107
|
+
* .append("abc")
|
|
1108
|
+
* .padEnd(1, "_")
|
|
1109
|
+
* .join("");
|
|
1110
|
+
* // "abc"
|
|
1111
|
+
* }
|
|
821
1112
|
* ```
|
|
822
1113
|
*/
|
|
823
1114
|
padEnd<TExtended = TInput>(maxLength: number, fillItems: AsyncIterableValue<TExtended>): IAsyncCollection<TInput | TExtended>;
|
|
@@ -826,51 +1117,81 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
826
1117
|
* where <i>start</i> and <i>end</i> (end not included) represent the index of items in the collection.
|
|
827
1118
|
* @example
|
|
828
1119
|
* ```ts
|
|
829
|
-
* import {
|
|
1120
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
830
1121
|
*
|
|
831
|
-
*
|
|
832
|
-
*
|
|
833
|
-
*
|
|
1122
|
+
* // Asume the inputed collection is empty.
|
|
1123
|
+
* async function main(collection: IAsyncCollection<string>): Promise<void> {
|
|
1124
|
+
* await collection
|
|
1125
|
+
* .append(["a", "b", "c", "d", "e", "f"])
|
|
1126
|
+
* .slice(3)
|
|
1127
|
+
* .toArray();
|
|
1128
|
+
* // ["d", "e", "f"]
|
|
1129
|
+
* }
|
|
834
1130
|
* ```
|
|
835
1131
|
* @example
|
|
836
1132
|
* ```ts
|
|
837
|
-
* import {
|
|
1133
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
838
1134
|
*
|
|
839
|
-
*
|
|
840
|
-
*
|
|
841
|
-
*
|
|
1135
|
+
* // Asume the inputed collection is empty.
|
|
1136
|
+
* async function main(collection: IAsyncCollection<string>): Promise<void> {
|
|
1137
|
+
* await collection
|
|
1138
|
+
* .append(["a", "b", "c", "d", "e", "f"])
|
|
1139
|
+
* .slice(undefined, 2)
|
|
1140
|
+
* .toArray();
|
|
1141
|
+
* // ["a", "b"]
|
|
1142
|
+
* }
|
|
842
1143
|
* ```
|
|
843
1144
|
* @example
|
|
844
1145
|
* ```ts
|
|
845
|
-
* import {
|
|
1146
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
846
1147
|
*
|
|
847
|
-
*
|
|
848
|
-
*
|
|
849
|
-
*
|
|
1148
|
+
* // Asume the inputed collection is empty.
|
|
1149
|
+
* async function main(collection: IAsyncCollection<string>): Promise<void> {
|
|
1150
|
+
* await collection
|
|
1151
|
+
* .append(["a", "b", "c", "d", "e", "f"])
|
|
1152
|
+
* .slice(2, 5)
|
|
1153
|
+
* .toArray();
|
|
1154
|
+
* // ["c", "d", "e"]
|
|
1155
|
+
* }
|
|
850
1156
|
* ```
|
|
851
1157
|
* @example
|
|
852
1158
|
* ```ts
|
|
853
|
-
* import {
|
|
1159
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
854
1160
|
*
|
|
855
|
-
*
|
|
856
|
-
*
|
|
857
|
-
*
|
|
1161
|
+
* // Asume the inputed collection is empty.
|
|
1162
|
+
* async function main(collection: IAsyncCollection<string>): Promise<void> {
|
|
1163
|
+
* await collection
|
|
1164
|
+
* .append(["a", "b", "c", "d", "e", "f"])
|
|
1165
|
+
* .slice(-2)
|
|
1166
|
+
* .toArray();
|
|
1167
|
+
* // ["e", "f"]
|
|
1168
|
+
* }
|
|
858
1169
|
* ```
|
|
859
1170
|
* @example
|
|
860
1171
|
* ```ts
|
|
861
|
-
* import {
|
|
1172
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
862
1173
|
*
|
|
863
|
-
*
|
|
864
|
-
*
|
|
865
|
-
*
|
|
1174
|
+
* // Asume the inputed collection is empty.
|
|
1175
|
+
* async function main(collection: IAsyncCollection<string>): Promise<void> {
|
|
1176
|
+
* await collection
|
|
1177
|
+
* .append(["a", "b", "c", "d", "e", "f"])
|
|
1178
|
+
* .slice(undefined, -2)
|
|
1179
|
+
* .toArray();
|
|
1180
|
+
* // ["a", "b", "c", "d"]
|
|
1181
|
+
* }
|
|
866
1182
|
* ```
|
|
867
1183
|
* @example
|
|
868
1184
|
* ```ts
|
|
869
|
-
* import {
|
|
1185
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
870
1186
|
*
|
|
871
|
-
*
|
|
872
|
-
*
|
|
873
|
-
*
|
|
1187
|
+
* // Asume the inputed collection is empty.
|
|
1188
|
+
* async function main(collection: IAsyncCollection<string>): Promise<void> {
|
|
1189
|
+
* await collection
|
|
1190
|
+
* .append(["a", "b", "c", "d", "e", "f"])
|
|
1191
|
+
* .slice(-4, -2)
|
|
1192
|
+
* .toArray();
|
|
1193
|
+
* // ["c", "d"]
|
|
1194
|
+
* }
|
|
874
1195
|
* ```
|
|
875
1196
|
*/
|
|
876
1197
|
slice(start?: number, end?: number): IAsyncCollection<TInput>;
|
|
@@ -878,11 +1199,16 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
878
1199
|
* The <i>prepend</i> method adds <i>iterable</i> to the beginning of the collection.
|
|
879
1200
|
* @example
|
|
880
1201
|
* ```ts
|
|
881
|
-
* import {
|
|
1202
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
882
1203
|
*
|
|
883
|
-
*
|
|
884
|
-
*
|
|
885
|
-
*
|
|
1204
|
+
* // Asume the inputed collection is empty.
|
|
1205
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1206
|
+
* await collection
|
|
1207
|
+
* .append([1, 2, 3, 4, 5])
|
|
1208
|
+
* .prepend([-1, 20])
|
|
1209
|
+
* .toArray();
|
|
1210
|
+
* // [-1, 20, 1, 2, 3, 4, 5]
|
|
1211
|
+
* }
|
|
886
1212
|
* ```
|
|
887
1213
|
*/
|
|
888
1214
|
prepend<TExtended = TInput>(iterable: AsyncIterableValue<TInput | TExtended>): IAsyncCollection<TInput | TExtended>;
|
|
@@ -890,11 +1216,16 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
890
1216
|
* The <i>append</i> method adds <i>iterable</i> to the end of the collection.
|
|
891
1217
|
* @example
|
|
892
1218
|
* ```ts
|
|
893
|
-
* import {
|
|
1219
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
894
1220
|
*
|
|
895
|
-
*
|
|
896
|
-
*
|
|
897
|
-
*
|
|
1221
|
+
* // Asume the inputed collection is empty.
|
|
1222
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1223
|
+
* await collection
|
|
1224
|
+
* .append([1, 2, 3, 4, 5])
|
|
1225
|
+
* .append([-1, -2])
|
|
1226
|
+
* .toArray();
|
|
1227
|
+
* // [1, 2, 3, 4, 5, -1, -2,]
|
|
1228
|
+
* }
|
|
898
1229
|
* ```
|
|
899
1230
|
*/
|
|
900
1231
|
append<TExtended = TInput>(iterable: AsyncIterableValue<TInput | TExtended>): IAsyncCollection<TInput | TExtended>;
|
|
@@ -902,11 +1233,16 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
902
1233
|
* The <i>insertBefore</i> method adds <i>iterable</i> before the first item that matches <i>predicateFn</i>.
|
|
903
1234
|
* @example
|
|
904
1235
|
* ```ts
|
|
905
|
-
* import {
|
|
1236
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
906
1237
|
*
|
|
907
|
-
*
|
|
908
|
-
*
|
|
909
|
-
*
|
|
1238
|
+
* // Asume the inputed collection is empty.
|
|
1239
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1240
|
+
* await collection
|
|
1241
|
+
* .append([1, 2, 2, 3, 4, 5])
|
|
1242
|
+
* .insertBefore(item => item === 2, [-1, 20])
|
|
1243
|
+
* .toArray();
|
|
1244
|
+
* // [1, -1, 20, 2, 2, 3, 4, 5]
|
|
1245
|
+
* }
|
|
910
1246
|
* ```
|
|
911
1247
|
*/
|
|
912
1248
|
insertBefore<TExtended = TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>, iterable: AsyncIterableValue<TInput | TExtended>): IAsyncCollection<TInput | TExtended>;
|
|
@@ -914,11 +1250,16 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
914
1250
|
* The <i>insertAfter</i> method adds <i>iterable</i> after the first item that matches <i>predicateFn</i>.
|
|
915
1251
|
* @example
|
|
916
1252
|
* ```ts
|
|
917
|
-
* import {
|
|
1253
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
918
1254
|
*
|
|
919
|
-
*
|
|
920
|
-
*
|
|
921
|
-
*
|
|
1255
|
+
* // Asume the inputed collection is empty.
|
|
1256
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1257
|
+
* await collection
|
|
1258
|
+
* .append([1, 2, 2, 3, 4, 5])
|
|
1259
|
+
* .insertAfter(item => item === 2, [-1, 20])
|
|
1260
|
+
* .toArray();
|
|
1261
|
+
* // [1, 2, -1, 20, 2, 3, 4, 5]
|
|
1262
|
+
* }
|
|
922
1263
|
* ```
|
|
923
1264
|
*/
|
|
924
1265
|
insertAfter<TExtended = TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>, iterable: AsyncIterableValue<TInput | TExtended>): IAsyncCollection<TInput | TExtended>;
|
|
@@ -926,35 +1267,42 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
926
1267
|
* The <i>crossJoin</i> method cross joins the collection's values among <i>iterables</i>, returning a Cartesian product with all possible permutations.
|
|
927
1268
|
* @example
|
|
928
1269
|
* ```ts
|
|
929
|
-
* import {
|
|
1270
|
+
* import { ICollection } from "@daiso-tech/core";;
|
|
930
1271
|
*
|
|
931
|
-
*
|
|
932
|
-
*
|
|
933
|
-
*
|
|
934
|
-
*
|
|
935
|
-
*
|
|
936
|
-
*
|
|
937
|
-
*
|
|
938
|
-
*
|
|
939
|
-
*
|
|
1272
|
+
* async function(): Promise<void> {
|
|
1273
|
+
* await collection
|
|
1274
|
+
* .append([1, 2])
|
|
1275
|
+
* .cross(["a", "b"])
|
|
1276
|
+
* .toArray();
|
|
1277
|
+
* // [
|
|
1278
|
+
* // [1, "a"],
|
|
1279
|
+
* // [1, "b"],
|
|
1280
|
+
* // [2, "a"],
|
|
1281
|
+
* // [2, "b"],
|
|
1282
|
+
* // ]
|
|
1283
|
+
* }
|
|
940
1284
|
* ```
|
|
941
1285
|
* @example
|
|
942
1286
|
* ```ts
|
|
943
|
-
* import {
|
|
944
|
-
*
|
|
945
|
-
*
|
|
946
|
-
*
|
|
947
|
-
*
|
|
948
|
-
*
|
|
949
|
-
*
|
|
950
|
-
*
|
|
951
|
-
*
|
|
952
|
-
*
|
|
953
|
-
*
|
|
954
|
-
*
|
|
955
|
-
*
|
|
956
|
-
*
|
|
957
|
-
*
|
|
1287
|
+
* import { ICollection } from "@daiso-tech/core";;
|
|
1288
|
+
*
|
|
1289
|
+
* async function(): Promise<void> {
|
|
1290
|
+
* await collection
|
|
1291
|
+
* .append([1, 2])
|
|
1292
|
+
* .cross(["a", "b"])
|
|
1293
|
+
* .cross(["I", "II"])
|
|
1294
|
+
* .toArray();
|
|
1295
|
+
* // [
|
|
1296
|
+
* // [1, "a", "I"],
|
|
1297
|
+
* // [1, "a", "II"],
|
|
1298
|
+
* // [1, "b", "I"],
|
|
1299
|
+
* // [1, "b", "II"],
|
|
1300
|
+
* // [2, "a", "I"],
|
|
1301
|
+
* // [2, "a", "II"],
|
|
1302
|
+
* // [2, "b", "I"],
|
|
1303
|
+
* // [2, "b", "II"],
|
|
1304
|
+
* // ]
|
|
1305
|
+
* }
|
|
958
1306
|
* ```
|
|
959
1307
|
*/
|
|
960
1308
|
crossJoin<TExtended>(iterable: AsyncIterableValue<TExtended>): IAsyncCollection<CrossJoinResult<TInput, TExtended>>;
|
|
@@ -963,30 +1311,42 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
963
1311
|
* The returned collection has size of the shortest collection.
|
|
964
1312
|
* @example
|
|
965
1313
|
* ```ts
|
|
966
|
-
* import {
|
|
1314
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
967
1315
|
*
|
|
968
|
-
*
|
|
969
|
-
*
|
|
970
|
-
*
|
|
971
|
-
*
|
|
1316
|
+
* // Asume the inputed collection is empty.
|
|
1317
|
+
* async function main(collection: IAsyncCollection<string>): Promise<void> {
|
|
1318
|
+
* await collection
|
|
1319
|
+
* .append(["Chair", "Desk"])
|
|
1320
|
+
* .zip([100, 200])
|
|
1321
|
+
* .toArray();
|
|
1322
|
+
* // [["Chair", 100], ["Desk", 200]]
|
|
1323
|
+
* }
|
|
972
1324
|
* ```
|
|
973
1325
|
* @example
|
|
974
1326
|
* ```ts
|
|
975
|
-
* import {
|
|
1327
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
976
1328
|
*
|
|
977
|
-
*
|
|
978
|
-
*
|
|
979
|
-
*
|
|
980
|
-
*
|
|
1329
|
+
* // Asume the inputed collection is empty.
|
|
1330
|
+
* async function main(collection: IAsyncCollection<string>): Promise<void> {
|
|
1331
|
+
* await collection
|
|
1332
|
+
* .append(["Chair", "Desk", "Couch"])
|
|
1333
|
+
* .zip([100, 200])
|
|
1334
|
+
* .toArray();
|
|
1335
|
+
* // [["Chair", 100], ["Desk", 200]]
|
|
1336
|
+
* }
|
|
981
1337
|
* ```
|
|
982
1338
|
* @example
|
|
983
1339
|
* ```ts
|
|
984
|
-
* import {
|
|
1340
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
985
1341
|
*
|
|
986
|
-
*
|
|
987
|
-
*
|
|
988
|
-
*
|
|
989
|
-
*
|
|
1342
|
+
* // Asume the inputed collection is empty.
|
|
1343
|
+
* async function main(collection: IAsyncCollection<string>): Promise<void> {
|
|
1344
|
+
* await collection
|
|
1345
|
+
* .append(["Chair", "Desk"])
|
|
1346
|
+
* .zip([100, 200, 300])
|
|
1347
|
+
* .toArray();
|
|
1348
|
+
* // [["Chair", 100], ["Desk", 200]]
|
|
1349
|
+
* }
|
|
990
1350
|
* ```
|
|
991
1351
|
*/
|
|
992
1352
|
zip<TExtended>(iterable: AsyncIterableValue<TExtended>): IAsyncCollection<[TInput, TExtended]>;
|
|
@@ -994,29 +1354,44 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
994
1354
|
* The <i>sort</i> method sorts the collection. You can provide a <i>comparator</i> function.
|
|
995
1355
|
* @example
|
|
996
1356
|
* ```ts
|
|
997
|
-
* import {
|
|
1357
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
998
1358
|
*
|
|
999
|
-
*
|
|
1000
|
-
*
|
|
1001
|
-
*
|
|
1359
|
+
* type Person = {
|
|
1360
|
+
* name: string;
|
|
1361
|
+
* age: number;
|
|
1362
|
+
* };
|
|
1363
|
+
*
|
|
1364
|
+
* // Asume the inputed collection is empty.
|
|
1365
|
+
* async function main(collection: IAsyncCollection<Person>): Promise<void> {
|
|
1366
|
+
* await collection
|
|
1367
|
+
* .append([-1, 2, 4, 3])
|
|
1368
|
+
* .sort()
|
|
1369
|
+
* .toArray();
|
|
1370
|
+
* // [-1, 2, 3, 4]
|
|
1371
|
+
* }
|
|
1002
1372
|
* ```
|
|
1003
1373
|
* @example
|
|
1004
1374
|
* ```ts
|
|
1005
|
-
* import {
|
|
1006
|
-
*
|
|
1007
|
-
*
|
|
1008
|
-
*
|
|
1009
|
-
*
|
|
1010
|
-
*
|
|
1011
|
-
*
|
|
1012
|
-
*
|
|
1013
|
-
*
|
|
1014
|
-
*
|
|
1015
|
-
*
|
|
1016
|
-
*
|
|
1017
|
-
*
|
|
1018
|
-
*
|
|
1019
|
-
*
|
|
1375
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1376
|
+
*
|
|
1377
|
+
* // Asume the inputed collection is empty.
|
|
1378
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1379
|
+
* await collection
|
|
1380
|
+
* .append([
|
|
1381
|
+
* { name: "Anders", age: 30 },
|
|
1382
|
+
* { name: "Joe", age: 20 },
|
|
1383
|
+
* { name: "Hasan", age: 25 },
|
|
1384
|
+
* { name: "Linda", age: 19 }
|
|
1385
|
+
* ])
|
|
1386
|
+
* .sort(({ age: ageA }, { age: ageB }) => ageA - ageB)
|
|
1387
|
+
* .toArray();
|
|
1388
|
+
* // [
|
|
1389
|
+
* // { name: "Linda", age: 19 }
|
|
1390
|
+
* // { name: "Joe", age: 20 },
|
|
1391
|
+
* // { name: "Hasan", age: 25 },
|
|
1392
|
+
* // { name: "Anders", age: 30 },
|
|
1393
|
+
* // ]
|
|
1394
|
+
* }
|
|
1020
1395
|
* ```
|
|
1021
1396
|
*/
|
|
1022
1397
|
sort(comparator?: Comparator<TInput>): IAsyncCollection<TInput>;
|
|
@@ -1025,11 +1400,16 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
1025
1400
|
* The reversing of the collection will be applied in chunks that are the size of <i> chunkSize </i>.
|
|
1026
1401
|
* @example
|
|
1027
1402
|
* ```ts
|
|
1028
|
-
* import {
|
|
1403
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1029
1404
|
*
|
|
1030
|
-
*
|
|
1031
|
-
*
|
|
1032
|
-
*
|
|
1405
|
+
* // Asume the inputed collection is empty.
|
|
1406
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1407
|
+
* await collection
|
|
1408
|
+
* .append([-1, 2, 4, 3])
|
|
1409
|
+
* .reverse()
|
|
1410
|
+
* .toArray();
|
|
1411
|
+
* // [3, 4, 2, -1]
|
|
1412
|
+
* }
|
|
1033
1413
|
* ```
|
|
1034
1414
|
*/
|
|
1035
1415
|
reverse(chunkSize?: number): IAsyncCollection<TInput>;
|
|
@@ -1042,29 +1422,40 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
1042
1422
|
* By default it will get the first item. If the collection is empty or no items passes <i> predicateFn </i> than null i returned.
|
|
1043
1423
|
* @example
|
|
1044
1424
|
* ```ts
|
|
1045
|
-
* import {
|
|
1425
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1046
1426
|
*
|
|
1047
|
-
*
|
|
1048
|
-
*
|
|
1049
|
-
*
|
|
1427
|
+
* // Asume the inputed collection is empty.
|
|
1428
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1429
|
+
* await collection
|
|
1430
|
+
* .append([1, 2, 3, 4])
|
|
1431
|
+
* .first();
|
|
1432
|
+
* // 1
|
|
1433
|
+
* }
|
|
1050
1434
|
* ```
|
|
1051
1435
|
* @example
|
|
1052
1436
|
* ```ts
|
|
1053
|
-
* import {
|
|
1437
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1054
1438
|
*
|
|
1055
|
-
*
|
|
1056
|
-
*
|
|
1057
|
-
*
|
|
1439
|
+
* // Asume the inputed collection is empty.
|
|
1440
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1441
|
+
* await collection
|
|
1442
|
+
* .append([1, 2, 3, 4])
|
|
1443
|
+
* .first(item => item > 2);
|
|
1444
|
+
* // 3
|
|
1445
|
+
* }
|
|
1058
1446
|
* ```
|
|
1059
1447
|
* @example
|
|
1060
1448
|
* ```ts
|
|
1061
|
-
* import {
|
|
1449
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1062
1450
|
*
|
|
1063
|
-
*
|
|
1064
|
-
*
|
|
1065
|
-
*
|
|
1451
|
+
* // Asume the inputed collection is empty.
|
|
1452
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1453
|
+
* await collection
|
|
1454
|
+
* .append([1, 2, 3, 4])
|
|
1455
|
+
* .first(item => item > 10);
|
|
1456
|
+
* // null
|
|
1457
|
+
* }
|
|
1066
1458
|
* ```
|
|
1067
|
-
* // 3
|
|
1068
1459
|
*/
|
|
1069
1460
|
first<TOutput extends TInput>(predicateFn?: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): LazyPromise<TOutput | null>;
|
|
1070
1461
|
/**
|
|
@@ -1072,35 +1463,51 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
1072
1463
|
* By default it will get the first item. If the collection is empty or no items passes <i> predicateFn </i> than <i> defaultValue </i>.
|
|
1073
1464
|
* @example
|
|
1074
1465
|
* ```ts
|
|
1075
|
-
* import {
|
|
1466
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1076
1467
|
*
|
|
1077
|
-
*
|
|
1078
|
-
*
|
|
1079
|
-
*
|
|
1468
|
+
* // Asume the inputed collection is empty.
|
|
1469
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1470
|
+
* await collection
|
|
1471
|
+
* .append([1, 2, 3, 4])
|
|
1472
|
+
* .firstOr(-1);
|
|
1473
|
+
* // 1
|
|
1474
|
+
* }
|
|
1080
1475
|
* ```
|
|
1081
1476
|
* @example
|
|
1082
1477
|
* ```ts
|
|
1083
|
-
* import {
|
|
1478
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1084
1479
|
*
|
|
1085
|
-
*
|
|
1086
|
-
*
|
|
1087
|
-
*
|
|
1480
|
+
* // Asume the inputed collection is empty.
|
|
1481
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1482
|
+
* await collection
|
|
1483
|
+
* .append([1, 2, 3, 4])
|
|
1484
|
+
* .firstOr(-1, item => item > 2);
|
|
1485
|
+
* // 3
|
|
1486
|
+
* }
|
|
1088
1487
|
* ```
|
|
1089
1488
|
* @example
|
|
1090
1489
|
* ```ts
|
|
1091
|
-
* import {
|
|
1490
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1092
1491
|
*
|
|
1093
|
-
*
|
|
1094
|
-
*
|
|
1095
|
-
*
|
|
1492
|
+
* // Asume the inputed collection is empty.
|
|
1493
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1494
|
+
* await collection
|
|
1495
|
+
* .append([1, 2, 3, 4])
|
|
1496
|
+
* .firstOr(-1, item => item > 10);
|
|
1497
|
+
* // -1
|
|
1498
|
+
* }
|
|
1096
1499
|
* ```
|
|
1097
1500
|
* @example
|
|
1098
1501
|
* ```ts
|
|
1099
|
-
* import {
|
|
1502
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1100
1503
|
*
|
|
1101
|
-
*
|
|
1102
|
-
*
|
|
1103
|
-
*
|
|
1504
|
+
* // Asume the inputed collection is empty.
|
|
1505
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1506
|
+
* await collection
|
|
1507
|
+
* .append([1, 2, 3, 4])
|
|
1508
|
+
* .firstOr(() => -1, item => item > 10);
|
|
1509
|
+
* // -1
|
|
1510
|
+
* }
|
|
1104
1511
|
* ```
|
|
1105
1512
|
*/
|
|
1106
1513
|
firstOr<TOutput extends TInput, TExtended = TInput>(defaultValue: AsyncLazyable<TExtended>, predicateFn?: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): LazyPromise<TOutput | TExtended>;
|
|
@@ -1110,27 +1517,39 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
1110
1517
|
* @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
|
|
1111
1518
|
* @example
|
|
1112
1519
|
* ```ts
|
|
1113
|
-
* import {
|
|
1520
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1114
1521
|
*
|
|
1115
|
-
*
|
|
1116
|
-
*
|
|
1117
|
-
*
|
|
1522
|
+
* // Asume the inputed collection is empty.
|
|
1523
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1524
|
+
* await collection
|
|
1525
|
+
* .append([1, 2, 3, 4])
|
|
1526
|
+
* .firstOrFail();
|
|
1527
|
+
* // 1
|
|
1528
|
+
* }
|
|
1118
1529
|
* ```
|
|
1119
1530
|
* @example
|
|
1120
1531
|
* ```ts
|
|
1121
|
-
* import {
|
|
1532
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1122
1533
|
*
|
|
1123
|
-
*
|
|
1124
|
-
*
|
|
1125
|
-
*
|
|
1534
|
+
* // Asume the inputed collection is empty.
|
|
1535
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1536
|
+
* await collection
|
|
1537
|
+
* .append([1, 2, 3, 4])
|
|
1538
|
+
* .firstOrFail(item => item > 2);
|
|
1539
|
+
* // 3
|
|
1540
|
+
* }
|
|
1126
1541
|
* ```
|
|
1127
1542
|
* @example
|
|
1128
1543
|
* ```ts
|
|
1129
|
-
* import {
|
|
1544
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1130
1545
|
*
|
|
1131
|
-
*
|
|
1132
|
-
*
|
|
1133
|
-
*
|
|
1546
|
+
* // Asume the inputed collection is empty.
|
|
1547
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1548
|
+
* await collection
|
|
1549
|
+
* .append([1, 2, 3, 4])
|
|
1550
|
+
* .firstOrFail(item => item > 10);
|
|
1551
|
+
* // throws an error
|
|
1552
|
+
* }
|
|
1134
1553
|
* ```
|
|
1135
1554
|
*/
|
|
1136
1555
|
firstOrFail<TOutput extends TInput>(predicateFn?: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): LazyPromise<TOutput>;
|
|
@@ -1139,29 +1558,40 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
1139
1558
|
* By default it will get the last item. If the collection is empty or no items passes <i> predicateFn </i> than null i returned.
|
|
1140
1559
|
* @example
|
|
1141
1560
|
* ```ts
|
|
1142
|
-
* import {
|
|
1561
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1143
1562
|
*
|
|
1144
|
-
*
|
|
1145
|
-
*
|
|
1146
|
-
*
|
|
1563
|
+
* // Asume the inputed collection is empty.
|
|
1564
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1565
|
+
* await collection
|
|
1566
|
+
* .append([1, 2, 3, 4])
|
|
1567
|
+
* .last();
|
|
1568
|
+
* // 4
|
|
1569
|
+
* }
|
|
1147
1570
|
* ```
|
|
1148
1571
|
* @example
|
|
1149
1572
|
* ```ts
|
|
1150
|
-
* import {
|
|
1573
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1151
1574
|
*
|
|
1152
|
-
*
|
|
1153
|
-
*
|
|
1154
|
-
*
|
|
1575
|
+
* // Asume the inputed collection is empty.
|
|
1576
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1577
|
+
* await collection
|
|
1578
|
+
* .append([1, 2, 3, 4])
|
|
1579
|
+
* .last(item => item < 4);
|
|
1580
|
+
* // 3
|
|
1581
|
+
* }
|
|
1155
1582
|
* ```
|
|
1156
1583
|
* @example
|
|
1157
1584
|
* ```ts
|
|
1158
|
-
* import {
|
|
1585
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1159
1586
|
*
|
|
1160
|
-
*
|
|
1161
|
-
*
|
|
1162
|
-
*
|
|
1587
|
+
* // Asume the inputed collection is empty.
|
|
1588
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1589
|
+
* await collection
|
|
1590
|
+
* .append([1, 2, 3, 4])
|
|
1591
|
+
* .last(item => item > 10);
|
|
1592
|
+
* // null
|
|
1593
|
+
* }
|
|
1163
1594
|
* ```
|
|
1164
|
-
* // 3
|
|
1165
1595
|
*/
|
|
1166
1596
|
last<TOutput extends TInput>(predicateFn?: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): LazyPromise<TOutput | null>;
|
|
1167
1597
|
/**
|
|
@@ -1169,35 +1599,51 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
1169
1599
|
* By default it will get the last item. If the collection is empty or no items passes <i> predicateFn </i> than <i> defaultValue </i>.
|
|
1170
1600
|
* @example
|
|
1171
1601
|
* ```ts
|
|
1172
|
-
* import {
|
|
1602
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1173
1603
|
*
|
|
1174
|
-
*
|
|
1175
|
-
*
|
|
1176
|
-
*
|
|
1604
|
+
* // Asume the inputed collection is empty.
|
|
1605
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1606
|
+
* await collection
|
|
1607
|
+
* .append([1, 2, 3, 4])
|
|
1608
|
+
* .lastOr(-1);
|
|
1609
|
+
* // 4
|
|
1610
|
+
* }
|
|
1177
1611
|
* ```
|
|
1178
1612
|
* @example
|
|
1179
1613
|
* ```ts
|
|
1180
|
-
* import {
|
|
1614
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1181
1615
|
*
|
|
1182
|
-
*
|
|
1183
|
-
*
|
|
1184
|
-
*
|
|
1616
|
+
* // Asume the inputed collection is empty.
|
|
1617
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1618
|
+
* await collection
|
|
1619
|
+
* .append([1, 2, 3, 4])
|
|
1620
|
+
* .lastOr(-1, item => item < 4);
|
|
1621
|
+
* // 3
|
|
1622
|
+
* }
|
|
1185
1623
|
* ```
|
|
1186
1624
|
* @example
|
|
1187
1625
|
* ```ts
|
|
1188
|
-
* import {
|
|
1626
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1189
1627
|
*
|
|
1190
|
-
*
|
|
1191
|
-
*
|
|
1192
|
-
*
|
|
1628
|
+
* // Asume the inputed collection is empty.
|
|
1629
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1630
|
+
* await collection
|
|
1631
|
+
* .append([1, 2, 3, 4])
|
|
1632
|
+
* .lastOr(-1, item => item > 10);
|
|
1633
|
+
* // -1
|
|
1634
|
+
* }
|
|
1193
1635
|
* ```
|
|
1194
1636
|
* @example
|
|
1195
1637
|
* ```ts
|
|
1196
|
-
* import {
|
|
1638
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1197
1639
|
*
|
|
1198
|
-
*
|
|
1199
|
-
*
|
|
1200
|
-
*
|
|
1640
|
+
* // Asume the inputed collection is empty.
|
|
1641
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1642
|
+
* await collection
|
|
1643
|
+
* .append([1, 2, 3, 4])
|
|
1644
|
+
* .lastOr(() => -1, item => item > 10);
|
|
1645
|
+
* // -1
|
|
1646
|
+
* }
|
|
1201
1647
|
* ```
|
|
1202
1648
|
*/
|
|
1203
1649
|
lastOr<TOutput extends TInput, TExtended = TInput>(defaultValue: AsyncLazyable<TExtended>, predicateFn?: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): LazyPromise<TOutput | TExtended>;
|
|
@@ -1207,27 +1653,39 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
1207
1653
|
* @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
|
|
1208
1654
|
* @example
|
|
1209
1655
|
* ```ts
|
|
1210
|
-
* import {
|
|
1656
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1211
1657
|
*
|
|
1212
|
-
*
|
|
1213
|
-
*
|
|
1214
|
-
*
|
|
1658
|
+
* // Asume the inputed collection is empty.
|
|
1659
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1660
|
+
* await collection
|
|
1661
|
+
* .append([1, 2, 3, 4])
|
|
1662
|
+
* .lastOrFail();
|
|
1663
|
+
* // 4
|
|
1664
|
+
* }
|
|
1215
1665
|
* ```
|
|
1216
1666
|
* @example
|
|
1217
1667
|
* ```ts
|
|
1218
|
-
* import {
|
|
1668
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1219
1669
|
*
|
|
1220
|
-
*
|
|
1221
|
-
*
|
|
1222
|
-
*
|
|
1670
|
+
* // Asume the inputed collection is empty.
|
|
1671
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1672
|
+
* await collection
|
|
1673
|
+
* .append([1, 2, 3, 4])
|
|
1674
|
+
* .lastOrFail(item => item < 4);
|
|
1675
|
+
* // 3
|
|
1676
|
+
* }
|
|
1223
1677
|
* ```
|
|
1224
1678
|
* @example
|
|
1225
1679
|
* ```ts
|
|
1226
|
-
* import {
|
|
1680
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1227
1681
|
*
|
|
1228
|
-
*
|
|
1229
|
-
*
|
|
1230
|
-
*
|
|
1682
|
+
* // Asume the inputed collection is empty.
|
|
1683
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1684
|
+
* await collection
|
|
1685
|
+
* .append([1, 2, 3, 4])
|
|
1686
|
+
* .lastOrFail(item => item > 10);
|
|
1687
|
+
* // throws an error
|
|
1688
|
+
* }
|
|
1231
1689
|
* ```
|
|
1232
1690
|
*/
|
|
1233
1691
|
lastOrFail<TOutput extends TInput>(predicateFn?: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): LazyPromise<TOutput>;
|
|
@@ -1236,19 +1694,27 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
1236
1694
|
* If the <i>predicateFn</i> does not match or matches the first item then null is returned.
|
|
1237
1695
|
* @example
|
|
1238
1696
|
* ```ts
|
|
1239
|
-
* import {
|
|
1697
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1240
1698
|
*
|
|
1241
|
-
*
|
|
1242
|
-
*
|
|
1243
|
-
*
|
|
1699
|
+
* // Asume the inputed collection is empty.
|
|
1700
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1701
|
+
* await collection
|
|
1702
|
+
* .append([1, 2, 3, 4])
|
|
1703
|
+
* .before(item => item === 2);
|
|
1704
|
+
* // 1
|
|
1705
|
+
* }
|
|
1244
1706
|
* ```
|
|
1245
1707
|
* @example
|
|
1246
1708
|
* ```ts
|
|
1247
|
-
* import {
|
|
1709
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1248
1710
|
*
|
|
1249
|
-
*
|
|
1250
|
-
*
|
|
1251
|
-
*
|
|
1711
|
+
* // Asume the inputed collection is empty.
|
|
1712
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1713
|
+
* await collection
|
|
1714
|
+
* .append([1, 2, 3, 4])
|
|
1715
|
+
* .before(item => item === 1);
|
|
1716
|
+
* // null
|
|
1717
|
+
* }
|
|
1252
1718
|
* ```
|
|
1253
1719
|
*/
|
|
1254
1720
|
before(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): LazyPromise<TInput | null>;
|
|
@@ -1257,27 +1723,39 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
1257
1723
|
* If the collection is empty or the <i>predicateFn</i> does not match or matches the first item then <i>defaultValue</i> is returned.
|
|
1258
1724
|
* @example
|
|
1259
1725
|
* ```ts
|
|
1260
|
-
* import {
|
|
1726
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1261
1727
|
*
|
|
1262
|
-
*
|
|
1263
|
-
*
|
|
1264
|
-
*
|
|
1728
|
+
* // Asume the inputed collection is empty.
|
|
1729
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1730
|
+
* await collection
|
|
1731
|
+
* .append([1, 2, 3, 4])
|
|
1732
|
+
* .beforeOr(-1, item => item === 2);
|
|
1733
|
+
* // 1
|
|
1734
|
+
* }
|
|
1265
1735
|
* ```
|
|
1266
1736
|
* @example
|
|
1267
1737
|
* ```ts
|
|
1268
|
-
* import {
|
|
1738
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1269
1739
|
*
|
|
1270
|
-
*
|
|
1271
|
-
*
|
|
1272
|
-
*
|
|
1740
|
+
* // Asume the inputed collection is empty.
|
|
1741
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1742
|
+
* await collection
|
|
1743
|
+
* .append([1, 2, 3, 4])
|
|
1744
|
+
* .beforeOr(-1, item => item === 1);
|
|
1745
|
+
* // -1
|
|
1746
|
+
* }
|
|
1273
1747
|
* ```
|
|
1274
1748
|
* @example
|
|
1275
1749
|
* ```ts
|
|
1276
|
-
* import {
|
|
1750
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1277
1751
|
*
|
|
1278
|
-
*
|
|
1279
|
-
*
|
|
1280
|
-
*
|
|
1752
|
+
* // Asume the inputed collection is empty.
|
|
1753
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1754
|
+
* await collection
|
|
1755
|
+
* .append([1, 2, 3, 4])
|
|
1756
|
+
* .beforeOr(() => -1, item => item === 1);
|
|
1757
|
+
* // -1
|
|
1758
|
+
* }
|
|
1281
1759
|
* ```
|
|
1282
1760
|
*/
|
|
1283
1761
|
beforeOr<TExtended = TInput>(defaultValue: AsyncLazyable<TExtended>, predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): LazyPromise<TInput | TExtended>;
|
|
@@ -1287,19 +1765,27 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
1287
1765
|
* @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
|
|
1288
1766
|
* @example
|
|
1289
1767
|
* ```ts
|
|
1290
|
-
* import {
|
|
1768
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1291
1769
|
*
|
|
1292
|
-
*
|
|
1293
|
-
*
|
|
1294
|
-
*
|
|
1770
|
+
* // Asume the inputed collection is empty.
|
|
1771
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1772
|
+
* await collection
|
|
1773
|
+
* .append([1, 2, 3, 4])
|
|
1774
|
+
* .beforeOrFail(item => item === 2);
|
|
1775
|
+
* // 1
|
|
1776
|
+
* }
|
|
1295
1777
|
* ```
|
|
1296
1778
|
* @example
|
|
1297
1779
|
* ```ts
|
|
1298
|
-
* import {
|
|
1780
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1299
1781
|
*
|
|
1300
|
-
*
|
|
1301
|
-
*
|
|
1302
|
-
*
|
|
1782
|
+
* // Asume the inputed collection is empty.
|
|
1783
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1784
|
+
* await collection
|
|
1785
|
+
* .append([1, 2, 3, 4])
|
|
1786
|
+
* .beforeOrFail(item => item === 1);
|
|
1787
|
+
* // error is thrown
|
|
1788
|
+
* }
|
|
1303
1789
|
* ```
|
|
1304
1790
|
*/
|
|
1305
1791
|
beforeOrFail(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): LazyPromise<TInput>;
|
|
@@ -1308,19 +1794,27 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
1308
1794
|
* If the collection is empty or the <i>predicateFn</i> does not match or matches the last item then null is returned.
|
|
1309
1795
|
* @example
|
|
1310
1796
|
* ```ts
|
|
1311
|
-
* import {
|
|
1797
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1312
1798
|
*
|
|
1313
|
-
*
|
|
1314
|
-
*
|
|
1315
|
-
*
|
|
1799
|
+
* // Asume the inputed collection is empty.
|
|
1800
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1801
|
+
* await collection
|
|
1802
|
+
* .append([1, 2, 3, 4])
|
|
1803
|
+
* .after(item => item === 2);
|
|
1804
|
+
* // 3
|
|
1805
|
+
* }
|
|
1316
1806
|
* ```
|
|
1317
1807
|
* @example
|
|
1318
1808
|
* ```ts
|
|
1319
|
-
* import {
|
|
1809
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1320
1810
|
*
|
|
1321
|
-
*
|
|
1322
|
-
*
|
|
1323
|
-
*
|
|
1811
|
+
* // Asume the inputed collection is empty.
|
|
1812
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1813
|
+
* await collection
|
|
1814
|
+
* .append([1, 2, 3, 4])
|
|
1815
|
+
* .after(item => item === 4);
|
|
1816
|
+
* // null
|
|
1817
|
+
* }
|
|
1324
1818
|
* ```
|
|
1325
1819
|
*/
|
|
1326
1820
|
after(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): LazyPromise<TInput | null>;
|
|
@@ -1329,27 +1823,39 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
1329
1823
|
* If the collection is empty or the <i>predicateFn</i> does not match or matches the last item then <i>defaultValue</i> is returned.
|
|
1330
1824
|
* @example
|
|
1331
1825
|
* ```ts
|
|
1332
|
-
* import {
|
|
1826
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1333
1827
|
*
|
|
1334
|
-
*
|
|
1335
|
-
*
|
|
1336
|
-
*
|
|
1828
|
+
* // Asume the inputed collection is empty.
|
|
1829
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1830
|
+
* await collection
|
|
1831
|
+
* .append([1, 2, 3, 4])
|
|
1832
|
+
* .afterOr(-1, item => item === 2);
|
|
1833
|
+
* // 3
|
|
1834
|
+
* }
|
|
1337
1835
|
* ```
|
|
1338
1836
|
* @example
|
|
1339
1837
|
* ```ts
|
|
1340
|
-
* import {
|
|
1838
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1341
1839
|
*
|
|
1342
|
-
*
|
|
1343
|
-
*
|
|
1344
|
-
*
|
|
1840
|
+
* // Asume the inputed collection is empty.
|
|
1841
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1842
|
+
* await collection
|
|
1843
|
+
* .append([1, 2, 3, 4])
|
|
1844
|
+
* .afterOr(-1, item => item === 4);
|
|
1845
|
+
* // -1
|
|
1846
|
+
* }
|
|
1345
1847
|
* ```
|
|
1346
1848
|
* @example
|
|
1347
1849
|
* ```ts
|
|
1348
|
-
* import {
|
|
1850
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1349
1851
|
*
|
|
1350
|
-
*
|
|
1351
|
-
*
|
|
1352
|
-
*
|
|
1852
|
+
* // Asume the inputed collection is empty.
|
|
1853
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1854
|
+
* await collection
|
|
1855
|
+
* .append([1, 2, 3, 4])
|
|
1856
|
+
* .afterOr(() => -1, item => item === 4);
|
|
1857
|
+
* // -1
|
|
1858
|
+
* }
|
|
1353
1859
|
* ```
|
|
1354
1860
|
*/
|
|
1355
1861
|
afterOr<TExtended = TInput>(defaultValue: AsyncLazyable<TExtended>, predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): LazyPromise<TInput | TExtended>;
|
|
@@ -1359,19 +1865,27 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
1359
1865
|
* @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
|
|
1360
1866
|
* @example
|
|
1361
1867
|
* ```ts
|
|
1362
|
-
* import {
|
|
1868
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1363
1869
|
*
|
|
1364
|
-
*
|
|
1365
|
-
*
|
|
1366
|
-
*
|
|
1870
|
+
* // Asume the inputed collection is empty.
|
|
1871
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1872
|
+
* await collection
|
|
1873
|
+
* .append([1, 2, 3, 4])
|
|
1874
|
+
* .afterOrFail(item => item === 2);
|
|
1875
|
+
* // 3
|
|
1876
|
+
* }
|
|
1367
1877
|
* ```
|
|
1368
1878
|
* @example
|
|
1369
1879
|
* ```ts
|
|
1370
|
-
* import {
|
|
1880
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1371
1881
|
*
|
|
1372
|
-
*
|
|
1373
|
-
*
|
|
1374
|
-
*
|
|
1882
|
+
* // Asume the inputed collection is empty.
|
|
1883
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1884
|
+
* await collection
|
|
1885
|
+
* .append([1, 2, 3, 4])
|
|
1886
|
+
* .afterOrFail(item => item === 4);
|
|
1887
|
+
* // error is thrown
|
|
1888
|
+
* }
|
|
1375
1889
|
* ```
|
|
1376
1890
|
*/
|
|
1377
1891
|
afterOrFail(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): LazyPromise<TInput>;
|
|
@@ -1382,27 +1896,39 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
1382
1896
|
* @throws {MultipleItemsFoundCollectionError} {@link MultipleItemsFoundCollectionError}
|
|
1383
1897
|
* @example
|
|
1384
1898
|
* ```ts
|
|
1385
|
-
* import {
|
|
1899
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1386
1900
|
*
|
|
1387
|
-
*
|
|
1388
|
-
*
|
|
1389
|
-
*
|
|
1901
|
+
* // Asume the inputed collection is empty.
|
|
1902
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1903
|
+
* await collection
|
|
1904
|
+
* .append([1, 2, 3, 4, 5])
|
|
1905
|
+
* .sole(item => item === 4);
|
|
1906
|
+
* // 4
|
|
1907
|
+
* }
|
|
1390
1908
|
* ```
|
|
1391
1909
|
* @example
|
|
1392
1910
|
* ```ts
|
|
1393
|
-
* import {
|
|
1911
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1394
1912
|
*
|
|
1395
|
-
*
|
|
1396
|
-
*
|
|
1397
|
-
*
|
|
1913
|
+
* // Asume the inputed collection is empty.
|
|
1914
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1915
|
+
* await collection
|
|
1916
|
+
* .append([1, 2, 3, 4, 4, 5])
|
|
1917
|
+
* .sole(item => item === 4);
|
|
1918
|
+
* // error is thrown
|
|
1919
|
+
* }
|
|
1398
1920
|
* ```
|
|
1399
1921
|
* @example
|
|
1400
1922
|
* ```ts
|
|
1401
|
-
* import {
|
|
1923
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1402
1924
|
*
|
|
1403
|
-
*
|
|
1404
|
-
*
|
|
1405
|
-
*
|
|
1925
|
+
* // Asume the inputed collection is empty.
|
|
1926
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1927
|
+
* await collection
|
|
1928
|
+
* .append([1, 2, 3, 5])
|
|
1929
|
+
* .sole(item => item === 4);
|
|
1930
|
+
* // error is thrown
|
|
1931
|
+
* }
|
|
1406
1932
|
* ```
|
|
1407
1933
|
*/
|
|
1408
1934
|
sole<TOutput extends TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): LazyPromise<TOutput>;
|
|
@@ -1410,11 +1936,15 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
1410
1936
|
* The <i>nth</i> method creates a new collection consisting of every n-th item.
|
|
1411
1937
|
* @example
|
|
1412
1938
|
* ```ts
|
|
1413
|
-
* import {
|
|
1939
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1414
1940
|
*
|
|
1415
|
-
*
|
|
1416
|
-
*
|
|
1417
|
-
*
|
|
1941
|
+
* // Asume the inputed collection is empty.
|
|
1942
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1943
|
+
* await collection.append(["a", "b", "c", "d", "e", "f"])
|
|
1944
|
+
* .nth(4)
|
|
1945
|
+
* .toArray();
|
|
1946
|
+
* // ["a", "e"]
|
|
1947
|
+
* }
|
|
1418
1948
|
* ```
|
|
1419
1949
|
*/
|
|
1420
1950
|
nth(step: number): IAsyncCollection<TInput>;
|
|
@@ -1422,11 +1952,15 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
1422
1952
|
* The <i>count</i> method returns the total number of items in the collection that passes <i>predicateFn</i>.
|
|
1423
1953
|
* @example
|
|
1424
1954
|
* ```ts
|
|
1425
|
-
* import {
|
|
1955
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1426
1956
|
*
|
|
1427
|
-
*
|
|
1428
|
-
*
|
|
1429
|
-
*
|
|
1957
|
+
* // Asume the inputed collection is empty.
|
|
1958
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
1959
|
+
* await collection
|
|
1960
|
+
* .append([1, 2, 3, 4, 5, 6])
|
|
1961
|
+
* .count(value => value % 2 === 0);
|
|
1962
|
+
* // 3
|
|
1963
|
+
* }
|
|
1430
1964
|
* ```
|
|
1431
1965
|
*/
|
|
1432
1966
|
count(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): LazyPromise<number>;
|
|
@@ -1446,11 +1980,15 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
1446
1980
|
* The <i>searchFirst</i> return the index of the first item that matches <i>predicateFn</i>.
|
|
1447
1981
|
* @example
|
|
1448
1982
|
* ```ts
|
|
1449
|
-
* import {
|
|
1983
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1450
1984
|
*
|
|
1451
|
-
*
|
|
1452
|
-
*
|
|
1453
|
-
*
|
|
1985
|
+
* // Asume the inputed collection is empty.
|
|
1986
|
+
* async function main(collection: IAsyncCollection<string>): Promise<void> {
|
|
1987
|
+
* await collection
|
|
1988
|
+
* .append(["a", "b", "b", "c"])
|
|
1989
|
+
* .searchFirst(item => item === "b");
|
|
1990
|
+
* // 1
|
|
1991
|
+
* }
|
|
1454
1992
|
* ```
|
|
1455
1993
|
*/
|
|
1456
1994
|
searchFirst(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): LazyPromise<number>;
|
|
@@ -1458,11 +1996,15 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
1458
1996
|
* The <i>searchLast</i> return the index of the last item that matches <i>predicateFn</i>.
|
|
1459
1997
|
* @example
|
|
1460
1998
|
* ```ts
|
|
1461
|
-
* import {
|
|
1999
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1462
2000
|
*
|
|
1463
|
-
*
|
|
1464
|
-
*
|
|
1465
|
-
*
|
|
2001
|
+
* // Asume the inputed collection is empty.
|
|
2002
|
+
* async function main(collection: IAsyncCollection<string>): Promise<void> {
|
|
2003
|
+
* await collection
|
|
2004
|
+
* .append(["a", "b", "b", "c"])
|
|
2005
|
+
* .searchLast(item => item === "b");
|
|
2006
|
+
* // 2
|
|
2007
|
+
* }
|
|
1466
2008
|
* ```
|
|
1467
2009
|
*/
|
|
1468
2010
|
searchLast(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): LazyPromise<number>;
|
|
@@ -1475,13 +2017,25 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
1475
2017
|
* This method is especially useful for situations where you may be interacting with external APIs that rate limit incoming requests:
|
|
1476
2018
|
* @example
|
|
1477
2019
|
* ```ts
|
|
1478
|
-
* import {
|
|
2020
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
1479
2021
|
*
|
|
1480
|
-
* //
|
|
1481
|
-
* class
|
|
1482
|
-
*
|
|
1483
|
-
*
|
|
1484
|
-
*
|
|
2022
|
+
* // Asume the inputed collection is empty.
|
|
2023
|
+
* class MyIterable implements Iterable<number> {
|
|
2024
|
+
* async *[Symbol.asyncIterator]() {
|
|
2025
|
+
* for (let i = 0; i < 10; i++) {
|
|
2026
|
+
* yield i;
|
|
2027
|
+
* }
|
|
2028
|
+
* }
|
|
2029
|
+
* }
|
|
2030
|
+
*
|
|
2031
|
+
* // Asume the inputed collection is empty.
|
|
2032
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
2033
|
+
* const myIterable = new MyIterable();
|
|
2034
|
+
* await collection
|
|
2035
|
+
* .append(myIterable)
|
|
2036
|
+
* .delay(1000)
|
|
2037
|
+
* .forEach(user => console.log(user))
|
|
2038
|
+
* }
|
|
1485
2039
|
* ```
|
|
1486
2040
|
*/
|
|
1487
2041
|
delay(time: TimeSpan): IAsyncCollection<TInput>;
|
|
@@ -1491,13 +2045,30 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
1491
2045
|
* After when aborted, the collection will stop iterating:
|
|
1492
2046
|
* @example
|
|
1493
2047
|
* ```ts
|
|
1494
|
-
* import {
|
|
2048
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
2049
|
+
*
|
|
2050
|
+
* class InfiniteIterable implements Iterable<number> {
|
|
2051
|
+
* async *[Symbol.asyncIterator]() {
|
|
2052
|
+
* let index = 0;
|
|
2053
|
+
* while(true) {
|
|
2054
|
+
* index++;
|
|
2055
|
+
* yield index;
|
|
2056
|
+
* }
|
|
2057
|
+
* }
|
|
2058
|
+
* }
|
|
1495
2059
|
*
|
|
1496
|
-
* //
|
|
1497
|
-
*
|
|
1498
|
-
*
|
|
1499
|
-
*
|
|
1500
|
-
*
|
|
2060
|
+
* // Asume the inputed collection is empty.
|
|
2061
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
2062
|
+
* const abortController = new AbortController();
|
|
2063
|
+
* setTimeout(() => {
|
|
2064
|
+
* abortController.abort("My abort error");
|
|
2065
|
+
* }, 1000)
|
|
2066
|
+
* const infiniteIterable = new InfiniteIterable();
|
|
2067
|
+
* await collection
|
|
2068
|
+
* .append(infiniteIterable);
|
|
2069
|
+
* .takeUntilAbort(abortController)
|
|
2070
|
+
* .forEach(nbr => console.log(nbr))
|
|
2071
|
+
* }
|
|
1501
2072
|
* ```
|
|
1502
2073
|
*/
|
|
1503
2074
|
takeUntilAbort(abortSignal: AbortSignal, shouldThrow?: boolean): IAsyncCollection<TInput>;
|
|
@@ -1507,20 +2078,26 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
1507
2078
|
* After that time, the collection will stop iterating:
|
|
1508
2079
|
* @example
|
|
1509
2080
|
* ```ts
|
|
1510
|
-
* import {
|
|
2081
|
+
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
2082
|
+
*
|
|
2083
|
+
* class InfiniteIterable implements AsyncIterable<number> {
|
|
2084
|
+
* async *[Symbol.asyncIterator]() {
|
|
2085
|
+
* let index = 0;
|
|
2086
|
+
* while(true) {
|
|
2087
|
+
* index++;
|
|
2088
|
+
* yield index;
|
|
2089
|
+
* }
|
|
2090
|
+
* }
|
|
2091
|
+
* }
|
|
1511
2092
|
*
|
|
1512
|
-
*
|
|
1513
|
-
*
|
|
1514
|
-
*
|
|
1515
|
-
*
|
|
1516
|
-
*
|
|
1517
|
-
*
|
|
2093
|
+
* // Asume the inputed collection is empty.
|
|
2094
|
+
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
2095
|
+
* const infiniteIterable = new InfiniteIterable();
|
|
2096
|
+
* await collection
|
|
2097
|
+
* .append(infiniteIterable)
|
|
2098
|
+
* .takeUntilTimeout(1000)
|
|
2099
|
+
* .forEach(nbr => console.log(nbr))
|
|
1518
2100
|
* }
|
|
1519
|
-
* const asyncInfiniteIterable = new AsyncInfiniteIterable();
|
|
1520
|
-
* const collection = new AsyncIterableCollection(asyncInfiniteIterable);
|
|
1521
|
-
* await collection
|
|
1522
|
-
* .timeout(1000)
|
|
1523
|
-
* .forEach(nbr => console.log(nbr))
|
|
1524
2101
|
* ```
|
|
1525
2102
|
*/
|
|
1526
2103
|
takeUntilTimeout(time: TimeSpan, shouldThrow?: boolean): IAsyncCollection<TInput>;
|
|
@@ -1530,10 +2107,14 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
1530
2107
|
toArray(): LazyPromise<TInput[]>;
|
|
1531
2108
|
/**
|
|
1532
2109
|
* The <i>toRecord</i> method converts the collection to a new <i>{@link Record}</i>.
|
|
2110
|
+
* An error will be thrown if item is not a tuple of size 2 where the first element is a string or a number.
|
|
2111
|
+
* @throws {TypeCollectionError} {@link TypeCollectionError}
|
|
1533
2112
|
*/
|
|
1534
2113
|
toRecord(): LazyPromise<EnsureRecord<TInput>>;
|
|
1535
2114
|
/**
|
|
1536
2115
|
* The <i>toMap</i> method converts the collection to a new <i>{@link Map}</i>.
|
|
2116
|
+
* An error will be thrown if item is not a tuple of size 2.
|
|
2117
|
+
* @throws {TypeCollectionError} {@link TypeCollectionError}
|
|
1537
2118
|
*/
|
|
1538
2119
|
toMap(): LazyPromise<EnsureMap<TInput>>;
|
|
1539
2120
|
};
|