@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,31 +0,0 @@
|
|
|
1
|
-
import type { GetCdnUrl, InstanceMapper, Transformation, TransformationQueries } from '../types';
|
|
2
|
-
|
|
3
|
-
const DEFAULT_THUMBNAIL_CONFIG: Transformation = {
|
|
4
|
-
width: 300,
|
|
5
|
-
height: 300,
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
type FactoryConfig = {
|
|
9
|
-
domain: `https://${string}`;
|
|
10
|
-
instanceMapper: InstanceMapper;
|
|
11
|
-
transformationQueries: TransformationQueries;
|
|
12
|
-
cacheVersion?: number;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const genCacheVersionQuery = (cacheVersion?: number) => (cacheVersion ? `v=${cacheVersion}` : '');
|
|
16
|
-
|
|
17
|
-
export const getCdnUrlFactory =
|
|
18
|
-
(config: FactoryConfig): GetCdnUrl =>
|
|
19
|
-
(instanceId, path, params = {}) => {
|
|
20
|
-
const { domain, instanceMapper, transformationQueries, cacheVersion } = config;
|
|
21
|
-
|
|
22
|
-
const { transformation = params.asThumbnail ? DEFAULT_THUMBNAIL_CONFIG : {} } = params;
|
|
23
|
-
|
|
24
|
-
const transformationQuery: string = transformationQueries(transformation);
|
|
25
|
-
const cacheVersionQuery = genCacheVersionQuery(cacheVersion);
|
|
26
|
-
const hasQueryParams = [transformationQuery, cacheVersionQuery].some((query) => query !== '');
|
|
27
|
-
|
|
28
|
-
return `${domain}${instanceMapper(instanceId)}${path}${hasQueryParams ? '?' : ''}${transformationQuery}${
|
|
29
|
-
cacheVersionQuery ? `&${cacheVersionQuery}` : ''
|
|
30
|
-
}`;
|
|
31
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { TwicpicsTransformationChain } from '../types';
|
|
2
|
-
|
|
3
|
-
export const twicpicsTransformationChainToString = (transformationChain: TwicpicsTransformationChain): string => {
|
|
4
|
-
if (transformationChain.length === 0) return '';
|
|
5
|
-
|
|
6
|
-
const transformations = transformationChain.map(([key, value]) => `${key}=${value}`).join('/');
|
|
7
|
-
|
|
8
|
-
return `twic=v1/${transformations}`;
|
|
9
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { type GameType } from '../business/types';
|
|
2
|
-
|
|
3
|
-
const DOLPHIN_CHRONO_GAMEPLAY = {
|
|
4
|
-
mcq: 27 * 1000,
|
|
5
|
-
'error-text': 27 * 1000,
|
|
6
|
-
'no-interaction': 20000,
|
|
7
|
-
'picture-spot': 15 * 1000,
|
|
8
|
-
'open-question': 73 * 1000,
|
|
9
|
-
'swiping-cards': 15 * 1000,
|
|
10
|
-
'ordering-cards': 20 * 1000 + 10000,
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const DOLPHIN_AVERAGE_CHRONO_GAMEPLAY =
|
|
14
|
-
Object.values(DOLPHIN_CHRONO_GAMEPLAY).reduce<number>((sum, time) => sum + time, 0) /
|
|
15
|
-
Object.keys(DOLPHIN_CHRONO_GAMEPLAY).length;
|
|
16
|
-
|
|
17
|
-
export const getApproximatedSessionTime = (gameTypes: GameType[]) => {
|
|
18
|
-
const time = gameTypes.reduce<number>((sessionTime, gameType) => {
|
|
19
|
-
const gameplayTime = DOLPHIN_CHRONO_GAMEPLAY[gameType];
|
|
20
|
-
|
|
21
|
-
return sessionTime + gameplayTime;
|
|
22
|
-
}, 0);
|
|
23
|
-
|
|
24
|
-
return time;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const getAverageSessionTime = (gameCount: number) => gameCount * DOLPHIN_AVERAGE_CHRONO_GAMEPLAY;
|
package/src/chrono/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './get-approximated-session-time';
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { getContrastColor } from '../get-contrast-color';
|
|
2
|
-
|
|
3
|
-
describe('getContrastColor', () => {
|
|
4
|
-
const customLight = '#f18888';
|
|
5
|
-
const customDark = '#051831';
|
|
6
|
-
|
|
7
|
-
it('should return the default light color', () => {
|
|
8
|
-
expect(getContrastColor('#000000')).toBe('#FFFFFF');
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it('should return the default dark color', () => {
|
|
12
|
-
expect(getContrastColor('#FFFFFF')).toBe('#000000');
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('should return a specified light color', () => {
|
|
16
|
-
expect(getContrastColor('#000000', customLight, customDark)).toBe(customLight);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('should return a specified dark color', () => {
|
|
20
|
-
expect(getContrastColor('#FFFFFF', customLight, customDark)).toBe(customDark);
|
|
21
|
-
});
|
|
22
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
const DEFAULT_LIGHT_COLOR = '#FFFFFF';
|
|
2
|
-
const DEFAULT_DARK_COLOR = '#000000';
|
|
3
|
-
|
|
4
|
-
// Based on https://stackoverflow.com/questions/11867545/change-text-color-based-on-brightness-of-the-covered-background-area
|
|
5
|
-
export const getContrastColor = (bgColor: string, lightColor: string = DEFAULT_LIGHT_COLOR, darkColor: string = DEFAULT_DARK_COLOR): string => {
|
|
6
|
-
const color = bgColor.charAt(0) === '#' ? bgColor.substring(1, 7) : bgColor;
|
|
7
|
-
|
|
8
|
-
if (color.length !== 6) {
|
|
9
|
-
throw new Error(`Invalid HEX color "${bgColor}" in sparted mail manager.`);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const r = parseInt(color.substring(0, 2), 16); // hexToR
|
|
13
|
-
const g = parseInt(color.substring(2, 4), 16); // hexToG
|
|
14
|
-
const b = parseInt(color.substring(4, 6), 16); // hexToB
|
|
15
|
-
|
|
16
|
-
// Values from https://www.w3.org/TR/AERT/#color-contrast
|
|
17
|
-
return r * 0.299 + g * 0.587 + b * 0.114 > 186 ? darkColor : lightColor;
|
|
18
|
-
};
|
package/src/color/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './get-contrast-color';
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { encrypt } from '../aes256';
|
|
2
|
-
|
|
3
|
-
const key = '6fa979f20126cb08aa645a8f495f6d856fa979f20126cb08aa645a8f495f6d85';
|
|
4
|
-
const iv = '49387a7941346c56684d43614a354b67';
|
|
5
|
-
|
|
6
|
-
const data = '111222333';
|
|
7
|
-
|
|
8
|
-
describe('aes-256-cbc', () => {
|
|
9
|
-
describe('encrypt', () => {
|
|
10
|
-
it('should match the expected cipher', () => {
|
|
11
|
-
const result = encrypt(data, key, iv);
|
|
12
|
-
expect(result).toBe('56457610927dc4923e2aa34cc2a79382');
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('should fail if the key is not 256 bits long', () => {
|
|
16
|
-
expect(() => encrypt(data, 'short-key', iv)).toThrow();
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('should fail if the iv is not 32 characters long', () => {
|
|
20
|
-
expect(() => encrypt(data, key, 'short-iv')).toThrow();
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
});
|
package/src/crypto/aes256.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { encrypt as cryptoEncrypt } from 'crypto-js/aes';
|
|
2
|
-
import { enc, mode, pad } from 'crypto-js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Encrypt data using AES-256-CBC
|
|
6
|
-
* @param data
|
|
7
|
-
* @param key Must be a 256 bits hex string
|
|
8
|
-
* @param iv Must be a 128 bits hex string
|
|
9
|
-
* @returns Encrypted data as a hex string
|
|
10
|
-
*/
|
|
11
|
-
function encrypt(data: string, key: string, iv: string): string {
|
|
12
|
-
if (key.length !== 64) throw new Error('Key must be 256 bits long');
|
|
13
|
-
if (iv.length !== 32) throw new Error('IV must be 128 bits long');
|
|
14
|
-
const cipher = cryptoEncrypt(data, enc.Hex.parse(key), {
|
|
15
|
-
mode: mode.CBC,
|
|
16
|
-
padding: pad.Pkcs7,
|
|
17
|
-
iv: enc.Hex.parse(iv),
|
|
18
|
-
});
|
|
19
|
-
return enc.Hex.stringify(cipher.ciphertext);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export { encrypt };
|
package/src/crypto/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { encrypt } from './aes256';
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { getIsoDayNumber } from '../get-iso-day-number';
|
|
2
|
-
|
|
3
|
-
describe('getIsoDayNumber', () => {
|
|
4
|
-
it('returns 1..7 for Monday..Sunday', () => {
|
|
5
|
-
const cases: Array<[Date, number]> = [
|
|
6
|
-
[new Date(2023, 7, 7, 12, 0, 0), 1], // Monday 2023-08-07
|
|
7
|
-
[new Date(2023, 7, 8, 12, 0, 0), 2], // Tuesday
|
|
8
|
-
[new Date(2023, 7, 9, 12, 0, 0), 3], // Wednesday
|
|
9
|
-
[new Date(2023, 7, 10, 12, 0, 0), 4], // Thursday
|
|
10
|
-
[new Date(2023, 7, 11, 12, 0, 0), 5], // Friday
|
|
11
|
-
[new Date(2023, 7, 12, 12, 0, 0), 6], // Saturday
|
|
12
|
-
[new Date(2023, 7, 13, 12, 0, 0), 7], // Sunday
|
|
13
|
-
];
|
|
14
|
-
|
|
15
|
-
for (const [date, expected] of cases) {
|
|
16
|
-
expect(getIsoDayNumber(date)).toBe(expected);
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('does not modify the original date', () => {
|
|
21
|
-
const date = new Date(2023, 7, 9, 12, 34, 56);
|
|
22
|
-
const originalTime = date.getTime();
|
|
23
|
-
getIsoDayNumber(date);
|
|
24
|
-
expect(date.getTime()).toBe(originalTime);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('uses current date when no argument is provided', () => {
|
|
28
|
-
jest.useFakeTimers().setSystemTime(new Date(2023, 7, 7, 12, 0, 0)); // Monday
|
|
29
|
-
expect(getIsoDayNumber()).toBe(1);
|
|
30
|
-
jest.useRealTimers();
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { getRemainingTimeFromMs, getRemainingTimeInMsFromDate } from '../get-remaining-time';
|
|
2
|
-
|
|
3
|
-
describe('getRemainingTimeInMsFromDate', () => {
|
|
4
|
-
it('should return 0 if the argument passed is not an instance of Date', () => {
|
|
5
|
-
expect(getRemainingTimeInMsFromDate('2024-12-01' as any)).toBe(0);
|
|
6
|
-
expect(getRemainingTimeInMsFromDate(null as any)).toBe(0);
|
|
7
|
-
expect(getRemainingTimeInMsFromDate(undefined as any)).toBe(0);
|
|
8
|
-
expect(getRemainingTimeInMsFromDate(123 as any)).toBe(0);
|
|
9
|
-
expect(getRemainingTimeInMsFromDate({} as any)).toBe(0);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('should return 0 if the date is in the past', () => {
|
|
13
|
-
const pastDate = new Date(Date.now() - 1000);
|
|
14
|
-
expect(getRemainingTimeInMsFromDate(pastDate)).toBe(0);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('should return the remaining time in milliseconds if the date is in the future', () => {
|
|
18
|
-
const futureDate = new Date(Date.now() + 5000);
|
|
19
|
-
const remainingTime = getRemainingTimeInMsFromDate(futureDate);
|
|
20
|
-
|
|
21
|
-
expect(remainingTime).toBe(5000);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('should return 0 if the date is exactly at the present moment', () => {
|
|
25
|
-
const currentTime = Date.now();
|
|
26
|
-
const presentDate = new Date(currentTime);
|
|
27
|
-
|
|
28
|
-
jest.spyOn(global.Date, 'now').mockReturnValue(currentTime);
|
|
29
|
-
|
|
30
|
-
const remainingTime = getRemainingTimeInMsFromDate(presentDate);
|
|
31
|
-
expect(remainingTime).toBe(0);
|
|
32
|
-
|
|
33
|
-
jest.restoreAllMocks();
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
describe('getRemainingTimeFromMs', () => {
|
|
38
|
-
it('should return correct time for a full day (86400000 ms)', () => {
|
|
39
|
-
const result = getRemainingTimeFromMs(86400000);
|
|
40
|
-
expect(result).toEqual({ daysLeft: 1, hoursLeft: 0, minutesLeft: 0, secondsLeft: 0 });
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('should return correct time for one hour (3600000 ms)', () => {
|
|
44
|
-
const result = getRemainingTimeFromMs(3600000);
|
|
45
|
-
expect(result).toEqual({ daysLeft: 0, hoursLeft: 1, minutesLeft: 0, secondsLeft: 0 });
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('should return correct time for one minute (60000 ms)', () => {
|
|
49
|
-
const result = getRemainingTimeFromMs(60000);
|
|
50
|
-
expect(result).toEqual({ daysLeft: 0, hoursLeft: 0, minutesLeft: 1, secondsLeft: 0 });
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('should return correct time for one second (1000 ms)', () => {
|
|
54
|
-
const result = getRemainingTimeFromMs(1000);
|
|
55
|
-
expect(result).toEqual({ daysLeft: 0, hoursLeft: 0, minutesLeft: 0, secondsLeft: 1 });
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('should return correct time for a combination of days, hours, minutes, and seconds', () => {
|
|
59
|
-
const ms = 90061000; // 1 day, 1 hour, 1 minute, 1 second
|
|
60
|
-
const result = getRemainingTimeFromMs(ms);
|
|
61
|
-
expect(result).toEqual({ daysLeft: 1, hoursLeft: 1, minutesLeft: 1, secondsLeft: 1 });
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('should return zero for all fields when ms is 0', () => {
|
|
65
|
-
const result = getRemainingTimeFromMs(0);
|
|
66
|
-
expect(result).toEqual({ daysLeft: 0, hoursLeft: 0, minutesLeft: 0, secondsLeft: 0 });
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('should handle non-integer values gracefully', () => {
|
|
70
|
-
const result = getRemainingTimeFromMs(1234567); // 0 days, 0 hours, 20 minutes, 34 seconds
|
|
71
|
-
expect(result).toEqual({ daysLeft: 0, hoursLeft: 0, minutesLeft: 20, secondsLeft: 34 });
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('should return zero for negative input', () => {
|
|
75
|
-
const result = getRemainingTimeFromMs(-1000);
|
|
76
|
-
expect(result).toEqual({ daysLeft: 0, hoursLeft: 0, minutesLeft: 0, secondsLeft: 0 });
|
|
77
|
-
});
|
|
78
|
-
});
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { startOfDay, startOfDayLocal } from '../get-start-of-day';
|
|
2
|
-
|
|
3
|
-
describe('startOfDay', () => {
|
|
4
|
-
it('should set the time of a date to 00:00:00 in local timezone', () => {
|
|
5
|
-
const date = new Date('2023-08-09T12:34:56');
|
|
6
|
-
const result = startOfDay(date);
|
|
7
|
-
const expected = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0));
|
|
8
|
-
expect(result.getTime()).toBe(expected.getTime());
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it('should not modify the original date object', () => {
|
|
12
|
-
const date = new Date('2023-08-09T12:34:56');
|
|
13
|
-
const originalTime = date.getTime();
|
|
14
|
-
startOfDay(date);
|
|
15
|
-
expect(date.getTime()).toBe(originalTime);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('should handle dates already at the start of the day', () => {
|
|
19
|
-
const date = new Date('2023-08-09T00:00:00');
|
|
20
|
-
const dateUTC = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
|
|
21
|
-
const result = startOfDay(dateUTC);
|
|
22
|
-
expect(result.getTime()).toBe(dateUTC.getTime());
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('should correctly handle leap year dates in local timezone', () => {
|
|
26
|
-
const date = new Date('2020-02-29T15:45:30');
|
|
27
|
-
const result = startOfDay(date);
|
|
28
|
-
const expected = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
|
|
29
|
-
expect(result.getTime()).toBe(expected.getTime());
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('should handle year boundaries correctly in local timezone', () => {
|
|
33
|
-
const date = new Date('2023-12-31T23:59:59');
|
|
34
|
-
const result = startOfDay(date);
|
|
35
|
-
const expected = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
|
|
36
|
-
expect(result.getTime()).toBe(expected.getTime());
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('should handle month boundaries correctly in local timezone', () => {
|
|
40
|
-
const date = new Date('2023-08-31T23:59:59');
|
|
41
|
-
const result = startOfDay(date);
|
|
42
|
-
const expected = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
|
|
43
|
-
expect(result.getTime()).toBe(expected.getTime());
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
describe('startOfDayLocal', () => {
|
|
48
|
-
it('should set the time of a date to 00:00:00 in local timezone', () => {
|
|
49
|
-
const date = new Date('2023-08-09T12:34:56');
|
|
50
|
-
const result = startOfDayLocal(date);
|
|
51
|
-
const expected = new Date(date);
|
|
52
|
-
expected.setHours(0, 0, 0, 0);
|
|
53
|
-
expect(result.getTime()).toBe(expected.getTime());
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('should not modify the original date object', () => {
|
|
57
|
-
const date = new Date('2023-08-09T12:34:56');
|
|
58
|
-
const originalTime = date.getTime();
|
|
59
|
-
startOfDayLocal(date);
|
|
60
|
-
expect(date.getTime()).toBe(originalTime);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('should handle dates already at the start of the day', () => {
|
|
64
|
-
const date = new Date(2023, 7, 9, 0, 0, 0, 0);
|
|
65
|
-
const result = startOfDayLocal(date);
|
|
66
|
-
expect(result.getTime()).toBe(date.getTime());
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('should correctly handle leap year dates in local timezone', () => {
|
|
70
|
-
const date = new Date(2020, 1, 29, 15, 45, 30);
|
|
71
|
-
const result = startOfDayLocal(date);
|
|
72
|
-
const expected = new Date(date);
|
|
73
|
-
expected.setHours(0, 0, 0, 0);
|
|
74
|
-
expect(result.getTime()).toBe(expected.getTime());
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('should handle year boundaries correctly in local timezone', () => {
|
|
78
|
-
const date = new Date(2023, 11, 31, 23, 59, 59);
|
|
79
|
-
const result = startOfDayLocal(date);
|
|
80
|
-
const expected = new Date(date);
|
|
81
|
-
expected.setHours(0, 0, 0, 0);
|
|
82
|
-
expect(result.getTime()).toBe(expected.getTime());
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('should handle month boundaries correctly in local timezone', () => {
|
|
86
|
-
const date = new Date(2023, 7, 31, 23, 59, 59);
|
|
87
|
-
const result = startOfDayLocal(date);
|
|
88
|
-
const expected = new Date(date);
|
|
89
|
-
expected.setHours(0, 0, 0, 0);
|
|
90
|
-
expect(result.getTime()).toBe(expected.getTime());
|
|
91
|
-
});
|
|
92
|
-
});
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { isSameDate } from '../is-same-date';
|
|
2
|
-
|
|
3
|
-
describe('isSameDate', () => {
|
|
4
|
-
it('should return true for the same date with same time zones', () => {
|
|
5
|
-
const date1 = new Date('2023-08-09T12:00:00+02:00'); // 9 August 2023
|
|
6
|
-
const date2 = new Date('2023-08-09T12:00:00+02:00'); // 9 August 2023
|
|
7
|
-
expect(isSameDate(date1, date2)).toBe(true);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('should return true for the same date across different time zones', () => {
|
|
11
|
-
const date1 = new Date('2023-08-09T23:00:00+00:00'); // 9 August 2023 UTC
|
|
12
|
-
const date2 = new Date('2023-08-10T01:00:00+02:00'); // 10 August 2023 UTC+2, but still 9 August in UTC
|
|
13
|
-
expect(isSameDate(date1, date2)).toBe(true);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('should return true for the same plain date', () => {
|
|
17
|
-
const date1 = new Date(2023, 7, 9); // 9 August 2023
|
|
18
|
-
const date2 = new Date(2023, 7, 9); // 9 August 2023
|
|
19
|
-
expect(isSameDate(date1, date2)).toBe(true);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('should return false for different dates across different time zones', () => {
|
|
23
|
-
const date1 = new Date('2023-08-09T23:00:00+00:00'); // 9 August 2023 UTC
|
|
24
|
-
const date2 = new Date('2023-08-10T02:00:00+02:00'); // 10 August 2023 UTC+2, also 10 August in UTC
|
|
25
|
-
expect(isSameDate(date1, date2)).toBe(false);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('should return false for different dates in the same time zone', () => {
|
|
29
|
-
const date1 = new Date('2023-08-09T12:00:00+02:00'); // 9 August 2023 UTC+2
|
|
30
|
-
const date2 = new Date('2023-08-10T12:00:00+02:00'); // 10 August 2023 UTC+2
|
|
31
|
-
expect(isSameDate(date1, date2)).toBe(false);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('should return false for different plain dates', () => {
|
|
35
|
-
const date1 = new Date(2023, 7, 9); // 9 August 2023
|
|
36
|
-
const date2 = new Date(2023, 7, 10); // 10 August 2023
|
|
37
|
-
expect(isSameDate(date1, date2)).toBe(false);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('should return true when comparing the same date with itself', () => {
|
|
41
|
-
const date = new Date('2023-08-09T12:00:00+02:00'); // 9 August 2023
|
|
42
|
-
expect(isSameDate(date, date)).toBe(true);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('should return false if one of the dates is invalid', () => {
|
|
46
|
-
const date1 = new Date('Invalid Date');
|
|
47
|
-
const date2 = new Date('2023-08-09T12:00:00+02:00'); // 9 August 2023
|
|
48
|
-
expect(isSameDate(date1, date2)).toBe(false);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { shiftDateBy } from '../shift-date-by';
|
|
2
|
-
|
|
3
|
-
describe('shiftDateBy', () => {
|
|
4
|
-
test('should add days, hours, minutes, and seconds to a given date', () => {
|
|
5
|
-
const initialDate = new Date('2024-11-14T00:00:00Z');
|
|
6
|
-
const options = { days: 1, hours: 2, minutes: 30, seconds: 45 };
|
|
7
|
-
const result = shiftDateBy(options, initialDate);
|
|
8
|
-
expect(result.toISOString()).toBe('2024-11-15T02:30:45.000Z');
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
test('should remove days, hours, minutes, and seconds to a given date', () => {
|
|
12
|
-
const initialDate = new Date('2024-11-14T00:00:00Z');
|
|
13
|
-
const options = { days: -1, hours: -2, minutes: -30, seconds: -45 };
|
|
14
|
-
const result = shiftDateBy(options, initialDate);
|
|
15
|
-
expect(result.toISOString()).toBe('2024-11-12T21:29:15.000Z');
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
test('should handle adding only days to a date', () => {
|
|
19
|
-
const initialDate = new Date('2024-11-14T00:00:00Z');
|
|
20
|
-
const result = shiftDateBy({ days: 5 }, initialDate);
|
|
21
|
-
expect(result.toISOString()).toBe('2024-11-19T00:00:00.000Z');
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test('should handle removing only days to a date', () => {
|
|
25
|
-
const initialDate = new Date('2024-11-14T00:00:00Z');
|
|
26
|
-
const result = shiftDateBy({ days: -5 }, initialDate);
|
|
27
|
-
expect(result.toISOString()).toBe('2024-11-09T00:00:00.000Z');
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test('should handle adding only hours to a date', () => {
|
|
31
|
-
const initialDate = new Date('2024-11-14T00:00:00Z');
|
|
32
|
-
const result = shiftDateBy({ hours: 3 }, initialDate);
|
|
33
|
-
expect(result.toISOString()).toBe('2024-11-14T03:00:00.000Z');
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
test('should handle removing only hours to a date', () => {
|
|
37
|
-
const initialDate = new Date('2024-11-14T00:00:00Z');
|
|
38
|
-
const result = shiftDateBy({ hours: -3 }, initialDate);
|
|
39
|
-
expect(result.toISOString()).toBe('2024-11-13T21:00:00.000Z');
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
test('should handle adding only minutes to a date', () => {
|
|
43
|
-
const initialDate = new Date('2024-11-14T00:00:00Z');
|
|
44
|
-
const result = shiftDateBy({ minutes: 45 }, initialDate);
|
|
45
|
-
expect(result.toISOString()).toBe('2024-11-14T00:45:00.000Z');
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test('should handle removing only minutes to a date', () => {
|
|
49
|
-
const initialDate = new Date('2024-11-14T00:00:00Z');
|
|
50
|
-
const result = shiftDateBy({ minutes: -45 }, initialDate);
|
|
51
|
-
expect(result.toISOString()).toBe('2024-11-13T23:15:00.000Z');
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
test('should handle adding only seconds to a date', () => {
|
|
55
|
-
const initialDate = new Date('2024-11-14T00:00:00Z');
|
|
56
|
-
const result = shiftDateBy({ seconds: 30 }, initialDate);
|
|
57
|
-
expect(result.toISOString()).toBe('2024-11-14T00:00:30.000Z');
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
test('should handle removing only seconds to a date', () => {
|
|
61
|
-
const initialDate = new Date('2024-11-14T00:00:00Z');
|
|
62
|
-
const result = shiftDateBy({ seconds: -30 }, initialDate);
|
|
63
|
-
expect(result.toISOString()).toBe('2024-11-13T23:59:30.000Z');
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
test('should return the same date if no options are provided', () => {
|
|
67
|
-
const initialDate = new Date('2024-11-14T00:00:00Z');
|
|
68
|
-
const result = shiftDateBy({}, initialDate);
|
|
69
|
-
expect(result.toISOString()).toBe('2024-11-14T00:00:00.000Z');
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
test('should return the current date if nothing is provided', () => {
|
|
73
|
-
const result = shiftDateBy();
|
|
74
|
-
expect(result.getTime()).toBeCloseTo(new Date().getTime(), -3);
|
|
75
|
-
});
|
|
76
|
-
});
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { toUTCDateString } from '../to-utc-date-string';
|
|
2
|
-
|
|
3
|
-
describe('toUTCDateString', () => {
|
|
4
|
-
it('should convert a date to UTC date string (same day)', () => {
|
|
5
|
-
const date = new Date('2023-08-09T12:00:00+02:00');
|
|
6
|
-
expect(toUTCDateString(date)).toBe('2023-08-09');
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
it('should convert a date to UTC date string (crossing midnight)', () => {
|
|
10
|
-
const date = new Date('2023-08-09T23:00:00+02:00');
|
|
11
|
-
expect(toUTCDateString(date)).toBe('2023-08-09');
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('should handle dates in UTC correctly', () => {
|
|
15
|
-
const date = new Date('2023-08-09T00:00:00+00:00');
|
|
16
|
-
expect(toUTCDateString(date)).toBe('2023-08-09');
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('should convert a date at the end of a day to correct UTC date string', () => {
|
|
20
|
-
const date = new Date('2023-08-09T23:59:59+02:00');
|
|
21
|
-
expect(toUTCDateString(date)).toBe('2023-08-09');
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('should handle a leap year date', () => {
|
|
25
|
-
const date = new Date('2020-02-29T12:00:00+00:00');
|
|
26
|
-
expect(toUTCDateString(date)).toBe('2020-02-29');
|
|
27
|
-
});
|
|
28
|
-
});
|
package/src/date/add-days.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export const differenceInDays = (start: Date, end: Date): number => {
|
|
2
|
-
const msPerDay = 24 * 60 * 60 * 1000;
|
|
3
|
-
const utcStart = Date.UTC(start.getFullYear(), start.getMonth(), start.getDate());
|
|
4
|
-
const utcEnd = Date.UTC(end.getFullYear(), end.getMonth(), end.getDate());
|
|
5
|
-
return Math.floor((utcEnd - utcStart) / msPerDay);
|
|
6
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const getIsoDayNumber = (date = new Date()) => ((date.getDay() + 6) % 7) + 1;
|
package/src/date/get-next-day.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export const getRemainingTimeInMsFromDate = (date: Date): number => {
|
|
2
|
-
if (!(date instanceof Date)) return 0;
|
|
3
|
-
|
|
4
|
-
const endTime = date.getTime();
|
|
5
|
-
const currentTime = Date.now();
|
|
6
|
-
const diff = endTime - currentTime;
|
|
7
|
-
return Math.max(0, diff);
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const getRemainingTimeFromMs = (
|
|
11
|
-
ms: number,
|
|
12
|
-
): { daysLeft: number; hoursLeft: number; minutesLeft: number; secondsLeft: number } => {
|
|
13
|
-
const daysLeft = Math.floor(ms / 86400000);
|
|
14
|
-
const hoursLeft = Math.floor((ms % 86400000) / 3600000);
|
|
15
|
-
const minutesLeft = Math.floor((ms % 3600000) / 60000);
|
|
16
|
-
const secondsLeft = Math.floor((ms % 60000) / 1000);
|
|
17
|
-
|
|
18
|
-
return {
|
|
19
|
-
daysLeft: Math.max(0, daysLeft),
|
|
20
|
-
hoursLeft: Math.max(0, hoursLeft),
|
|
21
|
-
minutesLeft: Math.max(0, minutesLeft),
|
|
22
|
-
secondsLeft: Math.max(0, secondsLeft),
|
|
23
|
-
};
|
|
24
|
-
};
|
package/src/date/index.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from './is-same-date';
|
|
2
|
-
export * from './to-plain-date-string';
|
|
3
|
-
export * from './get-next-day';
|
|
4
|
-
export * from './get-remaining-time';
|
|
5
|
-
export * from './shift-date-by';
|
|
6
|
-
export * from './difference-in-days';
|
|
7
|
-
export * from './add-days';
|
|
8
|
-
export * from './get-start-of-day';
|
|
9
|
-
export * from './to-utc-date-string';
|
|
10
|
-
export * from './get-iso-day-number';
|
package/src/date/is-same-date.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
type TimeShifts = {
|
|
2
|
-
days?: number;
|
|
3
|
-
hours?: number;
|
|
4
|
-
minutes?: number;
|
|
5
|
-
seconds?: number;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export const shiftDateBy = (shifts: TimeShifts = {}, date: Date = new Date()): Date => {
|
|
9
|
-
const { days = 0, hours = 0, minutes = 0, seconds = 0 } = shifts;
|
|
10
|
-
return new Date(
|
|
11
|
-
date.getTime() +
|
|
12
|
-
days * 86400000 + // 1 day = 86 400 000 ms
|
|
13
|
-
hours * 3600000 + // 1 hour = 3 600 000 ms
|
|
14
|
-
minutes * 60000 + // 1 minute = 60 000 ms
|
|
15
|
-
seconds * 1000, // 1 second = 1 000 ms
|
|
16
|
-
);
|
|
17
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const toPlainDateString = (date: Date): string => date.toISOString().split('T')[0];
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { formatNumber } from '../format-number';
|
|
2
|
-
|
|
3
|
-
describe('formatNumber', () => {
|
|
4
|
-
it('should format numbers correctly', () => {
|
|
5
|
-
expect(formatNumber(48)).toBe('48');
|
|
6
|
-
expect(formatNumber(999)).toBe('999');
|
|
7
|
-
expect(formatNumber(1000)).toBe('1.0k');
|
|
8
|
-
expect(formatNumber(42869)).toBe('42.8k');
|
|
9
|
-
expect(formatNumber(992169)).toBe('992.1k');
|
|
10
|
-
});
|
|
11
|
-
});
|