@startlibs/utils 1.0.0-alpha-7g → 1.0.0-alpha-7j

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/lib/index.js CHANGED
@@ -27,6 +27,7 @@ var polished = require('polished');
27
27
  var react = require('react');
28
28
  var styled = require('styled-components');
29
29
  var createEmotion = require('create-emotion');
30
+ var _flow = require('lodash/fp/flow');
30
31
  var _map = require('lodash/fp/map');
31
32
  var _filter = require('lodash/fp/filter');
32
33
  var _each = require('lodash/fp/each');
@@ -65,6 +66,7 @@ var _get__default = /*#__PURE__*/_interopDefaultLegacy(_get);
65
66
  var _unset__default = /*#__PURE__*/_interopDefaultLegacy(_unset);
66
67
  var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
67
68
  var createEmotion__default = /*#__PURE__*/_interopDefaultLegacy(createEmotion);
69
+ var _flow__default = /*#__PURE__*/_interopDefaultLegacy(_flow);
68
70
  var _map__default = /*#__PURE__*/_interopDefaultLegacy(_map);
69
71
  var _filter__default = /*#__PURE__*/_interopDefaultLegacy(_filter);
70
72
  var _each__default = /*#__PURE__*/_interopDefaultLegacy(_each);
@@ -524,6 +526,8 @@ var formatHour = function formatHour() {
524
526
 
525
527
  if (!h && parseInt(m) < 24 && !_isFinite__default['default'](hour)) {
526
528
  return m + ":00";
529
+ } else if (h) {
530
+ return (parseInt(h, 10) > 23 ? h.slice(1) : h) + ':' + m;
527
531
  }
528
532
 
529
533
  return ('000' + hour.toString().replace(":", "")).slice(-4).replace(/(\d\d)(\d\d)/, '$1:$2');
@@ -1163,7 +1167,14 @@ var _s = {
1163
1167
  find: find,
1164
1168
  filter: filter,
1165
1169
  map: map,
1166
- insertAt: insertAt
1170
+ insertAt: insertAt,
1171
+ flowEach: function flowEach() {
1172
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1173
+ args[_key] = arguments[_key];
1174
+ }
1175
+
1176
+ return _flow__default['default'].apply(void 0, _toConsumableArray__default['default'](args.filter(Boolean)));
1177
+ }
1167
1178
  };
1168
1179
 
1169
1180
  function _templateObject() {
@@ -2029,19 +2040,117 @@ var willUseAutoLazy = function willUseAutoLazy() {
2029
2040
  return [lazy, useAutoLazyEffect];
2030
2041
  };
2031
2042
 
2043
+ var SECOND = 1000;
2044
+ var MINUTE = SECOND * 60;
2045
+ var HOUR = MINUTE * 60;
2046
+ var DAY = HOUR * 24;
2047
+ var WEEK = DAY * 7;
2048
+ var MONTH = DAY * 31;
2049
+ var YEAR = DAY * 366;
2050
+ var getStartOfDay = function getStartOfDay(d) {
2051
+ var utc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
2052
+ var date = new Date(d);
2053
+
2054
+ if (utc) {
2055
+ date.setUTCHours(0, 0, 0, 0);
2056
+ } else {
2057
+ date.setHours(0, 0, 0, 0);
2058
+ }
2059
+
2060
+ return date;
2061
+ };
2062
+ var isSameDay = function isSameDay(a, b) {
2063
+ var utc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
2064
+ return getStartOfDay(a, utc).getTime() === getStartOfDay(b, utc).getTime();
2065
+ };
2066
+ var intervalsIntersect = function intervalsIntersect(_ref, _ref2) {
2067
+ var _ref3 = _slicedToArray__default['default'](_ref, 2),
2068
+ a1 = _ref3[0],
2069
+ a2 = _ref3[1];
2070
+
2071
+ var _ref4 = _slicedToArray__default['default'](_ref2, 2),
2072
+ b1 = _ref4[0],
2073
+ b2 = _ref4[1];
2074
+
2075
+ return b2 >= a1 && b1 <= a2;
2076
+ };
2077
+ var intervalsIntersection = function intervalsIntersection(a, b) {
2078
+ if (!intervalsIntersect(a, b)) {
2079
+ return [];
2080
+ }
2081
+
2082
+ return [[Math.max(a[0], b[0]), Math.min(a[1], b[1])]];
2083
+ };
2084
+ var diffIntervals = function diffIntervals(_ref5, _ref6) {
2085
+ var _ref7 = _slicedToArray__default['default'](_ref5, 2),
2086
+ a1 = _ref7[0],
2087
+ a2 = _ref7[1];
2088
+
2089
+ var _ref8 = _slicedToArray__default['default'](_ref6, 2),
2090
+ b1 = _ref8[0],
2091
+ b2 = _ref8[1];
2092
+
2093
+ if (a1 >= b2 || // a after b
2094
+ b1 >= a2 // a before b
2095
+ ) {
2096
+ return [[a1, a2]];
2097
+ } else if (a1 > b1 && a2 < b2) {
2098
+ // a inside b
2099
+ return [];
2100
+ }
2101
+
2102
+ if (b1 > a1 && b2 < a2) {
2103
+ // b inside a
2104
+ return [[a1, b1], [b2, a2]];
2105
+ }
2106
+
2107
+ if (b1 <= a1) {
2108
+ // b intersecting left of a
2109
+ return [[b2, a2]];
2110
+ } else {
2111
+ // b intersecting right of a
2112
+ return [[a1, b1]];
2113
+ }
2114
+ };
2115
+ var blockDiffIntervals = function blockDiffIntervals(a, b) {
2116
+ return intervalsIntersect(a, b) ? [] : [a];
2117
+ };
2118
+ var startBlockDiffIntervals = function startBlockDiffIntervals(a, b) {
2119
+ return intervalsIntersect(a, b) && a[0] < b[0] ? [] : [a];
2120
+ };
2121
+
2122
+ var formatJoin = function formatJoin(arr) {
2123
+ var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ', ';
2124
+ var lastSeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ' e ';
2125
+ return [arr.slice(0, -1).join(separator), arr.slice(-1)].join(lastSeparator);
2126
+ };
2127
+ var formatJoinArr = function formatJoinArr(arr, separator, lastSeparator) {
2128
+ return arr.flatMap(function (v, i) {
2129
+ return i < arr.length - 2 ? [v, separator] : i < arr.length - 1 ? [v, lastSeparator] : [v];
2130
+ });
2131
+ };
2132
+
2032
2133
  exports.Action = Action;
2033
2134
  exports.COMPLETE_ACTION = COMPLETE_ACTION;
2135
+ exports.DAY = DAY;
2034
2136
  exports.FETCH = FETCH;
2137
+ exports.HOUR = HOUR;
2138
+ exports.MINUTE = MINUTE;
2139
+ exports.MONTH = MONTH;
2035
2140
  exports.REDUCE = REDUCE;
2141
+ exports.SECOND = SECOND;
2036
2142
  exports.SKIPPED_ACTION = SKIPPED_ACTION;
2037
2143
  exports.SKIP_DISPATCH = SKIP_DISPATCH;
2038
2144
  exports.SKIP_FETCH = SKIP_FETCH;
2039
2145
  exports.SkipAction = SkipAction;
2146
+ exports.WEEK = WEEK;
2147
+ exports.YEAR = YEAR;
2040
2148
  exports._s = _s;
2041
2149
  exports.activateActions = activateActions;
2042
2150
  exports.addHttp = addHttp;
2043
2151
  exports.addQueryString = addQueryString;
2044
2152
  exports.animationTiming = animationTiming;
2153
+ exports.blockDiffIntervals = blockDiffIntervals;
2045
2154
  exports.callIfFunction = callIfFunction;
2046
2155
  exports.callIfFunctions = callIfFunctions;
2047
2156
  exports.callMany = callMany;
@@ -2053,6 +2162,7 @@ exports.createPressAndMoveEvent = createPressAndMoveEvent;
2053
2162
  exports.createPressEvent = createPressEvent;
2054
2163
  exports.createPromiseQueue = createPromiseQueue;
2055
2164
  exports.customTheme = customTheme;
2165
+ exports.diffIntervals = diffIntervals;
2056
2166
  exports.digitsToPattern = digitsToPattern;
2057
2167
  exports.ellipsis = ellipsis;
2058
2168
  exports.fixMediaQuery = fixMediaQuery;
@@ -2061,6 +2171,8 @@ exports.formFetchWithResponse = formFetchWithResponse;
2061
2171
  exports.formatDate = formatDate;
2062
2172
  exports.formatDateToPattern = formatDateToPattern;
2063
2173
  exports.formatHour = formatHour;
2174
+ exports.formatJoin = formatJoin;
2175
+ exports.formatJoinArr = formatJoinArr;
2064
2176
  exports.formatPath = formatPath;
2065
2177
  exports.getClosestOffsetScroll = getClosestOffsetScroll;
2066
2178
  exports.getColor = getColor;
@@ -2070,6 +2182,7 @@ exports.getMargin = getMargin;
2070
2182
  exports.getNumberInputType = getNumberInputType;
2071
2183
  exports.getNumberInputType2 = getNumberInputType2;
2072
2184
  exports.getScrollParent = getScrollParent;
2185
+ exports.getStartOfDay = getStartOfDay;
2073
2186
  exports.getUID = getUID;
2074
2187
  exports.getUrlParams = getUrlParams;
2075
2188
  exports.identityFn = identityFn;
@@ -2080,12 +2193,15 @@ exports.ifProp = ifProp;
2080
2193
  exports.ifPropEquals = ifPropEquals;
2081
2194
  exports.ifUndefined = ifUndefined;
2082
2195
  exports.intToHour = intToHour;
2196
+ exports.intervalsIntersect = intervalsIntersect;
2197
+ exports.intervalsIntersection = intervalsIntersection;
2083
2198
  exports.intsToHour = intsToHour;
2084
2199
  exports.isEmptyHtml = isEmptyHtml;
2085
2200
  exports.isHighDensity = isHighDensity;
2086
2201
  exports.isIOS = isIOS;
2087
2202
  exports.isMobile = isMobile;
2088
2203
  exports.isRetina = isRetina;
2204
+ exports.isSameDay = isSameDay;
2089
2205
  exports.isSmallDevice = isSmallDevice;
2090
2206
  exports.isTouchDevice = isTouchDevice;
2091
2207
  exports.isUrl = isUrl;
@@ -2108,6 +2224,7 @@ exports.scrollIntoViewWithOffset = scrollIntoViewWithOffset;
2108
2224
  exports.scrollWidth = scrollWidth;
2109
2225
  exports.selectPath = selectPath;
2110
2226
  exports.smoothScroll = smoothScroll;
2227
+ exports.startBlockDiffIntervals = startBlockDiffIntervals;
2111
2228
  exports.stopPropagation = stopPropagation;
2112
2229
  exports.styledExtend = styledExtend;
2113
2230
  exports.timerPromise = timerPromise;
package/package.json CHANGED
@@ -1,15 +1,14 @@
1
1
  {
2
2
  "name": "@startlibs/utils",
3
- "version": "1.0.0-alpha-7g",
3
+ "version": "1.0.0-alpha-7j",
4
4
  "description": "Startlibs Utils",
5
- "main": "src/index.js",
5
+ "main": "lib/index.js",
6
6
  "sideEffects": false,
7
7
  "source": true,
8
8
  "peerDependencies": {
9
9
  "lodash": "^4.17.11",
10
- "react": "^16.8",
11
- "react-dom": "^16.8",
12
- "react-hot-loader": "^4.3.5"
10
+ "react": "^18.0",
11
+ "react-dom": "^18.0"
13
12
  },
14
13
  "devDependencies": {
15
14
  "@babel/core": "^7.2.0",
package/src/index.js DELETED
@@ -1,15 +0,0 @@
1
- export * from './createPromiseQueue'
2
- export * from './getClosestOffsetScroll'
3
- export * from './smoothScroll'
4
- export * from './fixMediaQuery'
5
- export * from './FetchUtils'
6
- export * from './styled'
7
- export * from './formatDate'
8
- export {_s} from './lodashUtils'
9
- export * from './ActionUtils'
10
- export * from './reduceUtils'
11
- export * from './hooks/useEventListener'
12
- export * from './utils'
13
- export * from './createPressEvent'
14
- export * from './wrapLazy'
15
-