@bbn/bbn 1.0.437 → 1.0.439

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.
Files changed (206) hide show
  1. package/dist/_.js +7 -11
  2. package/dist/bbn.js +1 -1
  3. package/dist/bbn.js.map +1 -1
  4. package/dist/date.d.ts +39 -0
  5. package/dist/date.js +339 -0
  6. package/dist/db.js +107 -124
  7. package/dist/fn/ajax/_addLoader.js +6 -6
  8. package/dist/fn/ajax/_deleteLoader.js +11 -13
  9. package/dist/fn/ajax/abort.js +1 -1
  10. package/dist/fn/ajax/abortURL.js +1 -1
  11. package/dist/fn/ajax/ajax.js +25 -30
  12. package/dist/fn/ajax/callback.js +10 -14
  13. package/dist/fn/ajax/download.js +7 -9
  14. package/dist/fn/ajax/downloadContent.js +5 -6
  15. package/dist/fn/ajax/getLoader.js +1 -1
  16. package/dist/fn/ajax/getRequestId.js +2 -2
  17. package/dist/fn/ajax/link.js +9 -13
  18. package/dist/fn/ajax/post.js +3 -7
  19. package/dist/fn/ajax/postOut.js +2 -4
  20. package/dist/fn/ajax/setNavigationVars.js +5 -7
  21. package/dist/fn/ajax/stream.js +21 -22
  22. package/dist/fn/ajax/treatAjaxArguments.js +3 -3
  23. package/dist/fn/ajax/upload.js +6 -9
  24. package/dist/fn/browser/copy.js +9 -12
  25. package/dist/fn/browser/error.js +2 -2
  26. package/dist/fn/browser/executeSlowly.js +11 -55
  27. package/dist/fn/browser/getBrowserName.js +1 -1
  28. package/dist/fn/browser/getBrowserVersion.js +1 -1
  29. package/dist/fn/browser/getCookie.js +5 -5
  30. package/dist/fn/browser/getDeviceType.js +1 -1
  31. package/dist/fn/browser/getEventData.js +30 -30
  32. package/dist/fn/browser/happy.js +1 -5
  33. package/dist/fn/browser/info.js +1 -5
  34. package/dist/fn/browser/isActiveInterface.js +2 -3
  35. package/dist/fn/browser/isFocused.js +1 -2
  36. package/dist/fn/browser/log.js +8 -12
  37. package/dist/fn/browser/replaceSelection.js +5 -5
  38. package/dist/fn/browser/selectElementText.js +4 -5
  39. package/dist/fn/browser/setCookie.js +3 -3
  40. package/dist/fn/browser/warning.js +2 -2
  41. package/dist/fn/browser/yieldToBrowser.js +7 -43
  42. package/dist/fn/convert/arrayBuffer2String.js +1 -1
  43. package/dist/fn/convert/canvasToImage.js +1 -1
  44. package/dist/fn/convert/colorToHex.js +1 -1
  45. package/dist/fn/convert/fromXml.js +7 -13
  46. package/dist/fn/convert/hex2rgb.js +1 -1
  47. package/dist/fn/convert/imageToCanvas.js +1 -1
  48. package/dist/fn/convert/imgToBase64.js +2 -3
  49. package/dist/fn/convert/toCSV.js +7 -10
  50. package/dist/fn/datetime/calendar.js +4 -5
  51. package/dist/fn/datetime/date.js +1 -1
  52. package/dist/fn/datetime/dateSQL.js +1 -1
  53. package/dist/fn/datetime/daysInMonth.js +1 -1
  54. package/dist/fn/datetime/fdate.js +2 -3
  55. package/dist/fn/datetime/fdatetime.js +2 -3
  56. package/dist/fn/datetime/ftime.js +1 -1
  57. package/dist/fn/datetime/getChrono.js +2 -3
  58. package/dist/fn/datetime/getDay.js +3 -3
  59. package/dist/fn/datetime/startChrono.js +1 -1
  60. package/dist/fn/datetime/stopChrono.js +2 -2
  61. package/dist/fn/datetime/timestamp.js +2 -3
  62. package/dist/fn/default/defaultAjaxAbortFunction.js +1 -2
  63. package/dist/fn/default/defaultAjaxErrorFunction.js +1 -3
  64. package/dist/fn/default/defaultAlertFunction.js +1 -2
  65. package/dist/fn/default/defaultConfirmFunction.js +2 -3
  66. package/dist/fn/default/defaultEndLoadingFunction.js +1 -3
  67. package/dist/fn/default/defaultPostLinkFunction.js +1 -2
  68. package/dist/fn/default/defaultPreLinkFunction.js +1 -3
  69. package/dist/fn/form/addInputs.js +10 -12
  70. package/dist/fn/form/fieldValue.js +1 -1
  71. package/dist/fn/form/formdata.js +24 -24
  72. package/dist/fn/form/objectToFormData.js +5 -8
  73. package/dist/fn/form/submit.js +4 -4
  74. package/dist/fn/html/adjustHeight.js +1 -1
  75. package/dist/fn/html/adjustSize.js +5 -5
  76. package/dist/fn/html/adjustWidth.js +1 -1
  77. package/dist/fn/html/getAllTags.js +1 -1
  78. package/dist/fn/html/getAncestors.js +2 -3
  79. package/dist/fn/html/getAttributes.js +2 -2
  80. package/dist/fn/html/getHTMLOfSelection.js +4 -4
  81. package/dist/fn/html/getHtml.js +2 -3
  82. package/dist/fn/html/getIndex.js +3 -4
  83. package/dist/fn/html/getPath.js +12 -17
  84. package/dist/fn/html/html2text.js +1 -1
  85. package/dist/fn/html/isInViewport.js +4 -5
  86. package/dist/fn/html/isInside.js +5 -5
  87. package/dist/fn/html/makeReactive.js +22 -26
  88. package/dist/fn/init.js +18 -18
  89. package/dist/fn/loop/each.js +2 -2
  90. package/dist/fn/loop/fori.js +3 -5
  91. package/dist/fn/loop/forir.js +3 -5
  92. package/dist/fn/loop/iterate.js +3 -6
  93. package/dist/fn/loop/riterate.js +1 -2
  94. package/dist/fn/misc/analyzeFunction.js +36 -36
  95. package/dist/fn/misc/money.js +4 -4
  96. package/dist/fn/misc/translate.js +2 -2
  97. package/dist/fn/object/_compareValues.js +2 -3
  98. package/dist/fn/object/_filter.js +7 -10
  99. package/dist/fn/object/arrayFromProp.js +2 -2
  100. package/dist/fn/object/checkProps.js +1 -2
  101. package/dist/fn/object/checkPropsDetails.js +8 -9
  102. package/dist/fn/object/checkPropsOrDie.js +2 -3
  103. package/dist/fn/object/circularReplacer.js +2 -2
  104. package/dist/fn/object/clone.js +2 -2
  105. package/dist/fn/object/compareConditions.js +6 -6
  106. package/dist/fn/object/count.js +1 -3
  107. package/dist/fn/object/createObject.js +3 -16
  108. package/dist/fn/object/deepPath.js +6 -7
  109. package/dist/fn/object/diffObj.js +11 -13
  110. package/dist/fn/object/extend.js +10 -14
  111. package/dist/fn/object/extendOut.js +4 -9
  112. package/dist/fn/object/filter.js +6 -8
  113. package/dist/fn/object/filterToConditions.js +6 -7
  114. package/dist/fn/object/findAll.js +4 -5
  115. package/dist/fn/object/getField.js +2 -8
  116. package/dist/fn/object/getFieldValues.js +2 -2
  117. package/dist/fn/object/getProperty.js +5 -9
  118. package/dist/fn/object/getRow.js +2 -7
  119. package/dist/fn/object/getSortingMoves.js +28 -28
  120. package/dist/fn/object/isWritable.js +1 -1
  121. package/dist/fn/object/map.js +2 -3
  122. package/dist/fn/object/move.js +1 -1
  123. package/dist/fn/object/multiorder.js +5 -6
  124. package/dist/fn/object/mutateArray.js +8 -9
  125. package/dist/fn/object/mutateObject.js +3 -3
  126. package/dist/fn/object/order.js +1 -2
  127. package/dist/fn/object/removeEmpty.js +2 -2
  128. package/dist/fn/object/removePrivateProp.js +2 -3
  129. package/dist/fn/object/search.js +13 -17
  130. package/dist/fn/object/setProp.js +1 -3
  131. package/dist/fn/object/setProperty.js +8 -8
  132. package/dist/fn/object/shortenObj.js +3 -4
  133. package/dist/fn/object/shuffle.js +2 -3
  134. package/dist/fn/object/sum.js +3 -3
  135. package/dist/fn/object/unique.js +1 -1
  136. package/dist/fn/phone/fphone.js +22 -22
  137. package/dist/fn/string/baseName.js +3 -3
  138. package/dist/fn/string/correctCase.js +1 -1
  139. package/dist/fn/string/crc32.js +7 -7
  140. package/dist/fn/string/data2Html.js +4 -5
  141. package/dist/fn/string/dirName.js +1 -1
  142. package/dist/fn/string/escapeUrl.js +6 -6
  143. package/dist/fn/string/fileExt.js +1 -1
  144. package/dist/fn/string/firstVarElement.js +2 -2
  145. package/dist/fn/string/format.js +4 -4
  146. package/dist/fn/string/formatBytes.js +2 -3
  147. package/dist/fn/string/hash.js +4 -8
  148. package/dist/fn/string/randomString.js +5 -5
  149. package/dist/fn/string/replaceAll.js +1 -2
  150. package/dist/fn/string/sanitize.js +6 -7
  151. package/dist/fn/string/simpleHash.js +2 -2
  152. package/dist/fn/string/simpleHash1.js +3 -3
  153. package/dist/fn/string/simpleHash2.js +3 -3
  154. package/dist/fn/string/treatForHash.js +6 -10
  155. package/dist/fn/string/trim.js +1 -2
  156. package/dist/fn/string/uniqString.js +7 -14
  157. package/dist/fn/style/addColors.js +14 -14
  158. package/dist/fn/style/addStyle.js +1 -1
  159. package/dist/fn/style/animateCss.js +1 -1
  160. package/dist/fn/style/center.js +1 -1
  161. package/dist/fn/style/cssExists.js +5 -5
  162. package/dist/fn/style/getCssVar.js +1 -1
  163. package/dist/fn/style/getScrollBarSize.js +5 -5
  164. package/dist/fn/style/lightenDarkenHex.js +2 -2
  165. package/dist/fn/style/outerHeight.js +2 -2
  166. package/dist/fn/style/outerWidth.js +2 -2
  167. package/dist/fn/style/resize.js +14 -14
  168. package/dist/fn/type/checkType.js +5 -9
  169. package/dist/fn/type/isArray.js +2 -7
  170. package/dist/fn/type/isBlob.js +2 -7
  171. package/dist/fn/type/isBoolean.js +2 -7
  172. package/dist/fn/type/isCanvas.js +2 -7
  173. package/dist/fn/type/isColor.js +2 -7
  174. package/dist/fn/type/isComment.js +2 -7
  175. package/dist/fn/type/isCp.js +3 -8
  176. package/dist/fn/type/isDataURL.js +2 -7
  177. package/dist/fn/type/isDate.js +2 -7
  178. package/dist/fn/type/isDimension.js +2 -7
  179. package/dist/fn/type/isDom.js +2 -7
  180. package/dist/fn/type/isEmail.js +3 -8
  181. package/dist/fn/type/isEvent.js +2 -7
  182. package/dist/fn/type/isFunction.js +2 -7
  183. package/dist/fn/type/isHostname.js +2 -7
  184. package/dist/fn/type/isIP.js +2 -7
  185. package/dist/fn/type/isInt.js +2 -7
  186. package/dist/fn/type/isIterable.js +2 -7
  187. package/dist/fn/type/isNotObject.js +2 -7
  188. package/dist/fn/type/isNull.js +2 -7
  189. package/dist/fn/type/isNumber.js +2 -7
  190. package/dist/fn/type/isObject.js +2 -7
  191. package/dist/fn/type/isPercent.js +2 -7
  192. package/dist/fn/type/isPrimitive.js +2 -7
  193. package/dist/fn/type/isPromise.js +2 -7
  194. package/dist/fn/type/isPropSize.js +2 -2
  195. package/dist/fn/type/isSQLDate.js +2 -7
  196. package/dist/fn/type/isSame.js +12 -12
  197. package/dist/fn/type/isString.js +2 -7
  198. package/dist/fn/type/isSymbol.js +2 -7
  199. package/dist/fn/type/isURL.js +2 -7
  200. package/dist/fn/type/isUid.js +2 -7
  201. package/dist/fn/type/isValidDimension.js +2 -2
  202. package/dist/fn/type/isValidName.js +2 -7
  203. package/dist/fn/type/isVue.js +4 -11
  204. package/dist/fn.js +247 -247
  205. package/dist/index.js +9 -7
  206. package/package.json +1 -1
package/dist/date.d.ts ADDED
@@ -0,0 +1,39 @@
1
+ declare class bbnDateTool {
2
+ #private;
3
+ constructor(value: any, inputFormat?: null | String);
4
+ toString(): number;
5
+ get year(): number;
6
+ get month(): number;
7
+ get day(): number;
8
+ get hours(): number;
9
+ get minutes(): number;
10
+ get seconds(): number;
11
+ get tst(): number;
12
+ get mtst(): number;
13
+ get YYYY(): string;
14
+ get YY(): string;
15
+ get MM(): string;
16
+ get DD(): string;
17
+ get HH(): string;
18
+ get mm(): string;
19
+ get ss(): string;
20
+ add(value: number, unit?: string): bbnDateTool | null;
21
+ sub(value: number, unit: string | null): bbnDateTool;
22
+ dateFromFormat(value: string, unit: string | null): Date;
23
+ format(format?: string): string;
24
+ unix(ms?: boolean): number;
25
+ /**
26
+ * Compare this date to another date with a given precision.
27
+ * @returns -1 if this < other, 0 if equal, 1 if this > other
28
+ */
29
+ compare(date: any, unit?: string): -1 | 0 | 1;
30
+ isBefore(date: any, unit?: string): Boolean;
31
+ isAfter(date: any, unit?: string): Boolean;
32
+ isSame(date: any, unit?: string): Boolean;
33
+ isAfterOrSame(date: any, unit?: string): Boolean;
34
+ isBeforeOrSame(date: any, unit?: string): Boolean;
35
+ calendar(format: string): string;
36
+ get daysInMonth(): Number | 0;
37
+ }
38
+ declare function generatorFunction(value: any, inputFormat?: null | String): bbnDateTool;
39
+ export default generatorFunction;
package/dist/date.js ADDED
@@ -0,0 +1,339 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _bbnDateTool_value, _bbnDateTool_daysInMonth, _bbnDateTool_parts;
13
+ import each from './fn/loop/each.js';
14
+ import substr from './fn/string/substr.js';
15
+ import isNumber from './fn/type/isNumber.js';
16
+ import isDate from './fn/type/isDate.js';
17
+ const unitsMap = {
18
+ 'y': 'FullYear',
19
+ 'm': 'Month',
20
+ 'd': 'Date',
21
+ 'h': 'Hours',
22
+ 'n': 'Minutes',
23
+ 's': 'Seconds'
24
+ };
25
+ const unitsCorrespondence = {
26
+ 'YYYY': 'y',
27
+ 'YY': 'y',
28
+ 'yyyy': 'y',
29
+ 'yy': 'y',
30
+ 'year': 'y',
31
+ 'Y': 'y',
32
+ 'y': 'y',
33
+ 'MM': 'm',
34
+ 'M': 'm',
35
+ 'month': 'm',
36
+ 'mm': 'm',
37
+ 'm': 'm',
38
+ 'DD': 'd',
39
+ 'day': 'd',
40
+ 'D': 'd',
41
+ 'dd': 'd',
42
+ 'd': 'd',
43
+ 'HH': 'h',
44
+ 'hr': 'h',
45
+ 'hour': 'h',
46
+ 'H': 'h',
47
+ 'hh': 'h',
48
+ 'h': 'h',
49
+ 'NN': 'n',
50
+ 'nn': 'n',
51
+ 'mn': 'n',
52
+ 'minute': 'n',
53
+ 'min': 'n',
54
+ 'n': 'n',
55
+ 'SS': 's',
56
+ 'ss': 's',
57
+ 'sec': 's',
58
+ 's': 's',
59
+ 'S': 's',
60
+ };
61
+ class bbnDateTool {
62
+ constructor(value, inputFormat = null) {
63
+ _bbnDateTool_value.set(this, void 0);
64
+ _bbnDateTool_daysInMonth.set(this, undefined);
65
+ _bbnDateTool_parts.set(this, undefined);
66
+ if (!value) {
67
+ __classPrivateFieldSet(this, _bbnDateTool_value, new Date(), "f");
68
+ }
69
+ else if (inputFormat) {
70
+ __classPrivateFieldSet(this, _bbnDateTool_value, new Date(), "f");
71
+ }
72
+ else {
73
+ let t = typeof value;
74
+ if (t === 'number' || (isNumber(value) && value !== '')) {
75
+ if ((value < 5000) && isNumber(inputFormat)) {
76
+ value = Array.from(arguments);
77
+ }
78
+ else if (value < 10000000000) {
79
+ value = value * 1000;
80
+ }
81
+ if (!Array.isArray(value)) {
82
+ __classPrivateFieldSet(this, _bbnDateTool_value, new Date(value), "f");
83
+ }
84
+ }
85
+ if (t === 'string') {
86
+ if (value.length === 10) {
87
+ __classPrivateFieldSet(this, _bbnDateTool_value, new Date(parseInt(substr(value, 0, 4)), parseInt(substr(value, 5, 2)) - 1, parseInt(substr(value, 8, 2)), 12), "f");
88
+ }
89
+ else if (value.length === 19) {
90
+ __classPrivateFieldSet(this, _bbnDateTool_value, new Date(parseInt(substr(value, 0, 4)), parseInt(substr(value, 5, 2)) - 1, parseInt(substr(value, 8, 2)), parseInt(substr(value, 11, 2)), parseInt(substr(value, 14, 2)), parseInt(substr(value, 17, 2))), "f");
91
+ }
92
+ }
93
+ else if (isDate(value)) {
94
+ __classPrivateFieldSet(this, _bbnDateTool_value, value, "f");
95
+ }
96
+ else if (Array.isArray(value)) {
97
+ __classPrivateFieldSet(this, _bbnDateTool_value, new Date(...value), "f");
98
+ }
99
+ }
100
+ if (__classPrivateFieldGet(this, _bbnDateTool_value, "f") === undefined) {
101
+ const obj = {};
102
+ return new Proxy(this, {
103
+ get: (target, prop) => {
104
+ return undefined;
105
+ }
106
+ });
107
+ }
108
+ }
109
+ toString() {
110
+ return __classPrivateFieldGet(this, _bbnDateTool_value, "f") ? __classPrivateFieldGet(this, _bbnDateTool_value, "f").getTime() : 0;
111
+ }
112
+ get year() {
113
+ return __classPrivateFieldGet(this, _bbnDateTool_value, "f").getFullYear();
114
+ }
115
+ get month() {
116
+ return __classPrivateFieldGet(this, _bbnDateTool_value, "f").getMonth() + 1;
117
+ }
118
+ get day() {
119
+ return __classPrivateFieldGet(this, _bbnDateTool_value, "f").getDate();
120
+ }
121
+ get hours() {
122
+ return __classPrivateFieldGet(this, _bbnDateTool_value, "f").getHours();
123
+ }
124
+ get minutes() {
125
+ return __classPrivateFieldGet(this, _bbnDateTool_value, "f").getMinutes();
126
+ }
127
+ get seconds() {
128
+ return __classPrivateFieldGet(this, _bbnDateTool_value, "f").getSeconds();
129
+ }
130
+ get tst() {
131
+ return Math.ceil(__classPrivateFieldGet(this, _bbnDateTool_value, "f").getTime() / 1000);
132
+ }
133
+ get mtst() {
134
+ return __classPrivateFieldGet(this, _bbnDateTool_value, "f").getTime();
135
+ }
136
+ get YYYY() {
137
+ return this.year.toString();
138
+ }
139
+ get YY() {
140
+ return substr(this.year.toString(), 2, 2);
141
+ }
142
+ get MM() {
143
+ return this.month < 10 ? '0' + this.month.toString() : this.month.toString();
144
+ }
145
+ get DD() {
146
+ return this.day < 10 ? '0' + this.day.toString() : this.day.toString();
147
+ }
148
+ get HH() {
149
+ return this.hours < 10 ? '0' + this.hours.toString() : this.hours.toString();
150
+ }
151
+ get mm() {
152
+ return this.minutes < 10 ? '0' + this.minutes.toString() : this.minutes.toString();
153
+ }
154
+ get ss() {
155
+ return this.seconds < 10 ? '0' + this.seconds.toString() : this.seconds.toString();
156
+ }
157
+ add(value, unit = 'd') {
158
+ const date = __classPrivateFieldGet(this, _bbnDateTool_value, "f") ? new Date(__classPrivateFieldGet(this, _bbnDateTool_value, "f").getTime()) : new Date();
159
+ if (unitsCorrespondence[unit]) {
160
+ const realUnit = unitsCorrespondence[unit];
161
+ const suffix = unitsMap[realUnit];
162
+ const getter = 'get' + suffix;
163
+ const setter = 'set' + suffix;
164
+ date[setter](date[getter]() + value);
165
+ return new bbnDateTool(date);
166
+ }
167
+ return null;
168
+ }
169
+ sub(value, unit) {
170
+ return this.add(-value, unit);
171
+ }
172
+ dateFromFormat(value, unit) {
173
+ const d = new Date();
174
+ return d;
175
+ }
176
+ format(format = '') {
177
+ const date = __classPrivateFieldGet(this, _bbnDateTool_value, "f") ? new Date(__classPrivateFieldGet(this, _bbnDateTool_value, "f").getTime()) : new Date();
178
+ let str = '';
179
+ if (format) {
180
+ const parts = format.split('/(' + Object.keys(unitsCorrespondence).join('|') + ')/');
181
+ each(parts, (part) => {
182
+ if (part in unitsCorrespondence) {
183
+ const suffix = unitsMap[unitsCorrespondence[part]];
184
+ str += date['get' + suffix]();
185
+ }
186
+ else {
187
+ str += part;
188
+ }
189
+ });
190
+ }
191
+ return str;
192
+ }
193
+ unix(ms = false) {
194
+ if (__classPrivateFieldGet(this, _bbnDateTool_value, "f")) {
195
+ if (ms) {
196
+ return __classPrivateFieldGet(this, _bbnDateTool_value, "f").getTime();
197
+ }
198
+ else {
199
+ return Math.floor(__classPrivateFieldGet(this, _bbnDateTool_value, "f").getTime() / 1000);
200
+ }
201
+ }
202
+ return 0;
203
+ }
204
+ /**
205
+ * Compare this date to another date with a given precision.
206
+ * @returns -1 if this < other, 0 if equal, 1 if this > other
207
+ */
208
+ compare(date, unit = '') {
209
+ const d = new bbnDateTool(date);
210
+ const realUnit = unitsCorrespondence[unit] || null;
211
+ // If no unit or unknown unit, fall back to timestamp comparison
212
+ if (!realUnit) {
213
+ if (this.mtst < d.mtst) {
214
+ return -1;
215
+ }
216
+ if (this.mtst > d.mtst) {
217
+ return 1;
218
+ }
219
+ return 0;
220
+ }
221
+ const order = ['y', 'm', 'd', 'h', 'n', 's'];
222
+ // Compare step by step until the requested precision
223
+ for (const u of order) {
224
+ const key = unitsMap[u];
225
+ const a = this[key];
226
+ const b = d[key];
227
+ if (a < b) {
228
+ return -1;
229
+ }
230
+ if (a > b) {
231
+ return 1;
232
+ }
233
+ // Stop when we've reached the desired unit
234
+ if (u === realUnit) {
235
+ break;
236
+ }
237
+ }
238
+ return 0;
239
+ }
240
+ isBefore(date, unit = '') {
241
+ return this.compare(date, unit) === -1;
242
+ }
243
+ isAfter(date, unit = 'day') {
244
+ return this.compare(date, unit) === 1;
245
+ }
246
+ isSame(date, unit = 'day') {
247
+ return this.compare(date, unit) === 0;
248
+ }
249
+ isAfterOrSame(date, unit = '') {
250
+ return [0, 1].includes(this.compare(date, unit));
251
+ }
252
+ isBeforeOrSame(date, unit = '') {
253
+ return [-1, 0].includes(this.compare(date, unit));
254
+ }
255
+ /*
256
+ const d = new bbnDateTool(date);
257
+ if (unitsCorrespondence[unit]) {
258
+ const realUnit = unitsCorrespondence[unit];
259
+ switch (realUnit) {
260
+ case 'y':
261
+ return this.year < d.year;
262
+ case 'm':
263
+ return (this.year < d.year) || (this.year === d.year && this.month < d.month);
264
+ case 'd':
265
+ return (this.year < d.year) || (this.year === d.year && this.month < d.month) || (this.year === d.year && this.month === d.month && this.day < d.day);
266
+ case 'h':
267
+ return (this.year < d.year) || (this.year === d.year && this.month < d.month) || (this.year === d.year && this.month === d.month && this.day < d.day) || (this.year === d.year && this.month === d.month && this.day === d.day && this.hours < d.hours);
268
+ case 'n':
269
+ return (this.year < d.year) || (this.year === d.year && this.month < d.month) || (this.year === d.year && this.month === d.month && this.day < d.day) || (this.year === d.year && this.month === d.month && this.day === d.day && this.hours < d.hours) || (this.year === d.year && this.month === d.month && this.day === d.day && this.hours === d.hours && this.minutes < d.minutes);
270
+ case 's':
271
+ return (this.year < d.year) || (this.year === d.year && this.month < d.month) || (this.year === d.year && this.month === d.month && this.day < d.day) || (this.year === d.year && this.month === d.month && this.day === d.day && this.hours < d.hours) || (this.year === d.year && this.month === d.month && this.day === d.day && this.hours === d.hours && this.minutes < d.minutes) || (this.year === d.year && this.month === d.month && this.day === d.day && this.hours === d.hours && this.minutes === d.minutes && this.seconds < d.seconds);
272
+ }
273
+ }
274
+
275
+ return this.mtst < d.mtst;
276
+ }
277
+
278
+ isBeforeOrSame(date: any, unit: string = ''): Boolean {
279
+ const d = new bbnDateTool(date);
280
+ if (unitsCorrespondence[unit]) {
281
+ const realUnit = unitsCorrespondence[unit];
282
+ switch (realUnit) {
283
+ case 'y':
284
+ return this.year <= d.year;
285
+ case 'm':
286
+ return (this.year <= d.year) || (this.year === d.year && this.month <= d.month);
287
+ case 'd':
288
+ return (this.year <= d.year) || (this.year === d.year && this.month <= d.month) || (this.year === d.year && this.month === d.month && this.day <= d.day);
289
+ case 'h':
290
+ return (this.year <= d.year) || (this.year === d.year && this.month <= d.month) || (this.year === d.year && this.month === d.month && this.day <= d.day) || (this.year === d.year && this.month === d.month && this.day === d.day && this.hours <= d.hours);
291
+ case 'n':
292
+ return (this.year <= d.year) || (this.year === d.year && this.month <= d.month) || (this.year === d.year && this.month === d.month && this.day <= d.day) || (this.year === d.year && this.month === d.month && this.day === d.day && this.hours <= d.hours) || (this.year === d.year && this.month === d.month && this.day === d.day && this.hours === d.hours && this.minutes <= d.minutes);
293
+ case 's':
294
+ return (this.year <= d.year) || (this.year === d.year && this.month <= d.month) || (this.year === d.year && this.month === d.month && this.day <= d.day) || (this.year === d.year && this.month === d.month && this.day === d.day && this.hours <= d.hours) || (this.year === d.year && this.month === d.month && this.day === d.day && this.hours === d.hours && this.minutes <= d.minutes) || (this.year === d.year && this.month === d.month && this.day === d.day && this.hours === d.hours && this.minutes === d.minutes && this.seconds <= d.seconds);
295
+ }
296
+ }
297
+
298
+ return this.mtst < d.mtst;
299
+ }*/
300
+ calendar(format) {
301
+ let str = '';
302
+ if (format) {
303
+ }
304
+ return str;
305
+ }
306
+ get daysInMonth() {
307
+ if (!__classPrivateFieldGet(this, _bbnDateTool_value, "f")) {
308
+ return 0;
309
+ }
310
+ if (!__classPrivateFieldGet(this, _bbnDateTool_daysInMonth, "f")) {
311
+ switch (__classPrivateFieldGet(this, _bbnDateTool_value, "f").getMonth()) {
312
+ case 1:
313
+ if (__classPrivateFieldGet(this, _bbnDateTool_value, "f").getFullYear() % 4 === 0) {
314
+ __classPrivateFieldSet(this, _bbnDateTool_daysInMonth, 29, "f");
315
+ }
316
+ else {
317
+ __classPrivateFieldSet(this, _bbnDateTool_daysInMonth, 28, "f");
318
+ }
319
+ break;
320
+ case 0:
321
+ case 3:
322
+ case 5:
323
+ case 8:
324
+ case 10:
325
+ __classPrivateFieldSet(this, _bbnDateTool_daysInMonth, 30, "f");
326
+ break;
327
+ default:
328
+ __classPrivateFieldSet(this, _bbnDateTool_daysInMonth, 31, "f");
329
+ break;
330
+ }
331
+ }
332
+ return __classPrivateFieldGet(this, _bbnDateTool_daysInMonth, "f");
333
+ }
334
+ }
335
+ _bbnDateTool_value = new WeakMap(), _bbnDateTool_daysInMonth = new WeakMap(), _bbnDateTool_parts = new WeakMap();
336
+ function generatorFunction(value, inputFormat = null) {
337
+ return new bbnDateTool(value, inputFormat);
338
+ }
339
+ export default generatorFunction;