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