@sparted/shared-library 1.9.5 → 1.9.6
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/package.json +3 -6
- package/.circleci/config.yml +0 -40
- package/.eslintignore +0 -1
- package/.eslintrc.json +0 -25
- package/.gitignore +0 -37
- package/.prettierrc.json +0 -6
- package/CHANGELOG.md +0 -457
- package/README.md +0 -26
- package/dist/package.json +0 -25
- package/global.d.ts +0 -2
- package/rollup.config.ts +0 -19
- package/sparted-shared-library-v1.7.93.tgz +0 -0
- package/src/array/__tests__/array-to-map.test.ts +0 -50
- package/src/array/__tests__/get-values-from-keys.test.ts +0 -14
- package/src/array/__tests__/inner-join.test.ts +0 -55
- package/src/array/__tests__/left-outter-join.test.ts +0 -55
- package/src/array/array-to-map.ts +0 -32
- package/src/array/get-values-from-keys.ts +0 -3
- package/src/array/index.ts +0 -4
- package/src/array/inner-join.ts +0 -10
- package/src/array/left-outter-join.ts +0 -10
- package/src/business/campaign/__tests__/compute-current-session.test.ts +0 -189
- package/src/business/campaign/__tests__/compute-intense-calendar.test.ts +0 -134
- package/src/business/campaign/__tests__/find-next-available-date.test.ts +0 -82
- package/src/business/campaign/__tests__/get-calendar-dession-dates-from-campaign.test.ts +0 -123
- package/src/business/campaign/index.ts +0 -1
- package/src/business/campaign/live-campaign.ts +0 -133
- package/src/business/course/index.ts +0 -1
- package/src/business/course/microknowledge-max-lengths.ts +0 -12
- package/src/business/index.ts +0 -4
- package/src/business/picture-spot/index.ts +0 -3
- package/src/business/types/achievement.ts +0 -41
- package/src/business/types/activity.ts +0 -64
- package/src/business/types/audience.ts +0 -23
- package/src/business/types/battle.ts +0 -17
- package/src/business/types/breaking-news.ts +0 -43
- package/src/business/types/campaign.ts +0 -163
- package/src/business/types/content.ts +0 -261
- package/src/business/types/document.ts +0 -17
- package/src/business/types/index.ts +0 -14
- package/src/business/types/media.ts +0 -18
- package/src/business/types/multilingual.ts +0 -47
- package/src/business/types/player.ts +0 -28
- package/src/business/types/score.ts +0 -61
- package/src/business/types/thematic.ts +0 -12
- package/src/business/types/user-engagement.ts +0 -11
- package/src/cdn/__tests__/cdn.factory.test.ts +0 -150
- package/src/cdn/__tests__/utils.test.ts +0 -528
- package/src/cdn/cdn.factory.ts +0 -70
- package/src/cdn/index.ts +0 -2
- package/src/cdn/types/cdn-factory.type.ts +0 -49
- package/src/cdn/types/index.ts +0 -1
- package/src/cdn/utils/extract-info-from-url.util.ts +0 -25
- package/src/cdn/utils/get-cdn-from-s3-url.util.ts +0 -20
- package/src/cdn/utils/get-cdn-url.util.ts +0 -31
- package/src/cdn/utils/twicpics-transformations.util.ts +0 -9
- package/src/chrono/get-approximated-session-time.ts +0 -27
- package/src/chrono/index.ts +0 -1
- package/src/color/__tests__/get-contrast-color.test.ts +0 -22
- package/src/color/get-contrast-color.ts +0 -18
- package/src/color/index.ts +0 -1
- package/src/crypto/__tests__/aes256.test.ts +0 -23
- package/src/crypto/aes256.ts +0 -22
- package/src/crypto/index.ts +0 -1
- package/src/date/__tests__/get-iso-day-number.test.ts +0 -34
- package/src/date/__tests__/get-remaining-time.test.ts +0 -78
- package/src/date/__tests__/get-start-of-day.test.ts +0 -92
- package/src/date/__tests__/is-same-date.test.ts +0 -50
- package/src/date/__tests__/shift-date-by.test.ts +0 -76
- package/src/date/__tests__/to-utc-date-string.test.ts +0 -28
- package/src/date/add-days.ts +0 -5
- package/src/date/difference-in-days.ts +0 -6
- package/src/date/get-iso-day-number.ts +0 -1
- package/src/date/get-next-day.ts +0 -6
- package/src/date/get-remaining-time.ts +0 -24
- package/src/date/get-start-of-day.ts +0 -11
- package/src/date/index.ts +0 -10
- package/src/date/is-same-date.ts +0 -7
- package/src/date/shift-date-by.ts +0 -17
- package/src/date/to-plain-date-string.ts +0 -1
- package/src/date/to-utc-date-string.ts +0 -3
- package/src/formatting/__tests__/format-number.test.ts +0 -11
- package/src/formatting/format-number.ts +0 -14
- package/src/formatting/index.ts +0 -1
- package/src/fp/__tests__/run-while.test.ts +0 -29
- package/src/fp/index.ts +0 -1
- package/src/fp/run-while.ts +0 -54
- package/src/http/__tests__/build-search-params.test.ts +0 -17
- package/src/http/__tests__/encode-search-object.test.ts +0 -34
- package/src/http/__tests__/fetch-with-timeout.test.ts +0 -50
- package/src/http/build-search-params.ts +0 -16
- package/src/http/encode-search-object.ts +0 -42
- package/src/http/fetch-with-timeout.ts +0 -27
- package/src/http/index.ts +0 -3
- package/src/index.ts +0 -19
- package/src/linked-list/__tests__/apply-diff-linked-list.test.ts +0 -103
- package/src/linked-list/__tests__/create-linked-list.test.ts +0 -204
- package/src/linked-list/__tests__/find-linked-list.test.ts +0 -40
- package/src/linked-list/__tests__/get-linked-list.test.ts +0 -28
- package/src/linked-list/__tests__/insert-linked-list.test.ts +0 -186
- package/src/linked-list/__tests__/linked-list-utils.test.ts +0 -252
- package/src/linked-list/__tests__/reduce-linked-list.test.ts +0 -31
- package/src/linked-list/__tests__/remove-linked-list.test.ts +0 -129
- package/src/linked-list/__tests__/update-linked-list.test.ts +0 -53
- package/src/linked-list/__tests__/while-linked-list.test.ts +0 -58
- package/src/linked-list/apply-diff-linked-list.ts +0 -35
- package/src/linked-list/create-linked-list.ts +0 -79
- package/src/linked-list/find-linked-list.ts +0 -26
- package/src/linked-list/get-linked-list.ts +0 -9
- package/src/linked-list/index.ts +0 -2
- package/src/linked-list/insert-linked-list.ts +0 -50
- package/src/linked-list/linked-list-utils.ts +0 -143
- package/src/linked-list/reduce-linked-list.ts +0 -18
- package/src/linked-list/remove-linked-list.ts +0 -36
- package/src/linked-list/type.ts +0 -38
- package/src/linked-list/update-linked-list.ts +0 -30
- package/src/linked-list/while-linked-list.ts +0 -33
- package/src/math/__tests__/clamp-number.test.ts +0 -30
- package/src/math/__tests__/interpolate.test.ts +0 -28
- package/src/math/__tests__/median.test.ts +0 -27
- package/src/math/__tests__/number-range.test.ts +0 -59
- package/src/math/__tests__/random-number.test.ts +0 -11
- package/src/math/clamp-number.ts +0 -8
- package/src/math/index.ts +0 -5
- package/src/math/interpolate.ts +0 -18
- package/src/math/median.ts +0 -21
- package/src/math/number-range.ts +0 -16
- package/src/math/random-number.ts +0 -10
- package/src/object/__tests__/merge-deep.test.ts +0 -56
- package/src/object/__tests__/strip-properties-from-object.test.ts +0 -65
- package/src/object/index.ts +0 -2
- package/src/object/merge-deep.ts +0 -26
- package/src/object/strip-properties-from-object.ts +0 -26
- package/src/parsing/__tests__/parse-boolean.test.ts +0 -15
- package/src/parsing/__tests__/parse-enum.test.ts +0 -19
- package/src/parsing/__tests__/parse-number.test.ts +0 -20
- package/src/parsing/index.ts +0 -3
- package/src/parsing/parse-boolean.ts +0 -10
- package/src/parsing/parse-enum.ts +0 -16
- package/src/parsing/parse-number.ts +0 -12
- package/src/predicates/__tests__/is-function.test.ts +0 -11
- package/src/predicates/__tests__/is-null.test.ts +0 -11
- package/src/predicates/__tests__/is-object.test.ts +0 -11
- package/src/predicates/__tests__/is-primitive.test.ts +0 -42
- package/src/predicates/__tests__/is-undefined.test.ts +0 -11
- package/src/predicates/__tests__/is-uuid.test.ts +0 -13
- package/src/predicates/index.ts +0 -5
- package/src/predicates/is-function.ts +0 -3
- package/src/predicates/is-null.ts +0 -1
- package/src/predicates/is-object.ts +0 -3
- package/src/predicates/is-primitive.ts +0 -19
- package/src/predicates/is-undefined.ts +0 -3
- package/src/predicates/is-uuid.ts +0 -3
- package/src/promise/__tests__/delay.test.ts +0 -13
- package/src/promise/__tests__/execute-or-resolve-default.test.ts +0 -25
- package/src/promise/__tests__/execute-with-delay.test.ts +0 -24
- package/src/promise/delay.ts +0 -3
- package/src/promise/execute-or-resolve-default.ts +0 -14
- package/src/promise/execute-with-delay.ts +0 -6
- package/src/promise/index.ts +0 -3
- package/src/string/__tests__/is-string-length-within-range.test.ts +0 -23
- package/src/string/__tests__/replace-in-template.test.ts +0 -52
- package/src/string/index.ts +0 -2
- package/src/string/is-string-length-within-range.ts +0 -10
- package/src/string/replace-in-template.ts +0 -45
- package/src/time/__tests__/convert.test.ts +0 -14
- package/src/time/__tests__/format-minutes.test.ts +0 -10
- package/src/time/__tests__/get-time-diff-as-string.test.ts +0 -128
- package/src/time/constants.ts +0 -4
- package/src/time/convert.ts +0 -5
- package/src/time/format-minutes.ts +0 -9
- package/src/time/get-time-diff-as-string.ts +0 -196
- package/src/time/index.ts +0 -4
- package/src/types/function.ts +0 -1
- package/src/types/general.ts +0 -15
- package/src/types/index.ts +0 -4
- package/src/types/object.ts +0 -33
- package/src/types/search.ts +0 -36
- package/tmp-lib.tgz +0 -0
- package/tsconfig.json +0 -25
- package/yarn.lock +0 -4280
- /package/{dist/_virtual → _virtual}/_tslib.js +0 -0
- /package/{dist/_virtual → _virtual}/_tslib.js.map +0 -0
- /package/{dist/array → array}/array-to-map.d.ts +0 -0
- /package/{dist/array → array}/array-to-map.js +0 -0
- /package/{dist/array → array}/array-to-map.js.map +0 -0
- /package/{dist/array → array}/get-values-from-keys.d.ts +0 -0
- /package/{dist/array → array}/get-values-from-keys.js +0 -0
- /package/{dist/array → array}/get-values-from-keys.js.map +0 -0
- /package/{dist/array → array}/index.d.ts +0 -0
- /package/{dist/array → array}/index.js +0 -0
- /package/{dist/array → array}/index.js.map +0 -0
- /package/{dist/array → array}/inner-join.d.ts +0 -0
- /package/{dist/array → array}/inner-join.js +0 -0
- /package/{dist/array → array}/inner-join.js.map +0 -0
- /package/{dist/array → array}/left-outter-join.d.ts +0 -0
- /package/{dist/array → array}/left-outter-join.js +0 -0
- /package/{dist/array → array}/left-outter-join.js.map +0 -0
- /package/{dist/business → business}/campaign/index.d.ts +0 -0
- /package/{dist/business → business}/campaign/index.js +0 -0
- /package/{dist/business → business}/campaign/index.js.map +0 -0
- /package/{dist/business → business}/campaign/live-campaign.d.ts +0 -0
- /package/{dist/business → business}/campaign/live-campaign.js +0 -0
- /package/{dist/business → business}/campaign/live-campaign.js.map +0 -0
- /package/{dist/business → business}/course/index.d.ts +0 -0
- /package/{dist/business → business}/course/index.js +0 -0
- /package/{dist/business → business}/course/index.js.map +0 -0
- /package/{dist/business → business}/course/microknowledge-max-lengths.d.ts +0 -0
- /package/{dist/business → business}/course/microknowledge-max-lengths.js +0 -0
- /package/{dist/business → business}/course/microknowledge-max-lengths.js.map +0 -0
- /package/{dist/business → business}/index.d.ts +0 -0
- /package/{dist/business → business}/index.js +0 -0
- /package/{dist/business → business}/index.js.map +0 -0
- /package/{dist/business → business}/picture-spot/index.d.ts +0 -0
- /package/{dist/business → business}/picture-spot/index.js +0 -0
- /package/{dist/business → business}/picture-spot/index.js.map +0 -0
- /package/{dist/business → business}/types/achievement.d.ts +0 -0
- /package/{dist/business → business}/types/activity.d.ts +0 -0
- /package/{dist/business → business}/types/activity.js +0 -0
- /package/{dist/business → business}/types/activity.js.map +0 -0
- /package/{dist/business → business}/types/audience.d.ts +0 -0
- /package/{dist/business → business}/types/battle.d.ts +0 -0
- /package/{dist/business → business}/types/breaking-news.d.ts +0 -0
- /package/{dist/business → business}/types/campaign.d.ts +0 -0
- /package/{dist/business → business}/types/campaign.js +0 -0
- /package/{dist/business → business}/types/campaign.js.map +0 -0
- /package/{dist/business → business}/types/content.d.ts +0 -0
- /package/{dist/business → business}/types/content.js +0 -0
- /package/{dist/business → business}/types/content.js.map +0 -0
- /package/{dist/business → business}/types/document.d.ts +0 -0
- /package/{dist/business → business}/types/index.d.ts +0 -0
- /package/{dist/business → business}/types/index.js +0 -0
- /package/{dist/business → business}/types/index.js.map +0 -0
- /package/{dist/business → business}/types/media.d.ts +0 -0
- /package/{dist/business → business}/types/multilingual.d.ts +0 -0
- /package/{dist/business → business}/types/multilingual.js +0 -0
- /package/{dist/business → business}/types/multilingual.js.map +0 -0
- /package/{dist/business → business}/types/player.d.ts +0 -0
- /package/{dist/business → business}/types/score.d.ts +0 -0
- /package/{dist/business → business}/types/score.js +0 -0
- /package/{dist/business → business}/types/score.js.map +0 -0
- /package/{dist/business → business}/types/thematic.d.ts +0 -0
- /package/{dist/business → business}/types/user-engagement.d.ts +0 -0
- /package/{dist/cdn → cdn}/cdn.factory.d.ts +0 -0
- /package/{dist/cdn → cdn}/cdn.factory.js +0 -0
- /package/{dist/cdn → cdn}/cdn.factory.js.map +0 -0
- /package/{dist/cdn → cdn}/index.d.ts +0 -0
- /package/{dist/cdn → cdn}/index.js +0 -0
- /package/{dist/cdn → cdn}/index.js.map +0 -0
- /package/{dist/cdn → cdn}/types/cdn-factory.type.d.ts +0 -0
- /package/{dist/cdn → cdn}/types/index.d.ts +0 -0
- /package/{dist/cdn → cdn}/types/index.js +0 -0
- /package/{dist/cdn → cdn}/types/index.js.map +0 -0
- /package/{dist/cdn → cdn}/utils/extract-info-from-url.util.d.ts +0 -0
- /package/{dist/cdn → cdn}/utils/extract-info-from-url.util.js +0 -0
- /package/{dist/cdn → cdn}/utils/extract-info-from-url.util.js.map +0 -0
- /package/{dist/cdn → cdn}/utils/get-cdn-from-s3-url.util.d.ts +0 -0
- /package/{dist/cdn → cdn}/utils/get-cdn-from-s3-url.util.js +0 -0
- /package/{dist/cdn → cdn}/utils/get-cdn-from-s3-url.util.js.map +0 -0
- /package/{dist/cdn → cdn}/utils/get-cdn-url.util.d.ts +0 -0
- /package/{dist/cdn → cdn}/utils/get-cdn-url.util.js +0 -0
- /package/{dist/cdn → cdn}/utils/get-cdn-url.util.js.map +0 -0
- /package/{dist/cdn → cdn}/utils/twicpics-transformations.util.d.ts +0 -0
- /package/{dist/cdn → cdn}/utils/twicpics-transformations.util.js +0 -0
- /package/{dist/cdn → cdn}/utils/twicpics-transformations.util.js.map +0 -0
- /package/{dist/chrono → chrono}/get-approximated-session-time.d.ts +0 -0
- /package/{dist/chrono → chrono}/get-approximated-session-time.js +0 -0
- /package/{dist/chrono → chrono}/get-approximated-session-time.js.map +0 -0
- /package/{dist/chrono → chrono}/index.d.ts +0 -0
- /package/{dist/chrono → chrono}/index.js +0 -0
- /package/{dist/chrono → chrono}/index.js.map +0 -0
- /package/{dist/color → color}/get-contrast-color.d.ts +0 -0
- /package/{dist/color → color}/get-contrast-color.js +0 -0
- /package/{dist/color → color}/get-contrast-color.js.map +0 -0
- /package/{dist/color → color}/index.d.ts +0 -0
- /package/{dist/color → color}/index.js +0 -0
- /package/{dist/color → color}/index.js.map +0 -0
- /package/{dist/crypto → crypto}/aes256.d.ts +0 -0
- /package/{dist/crypto → crypto}/aes256.js +0 -0
- /package/{dist/crypto → crypto}/aes256.js.map +0 -0
- /package/{dist/crypto → crypto}/index.d.ts +0 -0
- /package/{dist/crypto → crypto}/index.js +0 -0
- /package/{dist/crypto → crypto}/index.js.map +0 -0
- /package/{dist/date → date}/add-days.d.ts +0 -0
- /package/{dist/date → date}/add-days.js +0 -0
- /package/{dist/date → date}/add-days.js.map +0 -0
- /package/{dist/date → date}/difference-in-days.d.ts +0 -0
- /package/{dist/date → date}/difference-in-days.js +0 -0
- /package/{dist/date → date}/difference-in-days.js.map +0 -0
- /package/{dist/date → date}/get-iso-day-number.d.ts +0 -0
- /package/{dist/date → date}/get-iso-day-number.js +0 -0
- /package/{dist/date → date}/get-iso-day-number.js.map +0 -0
- /package/{dist/date → date}/get-next-day.d.ts +0 -0
- /package/{dist/date → date}/get-next-day.js +0 -0
- /package/{dist/date → date}/get-next-day.js.map +0 -0
- /package/{dist/date → date}/get-remaining-time.d.ts +0 -0
- /package/{dist/date → date}/get-remaining-time.js +0 -0
- /package/{dist/date → date}/get-remaining-time.js.map +0 -0
- /package/{dist/date → date}/get-start-of-day.d.ts +0 -0
- /package/{dist/date → date}/get-start-of-day.js +0 -0
- /package/{dist/date → date}/get-start-of-day.js.map +0 -0
- /package/{dist/date → date}/index.d.ts +0 -0
- /package/{dist/date → date}/index.js +0 -0
- /package/{dist/date → date}/index.js.map +0 -0
- /package/{dist/date → date}/is-same-date.d.ts +0 -0
- /package/{dist/date → date}/is-same-date.js +0 -0
- /package/{dist/date → date}/is-same-date.js.map +0 -0
- /package/{dist/date → date}/shift-date-by.d.ts +0 -0
- /package/{dist/date → date}/shift-date-by.js +0 -0
- /package/{dist/date → date}/shift-date-by.js.map +0 -0
- /package/{dist/date → date}/to-plain-date-string.d.ts +0 -0
- /package/{dist/date → date}/to-plain-date-string.js +0 -0
- /package/{dist/date → date}/to-plain-date-string.js.map +0 -0
- /package/{dist/date → date}/to-utc-date-string.d.ts +0 -0
- /package/{dist/date → date}/to-utc-date-string.js +0 -0
- /package/{dist/date → date}/to-utc-date-string.js.map +0 -0
- /package/{dist/formatting → formatting}/format-number.d.ts +0 -0
- /package/{dist/formatting → formatting}/format-number.js +0 -0
- /package/{dist/formatting → formatting}/format-number.js.map +0 -0
- /package/{dist/formatting → formatting}/index.d.ts +0 -0
- /package/{dist/formatting → formatting}/index.js +0 -0
- /package/{dist/formatting → formatting}/index.js.map +0 -0
- /package/{dist/fp → fp}/index.d.ts +0 -0
- /package/{dist/fp → fp}/index.js +0 -0
- /package/{dist/fp → fp}/index.js.map +0 -0
- /package/{dist/fp → fp}/run-while.d.ts +0 -0
- /package/{dist/fp → fp}/run-while.js +0 -0
- /package/{dist/fp → fp}/run-while.js.map +0 -0
- /package/{dist/http → http}/build-search-params.d.ts +0 -0
- /package/{dist/http → http}/build-search-params.js +0 -0
- /package/{dist/http → http}/build-search-params.js.map +0 -0
- /package/{dist/http → http}/encode-search-object.d.ts +0 -0
- /package/{dist/http → http}/encode-search-object.js +0 -0
- /package/{dist/http → http}/encode-search-object.js.map +0 -0
- /package/{dist/http → http}/fetch-with-timeout.d.ts +0 -0
- /package/{dist/http → http}/fetch-with-timeout.js +0 -0
- /package/{dist/http → http}/fetch-with-timeout.js.map +0 -0
- /package/{dist/http → http}/index.d.ts +0 -0
- /package/{dist/http → http}/index.js +0 -0
- /package/{dist/http → http}/index.js.map +0 -0
- /package/{dist/index.d.ts → index.d.ts} +0 -0
- /package/{dist/index.js → index.js} +0 -0
- /package/{dist/index.js.map → index.js.map} +0 -0
- /package/{dist/linked-list → linked-list}/apply-diff-linked-list.d.ts +0 -0
- /package/{dist/linked-list → linked-list}/apply-diff-linked-list.js +0 -0
- /package/{dist/linked-list → linked-list}/apply-diff-linked-list.js.map +0 -0
- /package/{dist/linked-list → linked-list}/create-linked-list.d.ts +0 -0
- /package/{dist/linked-list → linked-list}/create-linked-list.js +0 -0
- /package/{dist/linked-list → linked-list}/create-linked-list.js.map +0 -0
- /package/{dist/linked-list → linked-list}/find-linked-list.d.ts +0 -0
- /package/{dist/linked-list → linked-list}/find-linked-list.js +0 -0
- /package/{dist/linked-list → linked-list}/find-linked-list.js.map +0 -0
- /package/{dist/linked-list → linked-list}/get-linked-list.d.ts +0 -0
- /package/{dist/linked-list → linked-list}/get-linked-list.js +0 -0
- /package/{dist/linked-list → linked-list}/get-linked-list.js.map +0 -0
- /package/{dist/linked-list → linked-list}/index.d.ts +0 -0
- /package/{dist/linked-list → linked-list}/index.js +0 -0
- /package/{dist/linked-list → linked-list}/index.js.map +0 -0
- /package/{dist/linked-list → linked-list}/insert-linked-list.d.ts +0 -0
- /package/{dist/linked-list → linked-list}/insert-linked-list.js +0 -0
- /package/{dist/linked-list → linked-list}/insert-linked-list.js.map +0 -0
- /package/{dist/linked-list → linked-list}/linked-list-utils.d.ts +0 -0
- /package/{dist/linked-list → linked-list}/linked-list-utils.js +0 -0
- /package/{dist/linked-list → linked-list}/linked-list-utils.js.map +0 -0
- /package/{dist/linked-list → linked-list}/reduce-linked-list.d.ts +0 -0
- /package/{dist/linked-list → linked-list}/reduce-linked-list.js +0 -0
- /package/{dist/linked-list → linked-list}/reduce-linked-list.js.map +0 -0
- /package/{dist/linked-list → linked-list}/remove-linked-list.d.ts +0 -0
- /package/{dist/linked-list → linked-list}/remove-linked-list.js +0 -0
- /package/{dist/linked-list → linked-list}/remove-linked-list.js.map +0 -0
- /package/{dist/linked-list → linked-list}/type.d.ts +0 -0
- /package/{dist/linked-list → linked-list}/update-linked-list.d.ts +0 -0
- /package/{dist/linked-list → linked-list}/update-linked-list.js +0 -0
- /package/{dist/linked-list → linked-list}/update-linked-list.js.map +0 -0
- /package/{dist/linked-list → linked-list}/while-linked-list.d.ts +0 -0
- /package/{dist/linked-list → linked-list}/while-linked-list.js +0 -0
- /package/{dist/linked-list → linked-list}/while-linked-list.js.map +0 -0
- /package/{dist/math → math}/clamp-number.d.ts +0 -0
- /package/{dist/math → math}/clamp-number.js +0 -0
- /package/{dist/math → math}/clamp-number.js.map +0 -0
- /package/{dist/math → math}/index.d.ts +0 -0
- /package/{dist/math → math}/index.js +0 -0
- /package/{dist/math → math}/index.js.map +0 -0
- /package/{dist/math → math}/interpolate.d.ts +0 -0
- /package/{dist/math → math}/interpolate.js +0 -0
- /package/{dist/math → math}/interpolate.js.map +0 -0
- /package/{dist/math → math}/median.d.ts +0 -0
- /package/{dist/math → math}/median.js +0 -0
- /package/{dist/math → math}/median.js.map +0 -0
- /package/{dist/math → math}/number-range.d.ts +0 -0
- /package/{dist/math → math}/number-range.js +0 -0
- /package/{dist/math → math}/number-range.js.map +0 -0
- /package/{dist/math → math}/random-number.d.ts +0 -0
- /package/{dist/math → math}/random-number.js +0 -0
- /package/{dist/math → math}/random-number.js.map +0 -0
- /package/{dist/object → object}/index.d.ts +0 -0
- /package/{dist/object → object}/index.js +0 -0
- /package/{dist/object → object}/index.js.map +0 -0
- /package/{dist/object → object}/merge-deep.d.ts +0 -0
- /package/{dist/object → object}/merge-deep.js +0 -0
- /package/{dist/object → object}/merge-deep.js.map +0 -0
- /package/{dist/object → object}/strip-properties-from-object.d.ts +0 -0
- /package/{dist/object → object}/strip-properties-from-object.js +0 -0
- /package/{dist/object → object}/strip-properties-from-object.js.map +0 -0
- /package/{dist/parsing → parsing}/index.d.ts +0 -0
- /package/{dist/parsing → parsing}/index.js +0 -0
- /package/{dist/parsing → parsing}/index.js.map +0 -0
- /package/{dist/parsing → parsing}/parse-boolean.d.ts +0 -0
- /package/{dist/parsing → parsing}/parse-boolean.js +0 -0
- /package/{dist/parsing → parsing}/parse-boolean.js.map +0 -0
- /package/{dist/parsing → parsing}/parse-enum.d.ts +0 -0
- /package/{dist/parsing → parsing}/parse-enum.js +0 -0
- /package/{dist/parsing → parsing}/parse-enum.js.map +0 -0
- /package/{dist/parsing → parsing}/parse-number.d.ts +0 -0
- /package/{dist/parsing → parsing}/parse-number.js +0 -0
- /package/{dist/parsing → parsing}/parse-number.js.map +0 -0
- /package/{dist/predicates → predicates}/index.d.ts +0 -0
- /package/{dist/predicates → predicates}/index.js +0 -0
- /package/{dist/predicates → predicates}/index.js.map +0 -0
- /package/{dist/predicates → predicates}/is-function.d.ts +0 -0
- /package/{dist/predicates → predicates}/is-function.js +0 -0
- /package/{dist/predicates → predicates}/is-function.js.map +0 -0
- /package/{dist/predicates → predicates}/is-null.d.ts +0 -0
- /package/{dist/predicates → predicates}/is-null.js +0 -0
- /package/{dist/predicates → predicates}/is-null.js.map +0 -0
- /package/{dist/predicates → predicates}/is-object.d.ts +0 -0
- /package/{dist/predicates → predicates}/is-object.js +0 -0
- /package/{dist/predicates → predicates}/is-object.js.map +0 -0
- /package/{dist/predicates → predicates}/is-primitive.d.ts +0 -0
- /package/{dist/predicates → predicates}/is-primitive.js +0 -0
- /package/{dist/predicates → predicates}/is-primitive.js.map +0 -0
- /package/{dist/predicates → predicates}/is-undefined.d.ts +0 -0
- /package/{dist/predicates → predicates}/is-undefined.js +0 -0
- /package/{dist/predicates → predicates}/is-undefined.js.map +0 -0
- /package/{dist/predicates → predicates}/is-uuid.d.ts +0 -0
- /package/{dist/promise → promise}/delay.d.ts +0 -0
- /package/{dist/promise → promise}/delay.js +0 -0
- /package/{dist/promise → promise}/delay.js.map +0 -0
- /package/{dist/promise → promise}/execute-or-resolve-default.d.ts +0 -0
- /package/{dist/promise → promise}/execute-or-resolve-default.js +0 -0
- /package/{dist/promise → promise}/execute-or-resolve-default.js.map +0 -0
- /package/{dist/promise → promise}/execute-with-delay.d.ts +0 -0
- /package/{dist/promise → promise}/execute-with-delay.js +0 -0
- /package/{dist/promise → promise}/execute-with-delay.js.map +0 -0
- /package/{dist/promise → promise}/index.d.ts +0 -0
- /package/{dist/promise → promise}/index.js +0 -0
- /package/{dist/promise → promise}/index.js.map +0 -0
- /package/{dist/string → string}/index.d.ts +0 -0
- /package/{dist/string → string}/index.js +0 -0
- /package/{dist/string → string}/index.js.map +0 -0
- /package/{dist/string → string}/is-string-length-within-range.d.ts +0 -0
- /package/{dist/string → string}/is-string-length-within-range.js +0 -0
- /package/{dist/string → string}/is-string-length-within-range.js.map +0 -0
- /package/{dist/string → string}/replace-in-template.d.ts +0 -0
- /package/{dist/string → string}/replace-in-template.js +0 -0
- /package/{dist/string → string}/replace-in-template.js.map +0 -0
- /package/{dist/time → time}/constants.d.ts +0 -0
- /package/{dist/time → time}/constants.js +0 -0
- /package/{dist/time → time}/constants.js.map +0 -0
- /package/{dist/time → time}/convert.d.ts +0 -0
- /package/{dist/time → time}/convert.js +0 -0
- /package/{dist/time → time}/convert.js.map +0 -0
- /package/{dist/time → time}/format-minutes.d.ts +0 -0
- /package/{dist/time → time}/format-minutes.js +0 -0
- /package/{dist/time → time}/format-minutes.js.map +0 -0
- /package/{dist/time → time}/get-time-diff-as-string.d.ts +0 -0
- /package/{dist/time → time}/get-time-diff-as-string.js +0 -0
- /package/{dist/time → time}/get-time-diff-as-string.js.map +0 -0
- /package/{dist/time → time}/index.d.ts +0 -0
- /package/{dist/time → time}/index.js +0 -0
- /package/{dist/time → time}/index.js.map +0 -0
- /package/{dist/types → types}/function.d.ts +0 -0
- /package/{dist/types → types}/general.d.ts +0 -0
- /package/{dist/types → types}/index.d.ts +0 -0
- /package/{dist/types → types}/index.js +0 -0
- /package/{dist/types → types}/index.js.map +0 -0
- /package/{dist/types → types}/object.d.ts +0 -0
- /package/{dist/types → types}/search.d.ts +0 -0
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { arrayToMap } from '../array-to-map';
|
|
2
|
-
|
|
3
|
-
type Item = {
|
|
4
|
-
id: string,
|
|
5
|
-
bar: number,
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
describe('arrayToMap', () => {
|
|
9
|
-
it('should convert array to map with item containing one key', () => {
|
|
10
|
-
const array = [{ id: 'toto' }, { id: 'bonjour' }];
|
|
11
|
-
const map = arrayToMap(array, { selectKey: ({ id }) => id });
|
|
12
|
-
|
|
13
|
-
expect(map).toStrictEqual({
|
|
14
|
-
bonjour: { id: 'bonjour' },
|
|
15
|
-
toto: { id: 'toto' },
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('should convert array to map and select right key in item', () => {
|
|
20
|
-
const array = [{ id: 'toto', bar: 1 }, { id: 'bonjour', bar: 2 }];
|
|
21
|
-
const map = arrayToMap(array, { selectKey: ({ bar }) => bar.toString() });
|
|
22
|
-
|
|
23
|
-
expect(map).toStrictEqual({
|
|
24
|
-
1: { id: 'toto', bar: 1 },
|
|
25
|
-
2: { id: 'bonjour', bar: 2 },
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('should handle data transformation', () => {
|
|
30
|
-
const item1: Item = { id: 'toto', bar: 1 };
|
|
31
|
-
const item2: Item = { id: 'bonjour', bar: 2 };
|
|
32
|
-
const array = [item1, item2];
|
|
33
|
-
|
|
34
|
-
const modifierFn = jest.fn();
|
|
35
|
-
const map = arrayToMap<Item, string>(array, {
|
|
36
|
-
selectKey: ({ bar }) => bar.toString(),
|
|
37
|
-
dataModifier: ({ id }, currentMap) => {
|
|
38
|
-
modifierFn(currentMap);
|
|
39
|
-
return id;
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
expect(modifierFn).toHaveBeenNthCalledWith(1, {});
|
|
44
|
-
expect(modifierFn).toHaveBeenNthCalledWith(2, { 1: 'toto' });
|
|
45
|
-
expect(map).toStrictEqual({
|
|
46
|
-
1: 'toto',
|
|
47
|
-
2: 'bonjour',
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { valuesFromKeys } from '../get-values-from-keys';
|
|
2
|
-
|
|
3
|
-
describe('valuesFromKeys', () => {
|
|
4
|
-
it('should transform a map to an array with only selected keys', () => {
|
|
5
|
-
const map = {
|
|
6
|
-
uno: 1,
|
|
7
|
-
dos: 2,
|
|
8
|
-
tres: 3,
|
|
9
|
-
quatro: 4,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
expect(valuesFromKeys(['uno', 'tres'], map)).toStrictEqual([1, 3]);
|
|
13
|
-
});
|
|
14
|
-
});
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { innerJoin } from '../inner-join';
|
|
2
|
-
|
|
3
|
-
describe('innerJoin', () => {
|
|
4
|
-
it('should return an inner join of simple arrays', () => {
|
|
5
|
-
const arr1 = [1, 2, 3];
|
|
6
|
-
const arr2 = [3, 4, 5];
|
|
7
|
-
|
|
8
|
-
const innerJoinedArr = innerJoin(
|
|
9
|
-
arr1,
|
|
10
|
-
arr2,
|
|
11
|
-
(item) => item,
|
|
12
|
-
(item) => item,
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
expect(innerJoinedArr).toEqual([3]);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('should return an inner join of complex array', () => {
|
|
19
|
-
const arr1 = [
|
|
20
|
-
{ id: 1, name: 'John' },
|
|
21
|
-
{ id: 2, name: 'Doe' },
|
|
22
|
-
{ id: 3, name: 'Jane' },
|
|
23
|
-
{ id: 4, name: 'Jack' },
|
|
24
|
-
{ id: 5, name: 'Jill' },
|
|
25
|
-
{ id: 6, name: 'Maurice' },
|
|
26
|
-
];
|
|
27
|
-
const arr2 = [
|
|
28
|
-
{ id: 3, name: 'Jane' },
|
|
29
|
-
{ id: 4, name: 'Jack' },
|
|
30
|
-
{ id: 5, name: 'Jill' },
|
|
31
|
-
];
|
|
32
|
-
|
|
33
|
-
const innerJoinedArr = innerJoin(
|
|
34
|
-
arr1,
|
|
35
|
-
arr2,
|
|
36
|
-
(item) => item.id,
|
|
37
|
-
(item) => item.id,
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
expect(innerJoinedArr).toEqual([
|
|
41
|
-
{
|
|
42
|
-
id: 3,
|
|
43
|
-
name: 'Jane',
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
id: 4,
|
|
47
|
-
name: 'Jack',
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
id: 5,
|
|
51
|
-
name: 'Jill',
|
|
52
|
-
},
|
|
53
|
-
]);
|
|
54
|
-
});
|
|
55
|
-
});
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { leftOutterJoin } from '../left-outter-join';
|
|
2
|
-
|
|
3
|
-
describe('leftOutterJoin', () => {
|
|
4
|
-
it('should return left outter joined of simple arrays', () => {
|
|
5
|
-
const arr1 = [1, 2, 3];
|
|
6
|
-
const arr2 = [3, 4, 5];
|
|
7
|
-
|
|
8
|
-
const leftOutterJoinedArr = leftOutterJoin(
|
|
9
|
-
arr1,
|
|
10
|
-
arr2,
|
|
11
|
-
(item) => item,
|
|
12
|
-
(item) => item,
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
expect(leftOutterJoinedArr).toEqual([1, 2]);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('should return left outter joined of complex array', () => {
|
|
19
|
-
const arr1 = [
|
|
20
|
-
{ id: 1, name: 'John' },
|
|
21
|
-
{ id: 2, name: 'Doe' },
|
|
22
|
-
{ id: 3, name: 'Jane' },
|
|
23
|
-
{ id: 4, name: 'Jack' },
|
|
24
|
-
{ id: 5, name: 'Jill' },
|
|
25
|
-
{ id: 6, name: 'Maurice' },
|
|
26
|
-
];
|
|
27
|
-
const arr2 = [
|
|
28
|
-
{ id: 3, name: 'Jane' },
|
|
29
|
-
{ id: 4, name: 'Jack' },
|
|
30
|
-
{ id: 5, name: 'Jill' },
|
|
31
|
-
];
|
|
32
|
-
|
|
33
|
-
const leftOutterJoinedArr = leftOutterJoin(
|
|
34
|
-
arr1,
|
|
35
|
-
arr2,
|
|
36
|
-
(item) => item.id,
|
|
37
|
-
(item) => item.id,
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
expect(leftOutterJoinedArr).toEqual([
|
|
41
|
-
{
|
|
42
|
-
id: 1,
|
|
43
|
-
name: 'John',
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
id: 2,
|
|
47
|
-
name: 'Doe',
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
id: 6,
|
|
51
|
-
name: 'Maurice',
|
|
52
|
-
},
|
|
53
|
-
]);
|
|
54
|
-
});
|
|
55
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export type ArrayToMapOptions<InitialValue, ModifiedValue = InitialValue> = {
|
|
2
|
-
/**
|
|
3
|
-
* Function to return the key used in the map.
|
|
4
|
-
*/
|
|
5
|
-
selectKey: (value: InitialValue) => string,
|
|
6
|
-
/**
|
|
7
|
-
* Transform the initial data into another value
|
|
8
|
-
*/
|
|
9
|
-
dataModifier?: (value: InitialValue, map: Readonly<Record<string, ModifiedValue>>) => ModifiedValue;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Transform an array to a map.
|
|
14
|
-
*/
|
|
15
|
-
export const arrayToMap = <InitialValue, ModifiedValue = InitialValue>(
|
|
16
|
-
array: ReadonlyArray<InitialValue>,
|
|
17
|
-
options: ArrayToMapOptions<InitialValue, ModifiedValue>,
|
|
18
|
-
) => {
|
|
19
|
-
const { selectKey } = options;
|
|
20
|
-
|
|
21
|
-
return array.reduce<Record<string, ModifiedValue>>((acc, current) => {
|
|
22
|
-
const key = selectKey(current);
|
|
23
|
-
const value = options.dataModifier
|
|
24
|
-
? options.dataModifier(current, acc)
|
|
25
|
-
: current;
|
|
26
|
-
|
|
27
|
-
return {
|
|
28
|
-
...acc,
|
|
29
|
-
[key]: value as ModifiedValue,
|
|
30
|
-
};
|
|
31
|
-
}, {});
|
|
32
|
-
};
|
package/src/array/index.ts
DELETED
package/src/array/inner-join.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export const innerJoin = <T, U>(
|
|
2
|
-
arr1: T[],
|
|
3
|
-
arr2: U[],
|
|
4
|
-
selectKey1: (item: T) => string | number,
|
|
5
|
-
selectKey2: (item: U) => string | number,
|
|
6
|
-
) => {
|
|
7
|
-
const arr2Set = new Set(arr2.map(selectKey2));
|
|
8
|
-
|
|
9
|
-
return arr1.filter((item) => arr2Set.has(selectKey1(item)));
|
|
10
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export const leftOutterJoin = <T, U>(
|
|
2
|
-
arr1: T[],
|
|
3
|
-
arr2: U[],
|
|
4
|
-
selectKey1: (item: T) => string | number,
|
|
5
|
-
selectKey2: (item: U) => string | number,
|
|
6
|
-
) => {
|
|
7
|
-
const arr2Set = new Set(arr2.map(selectKey2));
|
|
8
|
-
|
|
9
|
-
return arr1.filter((item) => !arr2Set.has(selectKey1(item)));
|
|
10
|
-
};
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import { computeCurrentSession } from '../live-campaign';
|
|
2
|
-
|
|
3
|
-
jest.useFakeTimers();
|
|
4
|
-
|
|
5
|
-
describe('computeCurrentSession', () => {
|
|
6
|
-
it('Flexible Type with Last Session Played Less Than Session Count', () => {
|
|
7
|
-
const card = {
|
|
8
|
-
details: {
|
|
9
|
-
type: 'flexible',
|
|
10
|
-
sessionCount: 5,
|
|
11
|
-
utcStartDate: '2023-01-01T00:00:00Z',
|
|
12
|
-
utcEndDate: '2023-12-31T23:59:59Z',
|
|
13
|
-
enabledWeekDays: [1, 2, 3, 4, 5],
|
|
14
|
-
disabledDates: [],
|
|
15
|
-
},
|
|
16
|
-
achievement: {
|
|
17
|
-
lastSessionPlayed: 2,
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
expect(computeCurrentSession(card as any)).toBe(3);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('Flexible Type with Last Session Played Equal to Session Count', () => {
|
|
24
|
-
const card = {
|
|
25
|
-
details: {
|
|
26
|
-
type: 'flexible',
|
|
27
|
-
sessionCount: 5,
|
|
28
|
-
utcStartDate: '2023-01-01T00:00:00Z',
|
|
29
|
-
utcEndDate: '2023-12-31T23:59:59Z',
|
|
30
|
-
enabledWeekDays: [1, 2, 3, 4, 5],
|
|
31
|
-
disabledDates: [],
|
|
32
|
-
},
|
|
33
|
-
achievement: {
|
|
34
|
-
lastSessionPlayed: 5,
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
expect(computeCurrentSession(card as any)).toBe(5);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('Flexible Type with forceComputeCalendar=true within normal date range', () => {
|
|
41
|
-
const card = {
|
|
42
|
-
details: {
|
|
43
|
-
type: 'flexible',
|
|
44
|
-
sessionCount: 10,
|
|
45
|
-
utcStartDate: '2024-01-01T00:00:00Z',
|
|
46
|
-
utcEndDate: '2024-01-31T23:59:59Z',
|
|
47
|
-
enabledWeekDays: [1, 2, 3, 4, 5],
|
|
48
|
-
disabledDates: [],
|
|
49
|
-
},
|
|
50
|
-
achievement: {
|
|
51
|
-
lastSessionPlayed: 0,
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
jest.setSystemTime(new Date('2024-01-09T00:00:00Z'));
|
|
55
|
-
expect(computeCurrentSession(card as any, true)).toBe(7);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('Flexible Type with forceComputeCalendar=true within extra days', () => {
|
|
59
|
-
const card = {
|
|
60
|
-
details: {
|
|
61
|
-
type: 'flexible',
|
|
62
|
-
sessionCount: 10,
|
|
63
|
-
utcStartDate: '2024-01-01T00:00:00Z',
|
|
64
|
-
utcEndDate: '2024-01-31T23:59:59Z',
|
|
65
|
-
enabledWeekDays: [1, 2, 3, 4, 5],
|
|
66
|
-
disabledDates: [],
|
|
67
|
-
},
|
|
68
|
-
achievement: {
|
|
69
|
-
lastSessionPlayed: 0,
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
jest.setSystemTime(new Date('2024-01-30T00:00:00Z'));
|
|
73
|
-
expect(computeCurrentSession(card as any, true)).toBe(10);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('Intense Type Before Start Date', () => {
|
|
77
|
-
const card = {
|
|
78
|
-
details: {
|
|
79
|
-
type: 'intense',
|
|
80
|
-
sessionCount: 10,
|
|
81
|
-
utcStartDate: '2024-12-31T00:00:00Z',
|
|
82
|
-
utcEndDate: '2025-12-31T23:59:59Z',
|
|
83
|
-
enabledWeekDays: [1, 2, 3, 4, 5],
|
|
84
|
-
disabledDates: [],
|
|
85
|
-
},
|
|
86
|
-
achievement: {
|
|
87
|
-
lastSessionPlayed: 0,
|
|
88
|
-
},
|
|
89
|
-
};
|
|
90
|
-
jest.setSystemTime(new Date('2024-12-01T00:00:00Z'));
|
|
91
|
-
expect(computeCurrentSession(card as any)).toBe(1);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('Intense Type Within Date Range with Enabled Weekday', () => {
|
|
95
|
-
const card = {
|
|
96
|
-
details: {
|
|
97
|
-
type: 'intense',
|
|
98
|
-
sessionCount: 10,
|
|
99
|
-
utcStartDate: '2023-03-01T00:00:00Z',
|
|
100
|
-
utcEndDate: '2023-03-31T23:59:59Z',
|
|
101
|
-
enabledWeekDays: [1, 2, 3, 4, 5],
|
|
102
|
-
disabledDates: [],
|
|
103
|
-
},
|
|
104
|
-
achievement: {
|
|
105
|
-
lastSessionPlayed: 0,
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
jest.setSystemTime(new Date('2023-03-06T00:00:00Z'));
|
|
110
|
-
|
|
111
|
-
expect(computeCurrentSession(card as any)).toBe(4);
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it('Intense Type Within Date Range with Disabled Date', () => {
|
|
115
|
-
const card = {
|
|
116
|
-
details: {
|
|
117
|
-
type: 'intense',
|
|
118
|
-
sessionCount: 10,
|
|
119
|
-
utcStartDate: '2023-03-01T00:00:00Z',
|
|
120
|
-
utcEndDate: '2023-03-31T23:59:59Z',
|
|
121
|
-
enabledWeekDays: [1, 2, 3, 4, 5],
|
|
122
|
-
disabledDates: ['2023-03-03'],
|
|
123
|
-
},
|
|
124
|
-
achievement: {
|
|
125
|
-
lastSessionPlayed: 0,
|
|
126
|
-
},
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
jest.setSystemTime(new Date('2023-03-06T00:00:00Z'));
|
|
130
|
-
|
|
131
|
-
expect(computeCurrentSession(card as any)).toBe(3);
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it('Intense Type Beyond End Date', () => {
|
|
135
|
-
const card = {
|
|
136
|
-
details: {
|
|
137
|
-
type: 'intense',
|
|
138
|
-
sessionCount: 10,
|
|
139
|
-
utcStartDate: '2023-01-01T00:00:00Z',
|
|
140
|
-
utcEndDate: '2023-12-31T23:59:59Z',
|
|
141
|
-
enabledWeekDays: [1, 2, 3, 4, 5],
|
|
142
|
-
disabledDates: [],
|
|
143
|
-
},
|
|
144
|
-
achievement: {
|
|
145
|
-
lastSessionPlayed: 0,
|
|
146
|
-
},
|
|
147
|
-
};
|
|
148
|
-
jest.setSystemTime(new Date('2024-01-01T00:00:00Z'));
|
|
149
|
-
expect(computeCurrentSession(card as any)).toBe(10);
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
it('Intense Type on Weekend', () => {
|
|
153
|
-
const card = {
|
|
154
|
-
details: {
|
|
155
|
-
type: 'intense',
|
|
156
|
-
sessionCount: 10,
|
|
157
|
-
utcStartDate: '2023-01-01T00:00:00Z',
|
|
158
|
-
utcEndDate: '2023-12-31T23:59:59Z',
|
|
159
|
-
enabledWeekDays: [1, 2, 3, 4, 5],
|
|
160
|
-
disabledDates: [],
|
|
161
|
-
},
|
|
162
|
-
achievement: {
|
|
163
|
-
lastSessionPlayed: 0,
|
|
164
|
-
},
|
|
165
|
-
};
|
|
166
|
-
jest.setSystemTime(new Date('2023-01-07T00:00:00Z')); // Saturday
|
|
167
|
-
expect(computeCurrentSession(card as any)).toBe(6);
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
it('Intense Type with forceComputeCalendar=true behaves normally', () => {
|
|
171
|
-
const card = {
|
|
172
|
-
details: {
|
|
173
|
-
type: 'intense',
|
|
174
|
-
sessionCount: 10,
|
|
175
|
-
utcStartDate: '2023-03-01T00:00:00Z',
|
|
176
|
-
utcEndDate: '2023-03-31T23:59:59Z',
|
|
177
|
-
enabledWeekDays: [1, 2, 3, 4, 5],
|
|
178
|
-
disabledDates: [],
|
|
179
|
-
},
|
|
180
|
-
achievement: {
|
|
181
|
-
lastSessionPlayed: 0,
|
|
182
|
-
},
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
jest.setSystemTime(new Date('2023-03-06T00:00:00Z'));
|
|
186
|
-
|
|
187
|
-
expect(computeCurrentSession(card as any, true)).toBe(4);
|
|
188
|
-
});
|
|
189
|
-
});
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { computeIntenseCalendar } from '../live-campaign';
|
|
2
|
-
|
|
3
|
-
describe('computeIntenseCalendar', () => {
|
|
4
|
-
it('Valid Dates and Weekdays', () => {
|
|
5
|
-
const card = {
|
|
6
|
-
details: {
|
|
7
|
-
utcStartDate: '2023-01-01T00:00:00Z',
|
|
8
|
-
utcEndDate: '2023-01-07T00:00:00Z',
|
|
9
|
-
enabledWeekDays: [1, 2, 3, 4, 5],
|
|
10
|
-
disabledDates: [],
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
const expectedOutput = [
|
|
14
|
-
new Date('2023-01-02'),
|
|
15
|
-
new Date('2023-01-03'),
|
|
16
|
-
new Date('2023-01-04'),
|
|
17
|
-
new Date('2023-01-05'),
|
|
18
|
-
new Date('2023-01-06'),
|
|
19
|
-
];
|
|
20
|
-
expect(computeIntenseCalendar(card as any)).toEqual(expectedOutput);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('Disabled Dates', () => {
|
|
24
|
-
const card = {
|
|
25
|
-
details: {
|
|
26
|
-
utcStartDate: '2023-01-01T00:00:00Z',
|
|
27
|
-
utcEndDate: '2023-01-07T00:00:00Z',
|
|
28
|
-
enabledWeekDays: [1, 2, 3, 4, 5],
|
|
29
|
-
disabledDates: ['2023-01-03'],
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
const expectedOutput = [
|
|
33
|
-
new Date('2023-01-02'),
|
|
34
|
-
new Date('2023-01-04'),
|
|
35
|
-
new Date('2023-01-05'),
|
|
36
|
-
new Date('2023-01-06'),
|
|
37
|
-
];
|
|
38
|
-
expect(computeIntenseCalendar(card as any)).toEqual(expectedOutput);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('Start Date Equals End Date', () => {
|
|
42
|
-
const card = {
|
|
43
|
-
details: {
|
|
44
|
-
utcStartDate: '2023-01-01T00:00:00Z',
|
|
45
|
-
utcEndDate: '2023-01-01T00:00:00Z',
|
|
46
|
-
enabledWeekDays: [1, 2, 3, 4, 5],
|
|
47
|
-
disabledDates: [],
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
const expectedOutput: Date[] = [];
|
|
51
|
-
expect(computeIntenseCalendar(card as any)).toEqual(expectedOutput);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('No Enabled Weekdays', () => {
|
|
55
|
-
const card = {
|
|
56
|
-
details: {
|
|
57
|
-
utcStartDate: '2023-01-01T00:00:00Z',
|
|
58
|
-
utcEndDate: '2023-01-07T00:00:00Z',
|
|
59
|
-
enabledWeekDays: [],
|
|
60
|
-
disabledDates: [],
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const expectedOutput: Date[] = [];
|
|
65
|
-
|
|
66
|
-
expect(computeIntenseCalendar(card as any)).toEqual(expectedOutput);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('All Weekdays Enabled', () => {
|
|
70
|
-
const card = {
|
|
71
|
-
details: {
|
|
72
|
-
utcStartDate: '2023-01-01T00:00:00Z',
|
|
73
|
-
utcEndDate: '2023-01-07T00:00:00Z',
|
|
74
|
-
enabledWeekDays: [1, 2, 3, 4, 5, 6, 7],
|
|
75
|
-
disabledDates: [],
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
const expectedOutput = [
|
|
79
|
-
new Date('2023-01-01'),
|
|
80
|
-
new Date('2023-01-02'),
|
|
81
|
-
new Date('2023-01-03'),
|
|
82
|
-
new Date('2023-01-04'),
|
|
83
|
-
new Date('2023-01-05'),
|
|
84
|
-
new Date('2023-01-06'),
|
|
85
|
-
new Date('2023-01-07'),
|
|
86
|
-
];
|
|
87
|
-
expect(computeIntenseCalendar(card as any)).toEqual(expectedOutput);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('Date Range Spans Across Months', () => {
|
|
91
|
-
const card = {
|
|
92
|
-
details: {
|
|
93
|
-
utcStartDate: '2023-01-30T00:00:00Z',
|
|
94
|
-
utcEndDate: '2023-02-05T00:00:00Z',
|
|
95
|
-
enabledWeekDays: [1, 2, 3, 4, 5],
|
|
96
|
-
disabledDates: [],
|
|
97
|
-
},
|
|
98
|
-
};
|
|
99
|
-
const expectedOutput = [
|
|
100
|
-
new Date('2023-01-30'),
|
|
101
|
-
new Date('2023-01-31'),
|
|
102
|
-
new Date('2023-02-01'),
|
|
103
|
-
new Date('2023-02-02'),
|
|
104
|
-
new Date('2023-02-03'),
|
|
105
|
-
];
|
|
106
|
-
expect(computeIntenseCalendar(card as any)).toEqual(expectedOutput);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it('All Days Disabled', () => {
|
|
110
|
-
const card = {
|
|
111
|
-
details: {
|
|
112
|
-
utcStartDate: '2023-01-01T00:00:00Z',
|
|
113
|
-
utcEndDate: '2023-01-07T00:00:00Z',
|
|
114
|
-
enabledWeekDays: [1, 2, 3, 4, 5],
|
|
115
|
-
disabledDates: ['2023-01-02', '2023-01-03', '2023-01-04', '2023-01-05', '2023-01-06'],
|
|
116
|
-
},
|
|
117
|
-
};
|
|
118
|
-
const expectedOutput: Date[] = [];
|
|
119
|
-
expect(computeIntenseCalendar(card as any)).toEqual(expectedOutput);
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it('Single Day Range', () => {
|
|
123
|
-
const card = {
|
|
124
|
-
details: {
|
|
125
|
-
utcStartDate: '2023-01-01T00:00:00Z',
|
|
126
|
-
utcEndDate: '2023-01-02T00:00:00Z',
|
|
127
|
-
enabledWeekDays: [1, 7],
|
|
128
|
-
disabledDates: [],
|
|
129
|
-
},
|
|
130
|
-
};
|
|
131
|
-
const expectedOutput = [new Date('2023-01-01'), new Date('2023-01-02')];
|
|
132
|
-
expect(computeIntenseCalendar(card as any)).toEqual(expectedOutput);
|
|
133
|
-
});
|
|
134
|
-
});
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { findNextAvailableDate } from '../live-campaign';
|
|
2
|
-
|
|
3
|
-
describe('findNextAvailableDate', () => {
|
|
4
|
-
it('should return the current date if it is enabled and not disabled', () => {
|
|
5
|
-
const currentDate = new Date('2024-04-22'); // Monday
|
|
6
|
-
const enabledWeekDays = [1, 2, 3, 4, 5]; // Monday to Friday
|
|
7
|
-
const disabledDates: Date[] = [];
|
|
8
|
-
|
|
9
|
-
const result = findNextAvailableDate(currentDate, enabledWeekDays, disabledDates);
|
|
10
|
-
expect(result).toEqual(currentDate);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it('should skip the current date if it is not an enabled weekday', () => {
|
|
14
|
-
const currentDate = new Date('2024-04-27'); // Saturday
|
|
15
|
-
const enabledWeekDays = [1, 2, 3, 4, 5]; // Monday to Friday
|
|
16
|
-
const disabledDates: Date[] = [];
|
|
17
|
-
|
|
18
|
-
const expectedDate = new Date('2024-04-29'); // Next Monday
|
|
19
|
-
const result = findNextAvailableDate(currentDate, enabledWeekDays, disabledDates);
|
|
20
|
-
expect(result).toEqual(expectedDate);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('should skip the current date if it is disabled', () => {
|
|
24
|
-
const currentDate = new Date('2024-04-22'); // Monday
|
|
25
|
-
const enabledWeekDays = [1, 2, 3, 4, 5];
|
|
26
|
-
const disabledDates = [new Date('2024-04-22')];
|
|
27
|
-
|
|
28
|
-
const expectedDate = new Date('2024-04-23'); // Thuesday
|
|
29
|
-
const result = findNextAvailableDate(currentDate, enabledWeekDays, disabledDates);
|
|
30
|
-
expect(result).toEqual(expectedDate);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('should recurse until a valid date is found', () => {
|
|
34
|
-
const currentDate = new Date('2024-04-26'); // Friday
|
|
35
|
-
const enabledWeekDays = [1, 2, 3, 4, 5]; // Monday to Friday
|
|
36
|
-
const disabledDates = [
|
|
37
|
-
new Date('2024-04-26'), // Friday
|
|
38
|
-
new Date('2024-04-29'), // Monday next
|
|
39
|
-
];
|
|
40
|
-
|
|
41
|
-
const expectedDate = new Date('2024-04-30'); // Thuesday
|
|
42
|
-
const result = findNextAvailableDate(currentDate, enabledWeekDays, disabledDates);
|
|
43
|
-
expect(result).toEqual(expectedDate);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('should return current date if it is the end date and valid', () => {
|
|
47
|
-
const currentDate = new Date('2024-04-30'); // Thuesday
|
|
48
|
-
const enabledWeekDays = [1, 2, 3, 4, 5];
|
|
49
|
-
const disabledDates: Date[] = [];
|
|
50
|
-
|
|
51
|
-
const result = findNextAvailableDate(currentDate, enabledWeekDays, disabledDates);
|
|
52
|
-
expect(result).toEqual(currentDate);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('should return current date if currentDate is after endDate', () => {
|
|
56
|
-
const currentDate = new Date('2024-05-01'); // Wednesday
|
|
57
|
-
const enabledWeekDays = [1, 2, 3, 4, 5];
|
|
58
|
-
const disabledDates: Date[] = [];
|
|
59
|
-
|
|
60
|
-
const result = findNextAvailableDate(currentDate, enabledWeekDays, disabledDates);
|
|
61
|
-
expect(result).toEqual(currentDate);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('should handle empty enabledWeekDays by treating no days as enabled', () => {
|
|
65
|
-
const currentDate = new Date('2024-04-22'); // Monday
|
|
66
|
-
|
|
67
|
-
const enabledWeekDays: number[] = []; // No days enabled
|
|
68
|
-
const disabledDates: Date[] = [];
|
|
69
|
-
|
|
70
|
-
const result = findNextAvailableDate(currentDate, enabledWeekDays, disabledDates);
|
|
71
|
-
expect(result).toBeNull();
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('should handle empty disabledDates', () => {
|
|
75
|
-
const currentDate = new Date('2024-04-22'); // Monday
|
|
76
|
-
const enabledWeekDays = [1, 2, 3, 4, 5];
|
|
77
|
-
const disabledDates: Date[] = [];
|
|
78
|
-
|
|
79
|
-
const result = findNextAvailableDate(currentDate, enabledWeekDays, disabledDates);
|
|
80
|
-
expect(result).toEqual(currentDate);
|
|
81
|
-
});
|
|
82
|
-
});
|