yummies 5.4.6 → 5.4.7

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 (290) hide show
  1. package/async.d.ts +28 -0
  2. package/async.d.ts.map +1 -0
  3. package/async.js +62 -0
  4. package/{src/common.ts → common.d.ts} +3 -14
  5. package/common.d.ts.map +1 -0
  6. package/common.js +14 -0
  7. package/complex/counter.d.ts +15 -0
  8. package/complex/counter.d.ts.map +1 -0
  9. package/complex/counter.js +17 -0
  10. package/complex/global-config.d.ts +11 -0
  11. package/complex/global-config.d.ts.map +1 -0
  12. package/complex/global-config.js +41 -0
  13. package/complex/index.d.ts +4 -0
  14. package/complex/index.d.ts.map +1 -0
  15. package/complex/modules-factory.d.ts +49 -0
  16. package/complex/modules-factory.d.ts.map +1 -0
  17. package/complex/modules-factory.js +46 -0
  18. package/cookie.d.ts +3 -0
  19. package/cookie.d.ts.map +1 -0
  20. package/cookie.js +9 -0
  21. package/css.d.ts +36 -0
  22. package/css.d.ts.map +1 -0
  23. package/css.js +20 -0
  24. package/data.d.ts +4 -0
  25. package/data.d.ts.map +1 -0
  26. package/data.js +52 -0
  27. package/date-time.d.ts +28 -0
  28. package/date-time.d.ts.map +1 -0
  29. package/date-time.js +160 -0
  30. package/device.d.ts +8 -0
  31. package/device.d.ts.map +1 -0
  32. package/device.js +21 -0
  33. package/encodings.d.ts +2 -0
  34. package/encodings.d.ts.map +1 -0
  35. package/encodings.js +267 -0
  36. package/errors.d.ts +19 -0
  37. package/errors.d.ts.map +1 -0
  38. package/errors.js +30 -0
  39. package/file.d.ts +3 -0
  40. package/file.d.ts.map +1 -0
  41. package/file.js +24 -0
  42. package/format/_exports.d.ts +5 -0
  43. package/format/_exports.d.ts.map +1 -0
  44. package/format/constants.d.ts +4 -0
  45. package/format/constants.d.ts.map +1 -0
  46. package/{src/format/constants.ts → format/constants.js} +0 -2
  47. package/format/index.d.ts +3 -0
  48. package/format/index.d.ts.map +1 -0
  49. package/{src/format/index.ts → format/index.js} +0 -1
  50. package/format/number.d.ts +36 -0
  51. package/format/number.d.ts.map +1 -0
  52. package/format/number.js +44 -0
  53. package/format/percent.d.ts +15 -0
  54. package/format/percent.d.ts.map +1 -0
  55. package/format/percent.js +23 -0
  56. package/format/skip-spaces.d.ts +5 -0
  57. package/format/skip-spaces.d.ts.map +1 -0
  58. package/format/skip-spaces.js +4 -0
  59. package/html.d.ts +44 -0
  60. package/html.d.ts.map +1 -0
  61. package/html.js +182 -0
  62. package/id.d.ts +63 -0
  63. package/id.d.ts.map +1 -0
  64. package/{src/id.ts → id.js} +6 -16
  65. package/imports.d.ts +15 -0
  66. package/imports.d.ts.map +1 -0
  67. package/imports.js +40 -0
  68. package/math.d.ts +13 -0
  69. package/math.d.ts.map +1 -0
  70. package/math.js +17 -0
  71. package/media.d.ts +20 -0
  72. package/media.d.ts.map +1 -0
  73. package/media.js +103 -0
  74. package/mobx/apply-observable.d.ts +4 -0
  75. package/mobx/apply-observable.d.ts.map +1 -0
  76. package/mobx/apply-observable.js +12 -0
  77. package/mobx/create-enhanced-atom.d.ts +11 -0
  78. package/mobx/create-enhanced-atom.d.ts.map +1 -0
  79. package/mobx/create-enhanced-atom.js +12 -0
  80. package/mobx/deep-observable-struct.d.ts +7 -0
  81. package/mobx/deep-observable-struct.d.ts.map +1 -0
  82. package/mobx/deep-observable-struct.js +57 -0
  83. package/mobx/get-mobx-administration.d.ts +6 -0
  84. package/mobx/get-mobx-administration.d.ts.map +1 -0
  85. package/mobx/get-mobx-administration.js +2 -0
  86. package/mobx/index.d.ts +6 -0
  87. package/mobx/index.d.ts.map +1 -0
  88. package/mobx/lazy-observe.d.ts +8 -0
  89. package/mobx/lazy-observe.d.ts.map +1 -0
  90. package/mobx/lazy-observe.js +43 -0
  91. package/ms.d.ts +19 -0
  92. package/ms.d.ts.map +1 -0
  93. package/ms.js +18 -0
  94. package/number.d.ts +8 -0
  95. package/number.d.ts.map +1 -0
  96. package/number.js +13 -0
  97. package/package.json +399 -3
  98. package/parser/_exports.d.ts +4 -0
  99. package/parser/_exports.d.ts.map +1 -0
  100. package/parser/index.d.ts +3 -0
  101. package/parser/index.d.ts.map +1 -0
  102. package/{src/parser/index.ts → parser/index.js} +0 -1
  103. package/parser/number.d.ts +21 -0
  104. package/parser/number.d.ts.map +1 -0
  105. package/parser/number.js +44 -0
  106. package/parser/percent.d.ts +4 -0
  107. package/parser/percent.d.ts.map +1 -0
  108. package/parser/percent.js +4 -0
  109. package/parser/string.d.ts +7 -0
  110. package/parser/string.d.ts.map +1 -0
  111. package/parser/string.js +14 -0
  112. package/price.d.ts +6 -0
  113. package/price.d.ts.map +1 -0
  114. package/price.js +17 -0
  115. package/random.d.ts +9 -0
  116. package/random.d.ts.map +1 -0
  117. package/random.js +14 -0
  118. package/react/hooks/index.d.ts +22 -0
  119. package/react/hooks/index.d.ts.map +1 -0
  120. package/react/hooks/use-abort-controller.d.ts +2 -0
  121. package/react/hooks/use-abort-controller.d.ts.map +1 -0
  122. package/react/hooks/use-abort-controller.js +11 -0
  123. package/react/hooks/use-abort-signal.d.ts +2 -0
  124. package/react/hooks/use-abort-signal.d.ts.map +1 -0
  125. package/{src/react/hooks/use-abort-signal.ts → react/hooks/use-abort-signal.js} +1 -2
  126. package/react/hooks/use-click-outside.d.ts +9 -0
  127. package/react/hooks/use-click-outside.d.ts.map +1 -0
  128. package/react/hooks/use-click-outside.js +13 -0
  129. package/react/hooks/use-constant.d.ts +9 -0
  130. package/react/hooks/use-constant.d.ts.map +1 -0
  131. package/{src/react/hooks/use-constant.ts → react/hooks/use-constant.js} +6 -9
  132. package/react/hooks/use-define-ref.d.ts +10 -0
  133. package/react/hooks/use-define-ref.d.ts.map +1 -0
  134. package/{src/react/hooks/use-define-ref.ts → react/hooks/use-define-ref.js} +7 -10
  135. package/react/hooks/use-element-ref.d.ts +2 -0
  136. package/react/hooks/use-element-ref.d.ts.map +1 -0
  137. package/react/hooks/use-element-ref.js +8 -0
  138. package/react/hooks/use-event-listener.d.ts +8 -0
  139. package/react/hooks/use-event-listener.d.ts.map +1 -0
  140. package/react/hooks/use-event-listener.js +13 -0
  141. package/react/hooks/use-event.d.ts +3 -0
  142. package/react/hooks/use-event.d.ts.map +1 -0
  143. package/react/hooks/use-event.js +19 -0
  144. package/react/hooks/use-flag.d.ts +8 -0
  145. package/react/hooks/use-flag.d.ts.map +1 -0
  146. package/react/hooks/use-flag.js +15 -0
  147. package/react/hooks/use-force-update.d.ts +2 -0
  148. package/react/hooks/use-force-update.d.ts.map +1 -0
  149. package/react/hooks/use-force-update.js +7 -0
  150. package/react/hooks/use-initial-height.d.ts +5 -0
  151. package/react/hooks/use-initial-height.d.ts.map +1 -0
  152. package/react/hooks/use-initial-height.js +11 -0
  153. package/react/hooks/use-instance.d.ts +27 -0
  154. package/react/hooks/use-instance.d.ts.map +1 -0
  155. package/{src/react/hooks/use-instance.ts → react/hooks/use-instance.js} +7 -29
  156. package/react/hooks/use-intersection-observer.d.ts +2 -0
  157. package/react/hooks/use-intersection-observer.d.ts.map +1 -0
  158. package/react/hooks/use-intersection-observer.js +10 -0
  159. package/react/hooks/use-last-defined-value.d.ts +2 -0
  160. package/react/hooks/use-last-defined-value.d.ts.map +1 -0
  161. package/react/hooks/use-last-defined-value.js +8 -0
  162. package/react/hooks/use-last-value-ref.d.ts +2 -0
  163. package/react/hooks/use-last-value-ref.d.ts.map +1 -0
  164. package/react/hooks/use-last-value-ref.js +8 -0
  165. package/react/hooks/use-life-cycle.d.ts +5 -0
  166. package/react/hooks/use-life-cycle.d.ts.map +1 -0
  167. package/react/hooks/use-life-cycle.js +10 -0
  168. package/react/hooks/use-resize-observer.d.ts +2 -0
  169. package/react/hooks/use-resize-observer.d.ts.map +1 -0
  170. package/react/hooks/use-resize-observer.js +11 -0
  171. package/react/hooks/use-sync-ref.d.ts +2 -0
  172. package/react/hooks/use-sync-ref.d.ts.map +1 -0
  173. package/react/hooks/use-sync-ref.js +6 -0
  174. package/react/hooks/use-toggle.d.ts +2 -0
  175. package/react/hooks/use-toggle.d.ts.map +1 -0
  176. package/react/hooks/use-toggle.js +6 -0
  177. package/react/hooks/use-value.d.ts +5 -0
  178. package/react/hooks/use-value.d.ts.map +1 -0
  179. package/react/hooks/use-value.js +8 -0
  180. package/react/hooks/use-visibility-state.d.ts +2 -0
  181. package/react/hooks/use-visibility-state.d.ts.map +1 -0
  182. package/react/hooks/use-visibility-state.js +14 -0
  183. package/react/index.d.ts +2 -0
  184. package/react/index.d.ts.map +1 -0
  185. package/sound.d.ts +7 -0
  186. package/sound.d.ts.map +1 -0
  187. package/sound.js +12 -0
  188. package/storage.d.ts +39 -0
  189. package/storage.d.ts.map +1 -0
  190. package/storage.js +43 -0
  191. package/text.d.ts +15 -0
  192. package/text.d.ts.map +1 -0
  193. package/text.js +48 -0
  194. package/type-guard/_exports.d.ts +86 -0
  195. package/type-guard/_exports.d.ts.map +1 -0
  196. package/type-guard/_exports.js +125 -0
  197. package/type-guard/index.d.ts +3 -0
  198. package/type-guard/index.d.ts.map +1 -0
  199. package/{src/type-guard/index.ts → type-guard/index.js} +0 -1
  200. package/utility-types.d.ts +395 -0
  201. package/utils/types.d.ts +395 -0
  202. package/utils/types.d.ts.map +1 -0
  203. package/utils/types.js +1 -0
  204. package/vibrate.d.ts +5 -0
  205. package/vibrate.d.ts.map +1 -0
  206. package/vibrate.js +8 -0
  207. package/.changeset/README.md +0 -8
  208. package/.changeset/config.json +0 -11
  209. package/.github/FUNDING.yml +0 -1
  210. package/.github/workflows/main.yml +0 -34
  211. package/.github/workflows/version-or-publish.yml +0 -45
  212. package/.nvmrc +0 -1
  213. package/.vscode/settings.json +0 -19
  214. package/CHANGELOG.md +0 -215
  215. package/CONTRIBUTING.md +0 -8
  216. package/Makefile +0 -7
  217. package/biome.json +0 -3
  218. package/commitfmt.toml +0 -18
  219. package/lefthook.yml +0 -14
  220. package/scripts/post-build.ts +0 -71
  221. package/src/async.ts +0 -86
  222. package/src/complex/counter.test.ts +0 -41
  223. package/src/complex/counter.ts +0 -40
  224. package/src/complex/global-config.ts +0 -55
  225. package/src/complex/modules-factory.ts +0 -65
  226. package/src/cookie.ts +0 -11
  227. package/src/css.ts +0 -60
  228. package/src/data.test.ts +0 -99
  229. package/src/data.ts +0 -65
  230. package/src/date-time.test.ts +0 -119
  231. package/src/date-time.ts +0 -236
  232. package/src/device.ts +0 -42
  233. package/src/encodings.ts +0 -270
  234. package/src/errors.ts +0 -40
  235. package/src/file.ts +0 -25
  236. package/src/format/number.test.ts +0 -16
  237. package/src/format/number.ts +0 -96
  238. package/src/format/percent.ts +0 -40
  239. package/src/format/skip-spaces.ts +0 -4
  240. package/src/html.ts +0 -238
  241. package/src/imports.ts +0 -52
  242. package/src/math.ts +0 -20
  243. package/src/media.ts +0 -134
  244. package/src/mobx/apply-observable.ts +0 -20
  245. package/src/mobx/create-enhanced-atom.ts +0 -28
  246. package/src/mobx/deep-observable-struct.test.ts +0 -69
  247. package/src/mobx/deep-observable-struct.ts +0 -69
  248. package/src/mobx/get-mobx-administration.ts +0 -10
  249. package/src/mobx/lazy-observe.ts +0 -59
  250. package/src/ms.ts +0 -20
  251. package/src/number.ts +0 -14
  252. package/src/parser/number.test.ts +0 -38
  253. package/src/parser/number.ts +0 -73
  254. package/src/parser/percent.ts +0 -11
  255. package/src/parser/string.ts +0 -29
  256. package/src/price.ts +0 -33
  257. package/src/random.ts +0 -27
  258. package/src/react/hooks/use-abort-controller.ts +0 -15
  259. package/src/react/hooks/use-click-outside.ts +0 -27
  260. package/src/react/hooks/use-element-ref.ts +0 -11
  261. package/src/react/hooks/use-event-listener.ts +0 -29
  262. package/src/react/hooks/use-event.ts +0 -23
  263. package/src/react/hooks/use-flag.ts +0 -27
  264. package/src/react/hooks/use-force-update.ts +0 -9
  265. package/src/react/hooks/use-initial-height.ts +0 -16
  266. package/src/react/hooks/use-intersection-observer.ts +0 -18
  267. package/src/react/hooks/use-last-defined-value.ts +0 -9
  268. package/src/react/hooks/use-last-value-ref.ts +0 -11
  269. package/src/react/hooks/use-life-cycle.ts +0 -17
  270. package/src/react/hooks/use-resize-observer.ts +0 -14
  271. package/src/react/hooks/use-sync-ref.ts +0 -7
  272. package/src/react/hooks/use-toggle.ts +0 -9
  273. package/src/react/hooks/use-value.ts +0 -10
  274. package/src/react/hooks/use-visibility-state.ts +0 -19
  275. package/src/sound.ts +0 -15
  276. package/src/storage.ts +0 -137
  277. package/src/text.test.ts +0 -91
  278. package/src/text.ts +0 -60
  279. package/src/type-guard/_exports.ts +0 -154
  280. package/src/type-guard/index.test.ts +0 -127
  281. package/src/vibrate.ts +0 -8
  282. package/tsconfig.json +0 -26
  283. package/tsconfig.test.json +0 -33
  284. package/vitest.config.ts +0 -20
  285. /package/{src/complex/index.ts → complex/index.js} +0 -0
  286. /package/{src/format/_exports.ts → format/_exports.js} +0 -0
  287. /package/{src/mobx/index.ts → mobx/index.js} +0 -0
  288. /package/{src/parser/_exports.ts → parser/_exports.js} +0 -0
  289. /package/{src/react/hooks/index.ts → react/hooks/index.js} +0 -0
  290. /package/{src/react/index.ts → react/index.js} +0 -0
@@ -0,0 +1,12 @@
1
+ import { makeObservable } from 'mobx';
2
+ export const applyObservable = (context, annotationsArray, useDecorators) => {
3
+ if (useDecorators) {
4
+ annotationsArray.forEach(([field, annotation]) => {
5
+ annotation(context, field);
6
+ });
7
+ makeObservable(context);
8
+ }
9
+ else {
10
+ makeObservable(context, Object.fromEntries(annotationsArray));
11
+ }
12
+ };
@@ -0,0 +1,11 @@
1
+ import { type IAtom } from 'mobx';
2
+ import type { AnyObject } from '../utils/types.js';
3
+ export interface IEnhancedAtom<TMeta extends AnyObject = AnyObject> extends IAtom {
4
+ meta: TMeta;
5
+ }
6
+ /**
7
+ * Creates an enhanced atom with meta data
8
+ * And bind `reportChanged` and `reportObserved` method to the atom
9
+ */
10
+ export declare const createEnhancedAtom: <TMeta extends AnyObject>(name: string, onBecomeObservedHandler?: (atom: IEnhancedAtom<TMeta>) => void, onBecomeUnobservedHandler?: (atom: IEnhancedAtom<TMeta>) => void, meta?: TMeta) => IEnhancedAtom<TMeta>;
11
+ //# sourceMappingURL=create-enhanced-atom.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-enhanced-atom.d.ts","sourceRoot":"","sources":["../../src/mobx/create-enhanced-atom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,KAAK,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,MAAM,WAAW,aAAa,CAAC,KAAK,SAAS,SAAS,GAAG,SAAS,CAChE,SAAQ,KAAK;IACb,IAAI,EAAE,KAAK,CAAC;CACb;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,KAAK,SAAS,SAAS,EACxD,MAAM,MAAM,EACZ,0BAA0B,CAAC,IAAI,EAAE,aAAa,CAAC,KAAK,CAAC,KAAK,IAAI,EAC9D,4BAA4B,CAAC,IAAI,EAAE,aAAa,CAAC,KAAK,CAAC,KAAK,IAAI,EAChE,OAAO,KAAK,KACX,aAAa,CAAC,KAAK,CAUrB,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { createAtom } from 'mobx';
2
+ /**
3
+ * Creates an enhanced atom with meta data
4
+ * And bind `reportChanged` and `reportObserved` method to the atom
5
+ */
6
+ export const createEnhancedAtom = (name, onBecomeObservedHandler, onBecomeUnobservedHandler, meta) => {
7
+ const atom = createAtom(name, onBecomeObservedHandler && (() => onBecomeObservedHandler?.(atom)), onBecomeUnobservedHandler && (() => onBecomeUnobservedHandler?.(atom)));
8
+ atom.meta = meta ?? {};
9
+ atom.reportChanged = atom.reportChanged.bind(atom);
10
+ atom.reportObserved = atom.reportObserved.bind(atom);
11
+ return atom;
12
+ };
@@ -0,0 +1,7 @@
1
+ import type { AnyObject } from '../utils/types.js';
2
+ export declare class DeepObservableStruct<TData extends AnyObject> {
3
+ data: TData;
4
+ constructor(data: TData);
5
+ set(newData: Partial<TData>): void;
6
+ }
7
+ //# sourceMappingURL=deep-observable-struct.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deep-observable-struct.d.ts","sourceRoot":"","sources":["../../src/mobx/deep-observable-struct.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,qBAAa,oBAAoB,CAAC,KAAK,SAAS,SAAS;IACvD,IAAI,EAAE,KAAK,CAAC;gBAEA,IAAI,EAAE,KAAK;IASvB,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC;CAoD5B"}
@@ -0,0 +1,57 @@
1
+ import { action, makeObservable, observable } from 'mobx';
2
+ import { typeGuard } from '../type-guard/index.js';
3
+ export class DeepObservableStruct {
4
+ data;
5
+ constructor(data) {
6
+ this.data = data;
7
+ makeObservable(this, {
8
+ data: observable.deep,
9
+ set: action,
10
+ });
11
+ }
12
+ set(newData) {
13
+ const stack = Object.keys(this.data).map((key) => [
14
+ key,
15
+ this.data,
16
+ newData,
17
+ ]);
18
+ let currentIndex = 0;
19
+ let stackLength = stack.length;
20
+ while (currentIndex < stackLength) {
21
+ const [key, currObservableData, newData] = stack[currentIndex];
22
+ const newValue = newData[key];
23
+ const currValue = currObservableData[key];
24
+ currentIndex++;
25
+ if (key in newData) {
26
+ if (typeGuard.isObject(newValue) && typeGuard.isObject(currValue)) {
27
+ const newValueKeys = Object.keys(newValue);
28
+ Object.keys(currValue).forEach((childKey) => {
29
+ if (!(childKey in newValue)) {
30
+ delete currObservableData[key][childKey];
31
+ }
32
+ });
33
+ newValueKeys.forEach((childKey) => {
34
+ const length = stack.push([
35
+ childKey,
36
+ currObservableData[key],
37
+ newValue,
38
+ ]);
39
+ stackLength = length;
40
+ });
41
+ }
42
+ else if (newValue !== currValue) {
43
+ currObservableData[key] = newValue;
44
+ }
45
+ }
46
+ else {
47
+ delete currObservableData[key];
48
+ }
49
+ }
50
+ Object.keys(newData).forEach((newDataKey) => {
51
+ if (!this.data[newDataKey]) {
52
+ // @ts-expect-error
53
+ this.data[newDataKey] = newData[newDataKey];
54
+ }
55
+ });
56
+ }
57
+ }
@@ -0,0 +1,6 @@
1
+ import { type AnnotationMapEntry } from 'mobx';
2
+ import type { AnyObject } from '../utils/types.js';
3
+ type ObservableObjectAdministration = Parameters<Exclude<AnnotationMapEntry, boolean>['make_']>[0];
4
+ export declare const getMobxAdministration: (context: AnyObject) => ObservableObjectAdministration;
5
+ export {};
6
+ //# sourceMappingURL=get-mobx-administration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-mobx-administration.d.ts","sourceRoot":"","sources":["../../src/mobx/get-mobx-administration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,kBAAkB,EAAE,MAAM,MAAM,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,KAAK,8BAA8B,GAAG,UAAU,CAC9C,OAAO,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,CAC9C,CAAC,CAAC,CAAC,CAAC;AAEL,eAAO,MAAM,qBAAqB,GAChC,SAAS,SAAS,KACjB,8BAAgD,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { $mobx } from 'mobx';
2
+ export const getMobxAdministration = (context) => context[$mobx];
@@ -0,0 +1,6 @@
1
+ export * from './apply-observable.js';
2
+ export * from './create-enhanced-atom.js';
3
+ export * from './deep-observable-struct.js';
4
+ export * from './get-mobx-administration.js';
5
+ export * from './lazy-observe.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mobx/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,8 @@
1
+ export declare const lazyObserve: <TMetaData = void>({ context, property, onStart, onEnd, endDelay, }: {
2
+ context?: any;
3
+ property: any | any[];
4
+ onStart: () => TMetaData;
5
+ onEnd: (metaData: TMetaData, cleanupFn: VoidFunction) => void;
6
+ endDelay?: number;
7
+ }) => () => void;
8
+ //# sourceMappingURL=lazy-observe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lazy-observe.d.ts","sourceRoot":"","sources":["../../src/mobx/lazy-observe.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,GAAI,SAAS,GAAG,IAAI,EAAE,kDAM3C;IACD,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,QAAQ,EAAE,GAAG,GAAG,GAAG,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,SAAS,CAAC;IACzB,KAAK,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,KAAK,IAAI,CAAC;IAC9D,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,eA4CA,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { onBecomeObserved, onBecomeUnobserved } from 'mobx';
2
+ export const lazyObserve = ({ context, property, onStart, onEnd, endDelay = 0, }) => {
3
+ let timeoutId;
4
+ let metaData;
5
+ const properties = Array.isArray(property) ? property : [property];
6
+ let isObserving = false;
7
+ const start = () => {
8
+ if (isObserving) {
9
+ return;
10
+ }
11
+ isObserving = true;
12
+ if (timeoutId) {
13
+ clearTimeout(timeoutId);
14
+ timeoutId = undefined;
15
+ }
16
+ metaData = onStart();
17
+ };
18
+ const cleanup = () => {
19
+ if (!isObserving) {
20
+ return;
21
+ }
22
+ if (timeoutId) {
23
+ clearTimeout(timeoutId);
24
+ timeoutId = undefined;
25
+ }
26
+ timeoutId = setTimeout(() => {
27
+ onEnd(metaData, cleanup);
28
+ timeoutId = undefined;
29
+ metaData = undefined;
30
+ }, endDelay);
31
+ };
32
+ properties.forEach((property) => {
33
+ if (context) {
34
+ onBecomeObserved(context, property, start);
35
+ onBecomeUnobserved(context, property, cleanup);
36
+ }
37
+ else {
38
+ onBecomeObserved(property, start);
39
+ onBecomeUnobserved(property, cleanup);
40
+ }
41
+ });
42
+ return cleanup;
43
+ };
package/ms.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ export declare const unitsToMs: {
2
+ readonly ms: 1;
3
+ readonly sec: 1000;
4
+ readonly min: number;
5
+ readonly hour: number;
6
+ readonly day: number;
7
+ readonly week: number;
8
+ };
9
+ /**
10
+ * Переводит значение в юнитах в миллисекунды
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * ms(1, 'min') // 60_000
15
+ * ms(30, 'sec') // 30_000
16
+ * ```
17
+ */
18
+ export declare const ms: (value: number, unit?: keyof typeof unitsToMs) => number;
19
+ //# sourceMappingURL=ms.d.ts.map
package/ms.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ms.d.ts","sourceRoot":"","sources":["../src/ms.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS;;;;;;;CAOZ,CAAC;AAEX;;;;;;;;GAQG;AACH,eAAO,MAAM,EAAE,GAAI,OAAO,MAAM,EAAE,OAAM,MAAM,OAAO,SAAgB,WAC5C,CAAC"}
package/ms.js ADDED
@@ -0,0 +1,18 @@
1
+ export const unitsToMs = {
2
+ ms: 1,
3
+ sec: 1000,
4
+ min: 1000 * 60,
5
+ hour: 1000 * 60 * 60,
6
+ day: 1000 * 60 * 60 * 24,
7
+ week: 1000 * 60 * 60 * 24 * 7,
8
+ };
9
+ /**
10
+ * Переводит значение в юнитах в миллисекунды
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * ms(1, 'min') // 60_000
15
+ * ms(30, 'sec') // 30_000
16
+ * ```
17
+ */
18
+ export const ms = (value, unit = 'ms') => value * unitsToMs[unit];
package/number.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Works like `parseFloat(number.toFixed(4))` but performance better
3
+ *
4
+ * @example
5
+ * round(191.212999999999999999999999, 4) // 191.213
6
+ */
7
+ export declare function round(value: number, decimalPlaces?: number): number;
8
+ //# sourceMappingURL=number.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../src/number.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,GAAE,MAAU,GAAG,MAAM,CAOtE"}
package/number.js ADDED
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Works like `parseFloat(number.toFixed(4))` but performance better
3
+ *
4
+ * @example
5
+ * round(191.212999999999999999999999, 4) // 191.213
6
+ */
7
+ export function round(value, decimalPlaces = 0) {
8
+ if (!decimalPlaces) {
9
+ return Math.round(value);
10
+ }
11
+ const factor = 10 ** decimalPlaces;
12
+ return Math.round(value * factor) / factor;
13
+ }