@sparted/shared-library 1.9.5 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{dist/business → business}/campaign/live-campaign.js +4 -4
- package/business/campaign/live-campaign.js.map +1 -0
- package/{dist/business → business}/types/content.d.ts +23 -0
- package/{dist/date → date}/difference-in-days.js +3 -2
- package/date/difference-in-days.js.map +1 -0
- package/date/get-next-day.js +11 -0
- package/date/get-next-day.js.map +1 -0
- package/{dist/date → date}/index.d.ts +1 -0
- package/{dist/date → date}/index.js +2 -0
- package/date/index.js.map +1 -0
- package/date/to-local-date-string.d.ts +1 -0
- package/{dist/date/to-utc-date-string.js → date/to-local-date-string.js} +3 -3
- package/date/to-local-date-string.js.map +1 -0
- package/date/to-utc-date-string.js +10 -0
- package/date/to-utc-date-string.js.map +1 -0
- package/{dist/index.js → index.js} +2 -0
- package/{dist/index.js.map → index.js.map} +1 -1
- package/package.json +5 -7
- 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/business/campaign/live-campaign.js.map +0 -1
- package/dist/date/difference-in-days.js.map +0 -1
- package/dist/date/get-next-day.js +0 -12
- package/dist/date/get-next-day.js.map +0 -1
- package/dist/date/index.js.map +0 -1
- package/dist/date/to-utc-date-string.js.map +0 -1
- 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}/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.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}/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-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}/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/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/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
package/src/promise/delay.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export type ExecutionConfig<Default> = {
|
|
2
|
-
execute: boolean,
|
|
3
|
-
defaultValue: Default,
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
export const executeOrResolveDefault = <T, Default>(callback: () => Promise<T>, config: ExecutionConfig<Default>): Promise<T | Default> => {
|
|
7
|
-
const { execute, defaultValue } = config;
|
|
8
|
-
|
|
9
|
-
if (execute) {
|
|
10
|
-
return callback();
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
return Promise.resolve(defaultValue);
|
|
14
|
-
};
|
package/src/promise/index.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { isStringLengthWithinRange } from '../is-string-length-within-range';
|
|
2
|
-
|
|
3
|
-
describe('isStringLengthWithinRange', () => {
|
|
4
|
-
it('should return true if the length is within the range', () => {
|
|
5
|
-
expect(isStringLengthWithinRange({ min: 1, max: 10 }, 'a'.repeat(5))).toBe(true);
|
|
6
|
-
expect(isStringLengthWithinRange({ min: 1, max: 10 }, 'a'.repeat(1))).toBe(true);
|
|
7
|
-
expect(isStringLengthWithinRange({ min: 1, max: 10 }, 'a'.repeat(10))).toBe(true);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('should return false if the length is not within the range', () => {
|
|
11
|
-
expect(isStringLengthWithinRange({ min: 1, max: 10 }, 'a'.repeat(20))).toBe(false);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('should handle undefined string', () => {
|
|
15
|
-
expect(isStringLengthWithinRange({ min: 1, max: 10 })).toBe(false);
|
|
16
|
-
expect(isStringLengthWithinRange({ min: 0, max: 10 })).toBe(true);
|
|
17
|
-
expect(isStringLengthWithinRange({ min: -10, max: -1 })).toBe(false);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('should throw an error if the range is invalid', () => {
|
|
21
|
-
expect(() => isStringLengthWithinRange({ min: 10, max: 1 })).toThrowError('Invalid range');
|
|
22
|
-
})
|
|
23
|
-
});
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { replaceInTemplate } from '../replace-in-template';
|
|
2
|
-
|
|
3
|
-
describe('replaceInTemplate', () => {
|
|
4
|
-
it('should inject the params object into the template with the default config', () => {
|
|
5
|
-
const template = 'You need to wait {{time}} minutes before ordering on {{deliveryService}} again';
|
|
6
|
-
const message = replaceInTemplate(template, {
|
|
7
|
-
time: 5,
|
|
8
|
-
deliveryService: 'Uber Eat',
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
expect(message).toStrictEqual('You need to wait 5 minutes before ordering on Uber Eat again');
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('should handle if there is a primitive array in params', () => {
|
|
15
|
-
const template = 'Grocery: {{groceries}}';
|
|
16
|
-
const message = replaceInTemplate(template, {
|
|
17
|
-
groceries: [
|
|
18
|
-
'Twix',
|
|
19
|
-
'Oasis',
|
|
20
|
-
'm&ms',
|
|
21
|
-
],
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
expect(message).toStrictEqual('Grocery: Twix, Oasis, m&ms');
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('should ignore non primitive values', () => {
|
|
28
|
-
const template = 'City: {{city}}, population: {{population}}';
|
|
29
|
-
const message = replaceInTemplate(template, {
|
|
30
|
-
city: 'Washington D.C.',
|
|
31
|
-
population: {
|
|
32
|
-
value: 12000000,
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
expect(message).toStrictEqual('City: Washington D.C., population: {{population}}');
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('should handle custom delimiter', () => {
|
|
40
|
-
const template = 'ISO |iso|, |focalLength| mm, f/|aperture|';
|
|
41
|
-
const params = {
|
|
42
|
-
iso: 100,
|
|
43
|
-
focalLength: 50,
|
|
44
|
-
aperture: '2.8',
|
|
45
|
-
};
|
|
46
|
-
const message = replaceInTemplate(template, params, {
|
|
47
|
-
delimiter: '|',
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
expect(message).toStrictEqual('ISO 100, 50 mm, f/2.8');
|
|
51
|
-
});
|
|
52
|
-
});
|
package/src/string/index.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Range } from '../types/general';
|
|
2
|
-
|
|
3
|
-
export const isStringLengthWithinRange = (range: Range, str?: string) => {
|
|
4
|
-
if (range.min > range.max) {
|
|
5
|
-
throw new Error('Invalid range');
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const strLength = str?.length || 0;
|
|
9
|
-
return strLength >= (range.min || 0) && strLength <= range.max;
|
|
10
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { isArrayOfPrimitive, isPrimitive } from '../predicates';
|
|
2
|
-
|
|
3
|
-
export type ReplaceConfig = {
|
|
4
|
-
delimiter: string | {
|
|
5
|
-
left: string,
|
|
6
|
-
right: string,
|
|
7
|
-
},
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const defaultConfig: ReplaceConfig = {
|
|
11
|
-
delimiter: {
|
|
12
|
-
left: '{{',
|
|
13
|
-
right: '}}',
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Replace string inside a template. For now, only works with
|
|
19
|
-
* an object containing promirives or array of primitives. If
|
|
20
|
-
* it contains other objects, they will be ignored.
|
|
21
|
-
*
|
|
22
|
-
* Uses the mustache syntax by default.
|
|
23
|
-
*/
|
|
24
|
-
export const replaceInTemplate = (
|
|
25
|
-
template: string,
|
|
26
|
-
params: Record<string, any>,
|
|
27
|
-
config: ReplaceConfig = defaultConfig,
|
|
28
|
-
) => {
|
|
29
|
-
const { delimiter } = config;
|
|
30
|
-
const leftDelimiter = typeof delimiter === 'string' ? delimiter : delimiter.left;
|
|
31
|
-
const rightDelimiter = typeof delimiter === 'string' ? delimiter : delimiter.right;
|
|
32
|
-
|
|
33
|
-
return Object
|
|
34
|
-
.entries(params)
|
|
35
|
-
.reduce((acc, [key, value]) => {
|
|
36
|
-
if (!isPrimitive(value) && !isArrayOfPrimitive(value)) {
|
|
37
|
-
return acc;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const searchValue = `${leftDelimiter}${key}${rightDelimiter}`;
|
|
41
|
-
const replaceBy = Array.isArray(value) ? value.join(', ') : String(value);
|
|
42
|
-
|
|
43
|
-
return acc.replace(searchValue, replaceBy);
|
|
44
|
-
}, template);
|
|
45
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { msToHour, msToMinute } from '../convert';
|
|
2
|
-
|
|
3
|
-
describe('msToMinute', () => {
|
|
4
|
-
it('should correctly convert milliseconds to minutes', () => {
|
|
5
|
-
expect(msToMinute(2520000)).toStrictEqual(42);
|
|
6
|
-
});
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
describe('msToHour', () => {
|
|
10
|
-
it('should correctly convert milliseconds to hours', () => {
|
|
11
|
-
expect(msToHour(1.08e+7)).toStrictEqual(3);
|
|
12
|
-
expect(msToHour(10)).toStrictEqual(0);
|
|
13
|
-
});
|
|
14
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { formatMinutes } from '../format-minutes';
|
|
2
|
-
|
|
3
|
-
describe('formatMinutes', () => {
|
|
4
|
-
it('should format minutes correctly', () => {
|
|
5
|
-
expect(formatMinutes(48)).toBe('48min');
|
|
6
|
-
expect(formatMinutes(65)).toBe('1h5min');
|
|
7
|
-
expect(formatMinutes(150)).toBe('2h30min');
|
|
8
|
-
expect(formatMinutes(355)).toBe('5h55min');
|
|
9
|
-
});
|
|
10
|
-
});
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { getTimeDiffAsString } from '../get-time-diff-as-string';
|
|
2
|
-
import type { MonthLocaleLabels } from '../get-time-diff-as-string';
|
|
3
|
-
|
|
4
|
-
describe('getTimeDiffAsString', () => {
|
|
5
|
-
const recentDate = new Date('2020-10-20 00:00:00.000');
|
|
6
|
-
const locales: MonthLocaleLabels = [
|
|
7
|
-
'January',
|
|
8
|
-
'February',
|
|
9
|
-
'March',
|
|
10
|
-
'April',
|
|
11
|
-
'May',
|
|
12
|
-
'June',
|
|
13
|
-
'July',
|
|
14
|
-
'August',
|
|
15
|
-
'September',
|
|
16
|
-
'October',
|
|
17
|
-
'November',
|
|
18
|
-
'December',
|
|
19
|
-
];
|
|
20
|
-
|
|
21
|
-
it('should correctly handle recent date in first param', () => {
|
|
22
|
-
const shouldBeEmptyString = getTimeDiffAsString(
|
|
23
|
-
new Date('2020-10-20 00:15:00.000'),
|
|
24
|
-
recentDate,
|
|
25
|
-
);
|
|
26
|
-
expect(shouldBeEmptyString).toStrictEqual('');
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('should correctly return formated minutes', () => {
|
|
30
|
-
const shouldBeFifteenMinAgo = getTimeDiffAsString(
|
|
31
|
-
new Date('2020-10-19 23:45:00.000'),
|
|
32
|
-
recentDate,
|
|
33
|
-
);
|
|
34
|
-
expect(shouldBeFifteenMinAgo).toStrictEqual('15 min ago');
|
|
35
|
-
|
|
36
|
-
const shouldbeFiftyNineMinAgo = getTimeDiffAsString(
|
|
37
|
-
new Date('2020-10-19 23:01:00.000'),
|
|
38
|
-
recentDate,
|
|
39
|
-
);
|
|
40
|
-
expect(shouldbeFiftyNineMinAgo).toStrictEqual('59 min ago');
|
|
41
|
-
|
|
42
|
-
const shouldBeOneMinAgo = getTimeDiffAsString(
|
|
43
|
-
new Date('2020-10-19 23:59:00.000'),
|
|
44
|
-
recentDate,
|
|
45
|
-
);
|
|
46
|
-
expect(shouldBeOneMinAgo).toStrictEqual('1 min ago');
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('should correctly return formated hours', () => {
|
|
50
|
-
const shouldBeOneHourAgo = getTimeDiffAsString(
|
|
51
|
-
new Date('2020-10-19 23:00:00.000'),
|
|
52
|
-
recentDate,
|
|
53
|
-
);
|
|
54
|
-
expect(shouldBeOneHourAgo).toStrictEqual('1 hour ago');
|
|
55
|
-
|
|
56
|
-
const shouldBeTwelveHoursAgo = getTimeDiffAsString(
|
|
57
|
-
new Date('2020-10-19 12:00:00.000'),
|
|
58
|
-
recentDate,
|
|
59
|
-
);
|
|
60
|
-
expect(shouldBeTwelveHoursAgo).toStrictEqual('12 hours ago');
|
|
61
|
-
|
|
62
|
-
const shouldBeTwentyThreeHoursAgo = getTimeDiffAsString(
|
|
63
|
-
new Date('2020-10-19 01:00:00.000'),
|
|
64
|
-
recentDate,
|
|
65
|
-
);
|
|
66
|
-
expect(shouldBeTwentyThreeHoursAgo).toStrictEqual('23 hours ago');
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('should correctly return formated date', () => {
|
|
70
|
-
const shouldBeOneDayAgo = getTimeDiffAsString(
|
|
71
|
-
new Date('2020-10-19 00:00:00.000'),
|
|
72
|
-
recentDate,
|
|
73
|
-
);
|
|
74
|
-
expect(shouldBeOneDayAgo).toStrictEqual('on October 19, 12:00 am');
|
|
75
|
-
|
|
76
|
-
const shouldBeTenMonthAgo = getTimeDiffAsString(
|
|
77
|
-
new Date('2020-01-20 12:30:00.000'),
|
|
78
|
-
recentDate,
|
|
79
|
-
);
|
|
80
|
-
expect(shouldBeTenMonthAgo).toStrictEqual('on January 20, 12:30 pm');
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('should correctly return according to template', () => {
|
|
84
|
-
const template = {
|
|
85
|
-
fullDateTemplate: 'hello %date% darkness',
|
|
86
|
-
timeTemplate: '%time% %timeLabel% yeet',
|
|
87
|
-
monthLocaleLabels: locales,
|
|
88
|
-
timeLabel: {
|
|
89
|
-
hour: { plural: 'a', singular: 'b' },
|
|
90
|
-
minute: { plural: 'c', singular: 'd' },
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
const shouldBeEmptyString = getTimeDiffAsString(
|
|
94
|
-
new Date('2020-10-19 00:00:00.000'),
|
|
95
|
-
recentDate,
|
|
96
|
-
template,
|
|
97
|
-
);
|
|
98
|
-
expect(shouldBeEmptyString).toStrictEqual('hello October 19, 12:00 am darkness');
|
|
99
|
-
|
|
100
|
-
const shouldBeTwoHoursAgo = getTimeDiffAsString(
|
|
101
|
-
new Date('2020-10-19 22:00:00.000'),
|
|
102
|
-
recentDate,
|
|
103
|
-
template,
|
|
104
|
-
);
|
|
105
|
-
expect(shouldBeTwoHoursAgo).toStrictEqual('2 a yeet');
|
|
106
|
-
|
|
107
|
-
const shouldBeOneHourAgo = getTimeDiffAsString(
|
|
108
|
-
new Date('2020-10-19 23:00:00.000'),
|
|
109
|
-
recentDate,
|
|
110
|
-
template,
|
|
111
|
-
);
|
|
112
|
-
expect(shouldBeOneHourAgo).toStrictEqual('1 b yeet');
|
|
113
|
-
|
|
114
|
-
const shouldbeFiftyNineMinAgo = getTimeDiffAsString(
|
|
115
|
-
new Date('2020-10-19 23:01:00.000'),
|
|
116
|
-
recentDate,
|
|
117
|
-
template,
|
|
118
|
-
);
|
|
119
|
-
expect(shouldbeFiftyNineMinAgo).toStrictEqual('59 c yeet');
|
|
120
|
-
|
|
121
|
-
const shouldBeOneMinAgo = getTimeDiffAsString(
|
|
122
|
-
new Date('2020-10-19 23:59:00.000'),
|
|
123
|
-
recentDate,
|
|
124
|
-
template,
|
|
125
|
-
);
|
|
126
|
-
expect(shouldBeOneMinAgo).toStrictEqual('1 d yeet');
|
|
127
|
-
});
|
|
128
|
-
});
|
package/src/time/constants.ts
DELETED
package/src/time/convert.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export const formatMinutes = (timeInMin: number): string => {
|
|
2
|
-
const hours = Math.floor(timeInMin / 60);
|
|
3
|
-
const mins = Math.round(timeInMin % 60);
|
|
4
|
-
|
|
5
|
-
if (hours === 0) return `${mins}min`;
|
|
6
|
-
if (mins === 0) return `${hours}h`;
|
|
7
|
-
|
|
8
|
-
return `${hours}h${mins}min`;
|
|
9
|
-
};
|
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import { ReplaceConfig, replaceInTemplate } from '../string';
|
|
2
|
-
import { MS_HOUR, MS_DAY } from './constants';
|
|
3
|
-
import { msToMinute, msToHour } from './convert';
|
|
4
|
-
|
|
5
|
-
export type MonthLocaleLabels = [
|
|
6
|
-
string,
|
|
7
|
-
string,
|
|
8
|
-
string,
|
|
9
|
-
string,
|
|
10
|
-
string,
|
|
11
|
-
string,
|
|
12
|
-
string,
|
|
13
|
-
string,
|
|
14
|
-
string,
|
|
15
|
-
string,
|
|
16
|
-
string,
|
|
17
|
-
string,
|
|
18
|
-
];
|
|
19
|
-
|
|
20
|
-
export type DiffTemplate = {
|
|
21
|
-
/**
|
|
22
|
-
* e.g.: ("%time% %timelabel% blabla")
|
|
23
|
-
*/
|
|
24
|
-
timeTemplate: string,
|
|
25
|
-
/**
|
|
26
|
-
* e.g.: "%date% blabla"
|
|
27
|
-
*/
|
|
28
|
-
monthLocaleLabels: MonthLocaleLabels,
|
|
29
|
-
fullDateTemplate: string,
|
|
30
|
-
timeLabel: {
|
|
31
|
-
minute: {
|
|
32
|
-
singular: string,
|
|
33
|
-
plural: string,
|
|
34
|
-
},
|
|
35
|
-
hour: {
|
|
36
|
-
singular: string,
|
|
37
|
-
plural: string,
|
|
38
|
-
},
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const defaultLocaleLabels: MonthLocaleLabels = [
|
|
43
|
-
'January',
|
|
44
|
-
'February',
|
|
45
|
-
'March',
|
|
46
|
-
'April',
|
|
47
|
-
'May',
|
|
48
|
-
'June',
|
|
49
|
-
'July',
|
|
50
|
-
'August',
|
|
51
|
-
'September',
|
|
52
|
-
'October',
|
|
53
|
-
'November',
|
|
54
|
-
'December',
|
|
55
|
-
];
|
|
56
|
-
|
|
57
|
-
const defaultEnglishTemplate: DiffTemplate = {
|
|
58
|
-
timeTemplate: '%time% %timeLabel% ago',
|
|
59
|
-
fullDateTemplate: 'on %date%',
|
|
60
|
-
monthLocaleLabels: defaultLocaleLabels,
|
|
61
|
-
timeLabel: {
|
|
62
|
-
minute: {
|
|
63
|
-
singular: 'min',
|
|
64
|
-
plural: 'min',
|
|
65
|
-
},
|
|
66
|
-
hour: {
|
|
67
|
-
singular: 'hour',
|
|
68
|
-
plural: 'hours',
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const TEMPLATE_CONFIG: ReplaceConfig = {
|
|
74
|
-
delimiter: {
|
|
75
|
-
left: '%',
|
|
76
|
-
right: '%',
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
type HourFormat = {
|
|
81
|
-
time: string,
|
|
82
|
-
period: 'am' | 'pm';
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
type MinuteFormat = {
|
|
86
|
-
time: string,
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
type DateForTemplate = {
|
|
90
|
-
old: Date,
|
|
91
|
-
recent: Date,
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
type ParamForTemplateConfig = {
|
|
95
|
-
templateConfig: DiffTemplate,
|
|
96
|
-
dates: DateForTemplate,
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
const formatMinuteString = (minute: number): MinuteFormat => {
|
|
100
|
-
const str = minute.toString();
|
|
101
|
-
|
|
102
|
-
return {
|
|
103
|
-
time: str.length === 2 ? str : `0${str}`,
|
|
104
|
-
};
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
const formatHourString = (hour: number): HourFormat => {
|
|
108
|
-
const period = hour < 12 ? 'am' : 'pm';
|
|
109
|
-
const twelveHourTime = hour > 12 ? hour - 12 : hour;
|
|
110
|
-
|
|
111
|
-
return {
|
|
112
|
-
time: twelveHourTime === 0 ? '12' : twelveHourTime.toString(),
|
|
113
|
-
period,
|
|
114
|
-
};
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
const getTemplatingParameters = (msDiff: number, config: ParamForTemplateConfig) => {
|
|
118
|
-
const { dates, templateConfig } = config;
|
|
119
|
-
const { timeLabel, monthLocaleLabels, timeTemplate, fullDateTemplate } = templateConfig;
|
|
120
|
-
|
|
121
|
-
if (msDiff < MS_HOUR) {
|
|
122
|
-
const minuteDiff = msToMinute(msDiff);
|
|
123
|
-
const minuteUnit = minuteDiff > 1
|
|
124
|
-
? timeLabel.minute.plural
|
|
125
|
-
: timeLabel.minute.singular;
|
|
126
|
-
|
|
127
|
-
return {
|
|
128
|
-
template: timeTemplate,
|
|
129
|
-
params: {
|
|
130
|
-
time: String(minuteDiff || 1),
|
|
131
|
-
timeLabel: minuteUnit,
|
|
132
|
-
},
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (msDiff < MS_DAY) {
|
|
137
|
-
const hourDiff = msToHour(msDiff);
|
|
138
|
-
const hourUnit = hourDiff > 1
|
|
139
|
-
? timeLabel.hour.plural
|
|
140
|
-
: timeLabel.hour.singular;
|
|
141
|
-
|
|
142
|
-
return {
|
|
143
|
-
template: timeTemplate,
|
|
144
|
-
params: {
|
|
145
|
-
time: String(hourDiff),
|
|
146
|
-
timeLabel: hourUnit,
|
|
147
|
-
},
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
const monthLabel = monthLocaleLabels[dates.old.getMonth()];
|
|
152
|
-
|
|
153
|
-
const minute = formatMinuteString(dates.old.getMinutes());
|
|
154
|
-
const hour = formatHourString(dates.old.getHours());
|
|
155
|
-
|
|
156
|
-
const dayFormat = `${monthLabel} ${dates.old.getDate()}`;
|
|
157
|
-
const timeFormat = `${hour.time}:${minute.time} ${hour.period}`;
|
|
158
|
-
|
|
159
|
-
return {
|
|
160
|
-
template: fullDateTemplate,
|
|
161
|
-
params: {
|
|
162
|
-
date: `${dayFormat}, ${timeFormat}`,
|
|
163
|
-
},
|
|
164
|
-
};
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* The returned string follows the following rules:
|
|
169
|
-
* - If diff < 60 minutes: '29 min ago'
|
|
170
|
-
* - If diff >= 60 minutes & < 24 hours: '12 hours ago' | '1 hour ago'
|
|
171
|
-
* - If diff > 24 hours: 'on March 15, 14:45 pm'
|
|
172
|
-
*
|
|
173
|
-
* @param olderDate - Date
|
|
174
|
-
* @param recentDate - Date
|
|
175
|
-
* @param template - DiffTemplate
|
|
176
|
-
* @returns a preformated string to be inserted in a phrase.
|
|
177
|
-
*/
|
|
178
|
-
export const getTimeDiffAsString = (olderDate: Date, recentDate = new Date(), templateConfig = defaultEnglishTemplate): string => {
|
|
179
|
-
const oldDateTime = olderDate.getTime();
|
|
180
|
-
const recentDateTime = recentDate.getTime();
|
|
181
|
-
|
|
182
|
-
if (oldDateTime > recentDateTime) {
|
|
183
|
-
return '';
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
const msDiff = recentDateTime - oldDateTime;
|
|
187
|
-
const { template, params } = getTemplatingParameters(msDiff, {
|
|
188
|
-
dates: {
|
|
189
|
-
old: olderDate,
|
|
190
|
-
recent: recentDate,
|
|
191
|
-
},
|
|
192
|
-
templateConfig,
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
return replaceInTemplate(template, params, TEMPLATE_CONFIG);
|
|
196
|
-
};
|
package/src/time/index.ts
DELETED
package/src/types/function.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type GenericFunction<TS extends any[], R> = (...args: TS) => R;
|
package/src/types/general.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export type Primitive = string | number | boolean;
|
|
2
|
-
export type Nullable<T> = T | null;
|
|
3
|
-
export type ValueType =
|
|
4
|
-
| Primitive
|
|
5
|
-
| null
|
|
6
|
-
| void
|
|
7
|
-
| Array<any>
|
|
8
|
-
| ReadonlyArray<any>;
|
|
9
|
-
|
|
10
|
-
export type ValueOf<T> = T[keyof T];
|
|
11
|
-
|
|
12
|
-
export type Range = {
|
|
13
|
-
min: number;
|
|
14
|
-
max: number;
|
|
15
|
-
};
|
package/src/types/index.ts
DELETED
package/src/types/object.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { ValueType } from './general';
|
|
2
|
-
|
|
3
|
-
// Used to extract non function attributes from a class or object
|
|
4
|
-
export type NonMethodKeys<T> = { [P in keyof T]: T[P] extends Function ? never : P }[keyof T];
|
|
5
|
-
export type Attributes<T> = { [K in NonMethodKeys<T>]: T[K] };
|
|
6
|
-
export type PartialAttributes<T> = { [K in NonMethodKeys<T>]?: T[K] };
|
|
7
|
-
|
|
8
|
-
// Used to extract functions attributes from a class or object
|
|
9
|
-
export type MethodKeys<T> = { [P in keyof T]: T[P] extends Function ? P : never }[keyof T];
|
|
10
|
-
export type Methods<T> = { [K in MethodKeys<T>]: T[K] };
|
|
11
|
-
export type PartialMethods<T> = { [K in MethodKeys<T>]?: T[K] };
|
|
12
|
-
|
|
13
|
-
export type ClassType<T, Params extends Array<any> = Array<any>> = {
|
|
14
|
-
new(...args: Params): T;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
18
|
-
|
|
19
|
-
export type DeepPartial<T> = T extends ValueType
|
|
20
|
-
? T
|
|
21
|
-
: { [P in keyof T]?: DeepPartial<T[P]> };
|
|
22
|
-
|
|
23
|
-
// Return intersecting properties of A & B
|
|
24
|
-
export type Intersection<A, B> = {
|
|
25
|
-
[P in keyof A & keyof B]: A[P] | B[P];
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Helper type. Passes T out again, but boxes it in a way that it cannot
|
|
30
|
-
* "widen" the type by accident if it is a generic that should be inferred
|
|
31
|
-
* from elsewhere.
|
|
32
|
-
*/
|
|
33
|
-
export type NoInfer<T> = [T][T extends any ? 0 : never];
|
package/src/types/search.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
export type SearchSortBy = string;
|
|
2
|
-
export type SearchSortOrder = 'asc' | 'desc';
|
|
3
|
-
|
|
4
|
-
export type SearchSort = {
|
|
5
|
-
[by: SearchSortBy]: SearchSortOrder;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export type SearchQueryProperty = string;
|
|
9
|
-
export type SearchQueryValue = string | string[];
|
|
10
|
-
|
|
11
|
-
export type SearchQuery = {
|
|
12
|
-
[property: SearchQueryProperty]: SearchQueryValue;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export type SearchQueryParam = {
|
|
16
|
-
q?: string;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export type PaginationOptions = {
|
|
20
|
-
offset: number;
|
|
21
|
-
limit: number;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export type SearchObject = Partial<PaginationOptions> & {
|
|
25
|
-
sort?: Record<string, SearchSortOrder>;
|
|
26
|
-
query?: SearchQuery;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export type SearchResponse<T> = {
|
|
30
|
-
items: T[];
|
|
31
|
-
offset: number;
|
|
32
|
-
limit: number;
|
|
33
|
-
total: number;
|
|
34
|
-
next: string | null;
|
|
35
|
-
previous: string | null;
|
|
36
|
-
};
|
package/tmp-lib.tgz
DELETED
|
Binary file
|
package/tsconfig.json
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"allowJs": false,
|
|
4
|
-
"allowSyntheticDefaultImports": true,
|
|
5
|
-
"moduleResolution": "node",
|
|
6
|
-
"strict": true,
|
|
7
|
-
"noImplicitAny": true,
|
|
8
|
-
"strictNullChecks": true,
|
|
9
|
-
"sourceMap": true,
|
|
10
|
-
"module": "ESNext",
|
|
11
|
-
"target": "ES6",
|
|
12
|
-
"isolatedModules": true,
|
|
13
|
-
"forceConsistentCasingInFileNames": true,
|
|
14
|
-
"declaration": true,
|
|
15
|
-
"outDir": "dist",
|
|
16
|
-
"lib": ["es2015", "es2017.object"]
|
|
17
|
-
},
|
|
18
|
-
"files": ["global.d.ts"],
|
|
19
|
-
"include": [
|
|
20
|
-
"src/**/*"
|
|
21
|
-
],
|
|
22
|
-
"exclude": [
|
|
23
|
-
"**/node_modules",
|
|
24
|
-
]
|
|
25
|
-
}
|