@iobroker/adapter-react-v5 0.0.2

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 (264) hide show
  1. package/Components/404.js +155 -0
  2. package/Components/404.js.map +1 -0
  3. package/Components/ColorPicker.js +313 -0
  4. package/Components/ColorPicker.js.map +1 -0
  5. package/Components/ComplexCron.js +606 -0
  6. package/Components/ComplexCron.js.map +1 -0
  7. package/Components/FileBrowser.js +2147 -0
  8. package/Components/FileBrowser.js.map +1 -0
  9. package/Components/FileViewer.js +245 -0
  10. package/Components/FileViewer.js.map +1 -0
  11. package/Components/Icon.js +234 -0
  12. package/Components/Icon.js.map +1 -0
  13. package/Components/IconPicker.js +188 -0
  14. package/Components/IconPicker.js.map +1 -0
  15. package/Components/IconSelector.js +337 -0
  16. package/Components/IconSelector.js.map +1 -0
  17. package/Components/Image.js +215 -0
  18. package/Components/Image.js.map +1 -0
  19. package/Components/Loader.js +134 -0
  20. package/Components/Loader.js.map +1 -0
  21. package/Components/Loaders/PT.css +109 -0
  22. package/Components/Loaders/PT.js +104 -0
  23. package/Components/Loaders/PT.js.map +1 -0
  24. package/Components/Loaders/Vendor.css +13 -0
  25. package/Components/Loaders/Vendor.js +108 -0
  26. package/Components/Loaders/Vendor.js.map +1 -0
  27. package/Components/Logo.js +230 -0
  28. package/Components/Logo.js.map +1 -0
  29. package/Components/MDUtils.js +141 -0
  30. package/Components/MDUtils.js.map +1 -0
  31. package/Components/ObjectBrowser.js +6119 -0
  32. package/Components/ObjectBrowser.js.map +1 -0
  33. package/Components/Router.js +152 -0
  34. package/Components/Router.js.map +1 -0
  35. package/Components/SaveCloseButtons.js +177 -0
  36. package/Components/SaveCloseButtons.js.map +1 -0
  37. package/Components/Schedule.js +1891 -0
  38. package/Components/Schedule.js.map +1 -0
  39. package/Components/SelectWithIcon.js +235 -0
  40. package/Components/SelectWithIcon.js.map +1 -0
  41. package/Components/SimpleCron/cron2text.js +563 -0
  42. package/Components/SimpleCron/cron2text.js.map +1 -0
  43. package/Components/SimpleCron/cronText.js +60 -0
  44. package/Components/SimpleCron/cronText.js.map +1 -0
  45. package/Components/SimpleCron/index.js +861 -0
  46. package/Components/SimpleCron/index.js.map +1 -0
  47. package/Components/SimpleCron/jquery.cron.locale.js +322 -0
  48. package/Components/SimpleCron/jquery.cron.locale.js.map +1 -0
  49. package/Components/TabContainer.js +108 -0
  50. package/Components/TabContainer.js.map +1 -0
  51. package/Components/TabContent.js +96 -0
  52. package/Components/TabContent.js.map +1 -0
  53. package/Components/TabHeader.js +72 -0
  54. package/Components/TabHeader.js.map +1 -0
  55. package/Components/TextWithIcon.js +148 -0
  56. package/Components/TextWithIcon.js.map +1 -0
  57. package/Components/ToggleThemeMenu.js +49 -0
  58. package/Components/ToggleThemeMenu.js.map +1 -0
  59. package/Components/TreeTable.js +1030 -0
  60. package/Components/TreeTable.js.map +1 -0
  61. package/Components/Utils.js +1763 -0
  62. package/Components/Utils.js.map +1 -0
  63. package/Components/copy-to-clipboard.js +183 -0
  64. package/Components/copy-to-clipboard.js.map +1 -0
  65. package/Components/loader.css +222 -0
  66. package/Components/types.d.ts +121 -0
  67. package/Connection.js +3334 -0
  68. package/Connection.js.map +1 -0
  69. package/Dialogs/ComplexCron.js +193 -0
  70. package/Dialogs/ComplexCron.js.map +1 -0
  71. package/Dialogs/Confirm.js +211 -0
  72. package/Dialogs/Confirm.js.map +1 -0
  73. package/Dialogs/Cron.js +254 -0
  74. package/Dialogs/Cron.js.map +1 -0
  75. package/Dialogs/Error.js +137 -0
  76. package/Dialogs/Error.js.map +1 -0
  77. package/Dialogs/Message.js +118 -0
  78. package/Dialogs/Message.js.map +1 -0
  79. package/Dialogs/SelectID.js +313 -0
  80. package/Dialogs/SelectID.js.map +1 -0
  81. package/Dialogs/SimpleCron.js +177 -0
  82. package/Dialogs/SimpleCron.js.map +1 -0
  83. package/Dialogs/TextInput.js +194 -0
  84. package/Dialogs/TextInput.js.map +1 -0
  85. package/GenericApp.js +1022 -0
  86. package/GenericApp.js.map +1 -0
  87. package/LICENSE +22 -0
  88. package/Prompt.js +21 -0
  89. package/Prompt.js.map +1 -0
  90. package/README.md +645 -0
  91. package/Theme.js +422 -0
  92. package/Theme.js.map +1 -0
  93. package/assets/devices/Alarm Systems.svg +19 -0
  94. package/assets/devices/Amplifier.svg +22 -0
  95. package/assets/devices/Awnings.svg +5 -0
  96. package/assets/devices/Battery Status.svg +5 -0
  97. package/assets/devices/Ceiling Spotlights.svg +16 -0
  98. package/assets/devices/Chandelier.svg +7 -0
  99. package/assets/devices/Climate.svg +12 -0
  100. package/assets/devices/Coffee Makers.svg +6 -0
  101. package/assets/devices/Cold Water.svg +31 -0
  102. package/assets/devices/Computer.svg +21 -0
  103. package/assets/devices/Consumption.svg +8 -0
  104. package/assets/devices/Curtains.svg +43 -0
  105. package/assets/devices/Dishwashers.svg +12 -0
  106. package/assets/devices/Doors.svg +6 -0
  107. package/assets/devices/Doorstep.svg +35 -0
  108. package/assets/devices/Dryer.svg +14 -0
  109. package/assets/devices/Fan.svg +20 -0
  110. package/assets/devices/Floor Lamps.svg +5 -0
  111. package/assets/devices/Garage Doors.svg +9 -0
  112. package/assets/devices/Gates.svg +32 -0
  113. package/assets/devices/Hairdryer.svg +23 -0
  114. package/assets/devices/Handle.svg +6 -0
  115. package/assets/devices/Hanging Lamps.svg +9 -0
  116. package/assets/devices/Heater.svg +44 -0
  117. package/assets/devices/Hoods.svg +12 -0
  118. package/assets/devices/Hot Water.svg +10 -0
  119. package/assets/devices/Humidity.svg +41 -0
  120. package/assets/devices/Iron.svg +5 -0
  121. package/assets/devices/Irrigation.svg +42 -0
  122. package/assets/devices/Led Strip.svg +31 -0
  123. package/assets/devices/Light.svg +30 -0
  124. package/assets/devices/Lightings.svg +46 -0
  125. package/assets/devices/Lock.svg +19 -0
  126. package/assets/devices/Louvre.svg +7 -0
  127. package/assets/devices/Mowing Machine.svg +9 -0
  128. package/assets/devices/Music.svg +13 -0
  129. package/assets/devices/Outdoor Blinds.svg +7 -0
  130. package/assets/devices/People.svg +19 -0
  131. package/assets/devices/Pool.svg +8 -0
  132. package/assets/devices/Power Consumption.svg +13 -0
  133. package/assets/devices/Printer.svg +10 -0
  134. package/assets/devices/Pump.svg +10 -0
  135. package/assets/devices/Receiver.svg +19 -0
  136. package/assets/devices/Sconces.svg +10 -0
  137. package/assets/devices/Security.svg +34 -0
  138. package/assets/devices/Shading.svg +5 -0
  139. package/assets/devices/Shutters.svg +11 -0
  140. package/assets/devices/SmokeDetector.svg +13 -0
  141. package/assets/devices/Sockets.svg +13 -0
  142. package/assets/devices/Speaker.svg +35 -0
  143. package/assets/devices/Stove.svg +12 -0
  144. package/assets/devices/Table Lamps.svg +12 -0
  145. package/assets/devices/Temperature Sensors.svg +28 -0
  146. package/assets/devices/Tv.svg +8 -0
  147. package/assets/devices/Vacuum Cleaner.svg +16 -0
  148. package/assets/devices/Ventilation.svg +12 -0
  149. package/assets/devices/Washing Machines.svg +16 -0
  150. package/assets/devices/Water Consumption.svg +6 -0
  151. package/assets/devices/Water Heater.svg +8 -0
  152. package/assets/devices/Water.svg +40 -0
  153. package/assets/devices/Weather.svg +28 -0
  154. package/assets/devices/Window.svg +8 -0
  155. package/assets/devices/list.json +994 -0
  156. package/assets/devices/names.txt +63 -0
  157. package/assets/devices/parseNames.js +34 -0
  158. package/assets/lamp_ceiling.svg +9 -0
  159. package/assets/lamp_table.svg +8 -0
  160. package/assets/no_icon.svg +9 -0
  161. package/assets/rooms/Anteroom.svg +53 -0
  162. package/assets/rooms/Attic.svg +21 -0
  163. package/assets/rooms/Balcony.svg +13 -0
  164. package/assets/rooms/Barn.svg +6 -0
  165. package/assets/rooms/Basement.svg +5 -0
  166. package/assets/rooms/Bathroom.svg +38 -0
  167. package/assets/rooms/Bedroom.svg +5 -0
  168. package/assets/rooms/Boiler Room.svg +13 -0
  169. package/assets/rooms/Carport.svg +17 -0
  170. package/assets/rooms/Cellar.svg +89 -0
  171. package/assets/rooms/Chamber.svg +9 -0
  172. package/assets/rooms/Corridor.svg +53 -0
  173. package/assets/rooms/Dining Area.svg +37 -0
  174. package/assets/rooms/Dining Room.svg +37 -0
  175. package/assets/rooms/Dining.svg +37 -0
  176. package/assets/rooms/Dressing Room.svg +5 -0
  177. package/assets/rooms/Driveway.svg +15 -0
  178. package/assets/rooms/Entrance.svg +44 -0
  179. package/assets/rooms/Equipment Room.svg +15 -0
  180. package/assets/rooms/Front Yard.svg +64 -0
  181. package/assets/rooms/Gallery.svg +14 -0
  182. package/assets/rooms/Garage.svg +20 -0
  183. package/assets/rooms/Garden.svg +13 -0
  184. package/assets/rooms/Ground Floor.svg +95 -0
  185. package/assets/rooms/Guest Bathroom.svg +33 -0
  186. package/assets/rooms/Guest Room.svg +5 -0
  187. package/assets/rooms/Gym.svg +5 -0
  188. package/assets/rooms/Hall.svg +19 -0
  189. package/assets/rooms/Home Theater.svg +8 -0
  190. package/assets/rooms/Kitchen.svg +18 -0
  191. package/assets/rooms/Laundry Room.svg +12 -0
  192. package/assets/rooms/Living Area.svg +11 -0
  193. package/assets/rooms/Living Room.svg +10 -0
  194. package/assets/rooms/Locker Room.svg +17 -0
  195. package/assets/rooms/Nursery.svg +5 -0
  196. package/assets/rooms/Office.svg +8 -0
  197. package/assets/rooms/Outdoors.svg +7 -0
  198. package/assets/rooms/Playroom.svg +6 -0
  199. package/assets/rooms/Pool.svg +8 -0
  200. package/assets/rooms/Rear Wall.svg +30 -0
  201. package/assets/rooms/Second Floor.svg +95 -0
  202. package/assets/rooms/Shed.svg +16 -0
  203. package/assets/rooms/Sleeping Area.svg +22 -0
  204. package/assets/rooms/Stairway.svg +5 -0
  205. package/assets/rooms/Stairwell.svg +15 -0
  206. package/assets/rooms/Storeroom.svg +5 -0
  207. package/assets/rooms/Summer House.svg +27 -0
  208. package/assets/rooms/Swimming Pool.svg +21 -0
  209. package/assets/rooms/Terrace.svg +7 -0
  210. package/assets/rooms/Toilet.svg +10 -0
  211. package/assets/rooms/Upstairs.svg +6 -0
  212. package/assets/rooms/Wardrobe.svg +60 -0
  213. package/assets/rooms/Washroom.svg +20 -0
  214. package/assets/rooms/Wc.svg +10 -0
  215. package/assets/rooms/Windscreen.svg +60 -0
  216. package/assets/rooms/Workshop.svg +23 -0
  217. package/assets/rooms/Workspace.svg +8 -0
  218. package/assets/rooms/list.json +946 -0
  219. package/assets/rooms/names.txt +60 -0
  220. package/assets/rooms/parseNames.js +34 -0
  221. package/gulpfile.js +113 -0
  222. package/i18n/de.json +280 -0
  223. package/i18n/en.json +280 -0
  224. package/i18n/es.json +267 -0
  225. package/i18n/fr.json +267 -0
  226. package/i18n/it.json +267 -0
  227. package/i18n/nl.json +267 -0
  228. package/i18n/pl.json +267 -0
  229. package/i18n/pt.json +267 -0
  230. package/i18n/ru.json +280 -0
  231. package/i18n/zh-cn.json +267 -0
  232. package/i18n.js +171 -0
  233. package/i18n.js.map +1 -0
  234. package/icons/IconAdapter.js +39 -0
  235. package/icons/IconAdapter.js.map +1 -0
  236. package/icons/IconAlias.js +39 -0
  237. package/icons/IconAlias.js.map +1 -0
  238. package/icons/IconChannel.js +80 -0
  239. package/icons/IconChannel.js.map +1 -0
  240. package/icons/IconClearFilter.js +41 -0
  241. package/icons/IconClearFilter.js.map +1 -0
  242. package/icons/IconClosed.js +39 -0
  243. package/icons/IconClosed.js.map +1 -0
  244. package/icons/IconCopy.js +48 -0
  245. package/icons/IconCopy.js.map +1 -0
  246. package/icons/IconDevice.js +147 -0
  247. package/icons/IconDevice.js.map +1 -0
  248. package/icons/IconDocument.js +39 -0
  249. package/icons/IconDocument.js.map +1 -0
  250. package/icons/IconExpert.js +50 -0
  251. package/icons/IconExpert.js.map +1 -0
  252. package/icons/IconFx.js +39 -0
  253. package/icons/IconFx.js.map +1 -0
  254. package/icons/IconInstance.js +39 -0
  255. package/icons/IconInstance.js.map +1 -0
  256. package/icons/IconLogout.js +50 -0
  257. package/icons/IconLogout.js.map +1 -0
  258. package/icons/IconOpen.js +39 -0
  259. package/icons/IconOpen.js.map +1 -0
  260. package/icons/IconState.js +58 -0
  261. package/icons/IconState.js.map +1 -0
  262. package/index.css +55 -0
  263. package/package.json +42 -0
  264. package/types.d.ts +84 -0
@@ -0,0 +1,563 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ /**
9
+ * Given a cronspec, return the human-readable string.
10
+ * @param {string} cronspec
11
+ * @param withSeconds
12
+ * @param {Object=} locale
13
+ */
14
+ function cronToText(cronspec, withSeconds, locale) {
15
+ // Constant array to convert valid names to values
16
+ var NAMES = {
17
+ JAN: 1,
18
+ FEB: 2,
19
+ MAR: 3,
20
+ APR: 4,
21
+ MAY: 5,
22
+ JUN: 6,
23
+ JUL: 7,
24
+ AUG: 8,
25
+ SEP: 9,
26
+ OCT: 10,
27
+ NOV: 11,
28
+ DEC: 12,
29
+ SUN: 1,
30
+ MON: 2,
31
+ TUE: 3,
32
+ WED: 4,
33
+ THU: 5,
34
+ FRI: 6,
35
+ SAT: 7
36
+ }; // Parsable replacements for common expressions
37
+
38
+ var REPLACEMENTS = {
39
+ '* * * * * *': '0/1 * * * * *',
40
+ '@YEARLY': '0 0 1 1 *',
41
+ '@ANNUALLY': '0 0 1 1 *',
42
+ '@MONTHLY': '0 0 1 * *',
43
+ '@WEEKLY': '0 0 * * 0',
44
+ '@DAILY': '0 0 * * *',
45
+ '@HOURLY': '0 * * * *'
46
+ }; // Contains the index, min, and max for each of the constraints
47
+
48
+ var FIELDS = {
49
+ s: [0, 0, 59],
50
+ // seconds
51
+ m: [1, 0, 59],
52
+ // minutes
53
+ h: [2, 0, 23],
54
+ // hours
55
+ D: [3, 1, 31],
56
+ // day of month
57
+ M: [4, 1, 12],
58
+ // month
59
+ Y: [6, 1970, 2099],
60
+ // year
61
+ d: [5, 1, 7, 1] // day of week
62
+
63
+ };
64
+ /**
65
+ * Returns the value + offset if value is a number, otherwise it
66
+ * attempts to look up the value in the NAMES table and returns
67
+ * that result instead.
68
+ *
69
+ * @param {Number,String} value: The value that should be parsed
70
+ * @param {Number=} offset: Any offset that must be added to the value
71
+ * @param {Number=} max
72
+ * @returns {Number|null}
73
+ */
74
+
75
+ function getValue(value) {
76
+ var offset = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1];
77
+ var max = arguments.length <= 2 || arguments[2] === undefined ? 9999 : arguments[2];
78
+ return isNaN(value) ? NAMES[value] || null : Math.min(+value + offset, max);
79
+ }
80
+ /**
81
+ * Returns a deep clone of a schedule skipping any day of week
82
+ * constraints.
83
+ *
84
+ * @param {Object} sched: The schedule that will be cloned
85
+ * @returns {Object}
86
+ */
87
+
88
+
89
+ function cloneSchedule(sched) {
90
+ var clone = {};
91
+ var field;
92
+
93
+ for (field in sched) {
94
+ if (field !== 'dc' && field !== 'd') {
95
+ clone[field] = sched[field].slice(0);
96
+ }
97
+ }
98
+
99
+ return clone;
100
+ }
101
+ /**
102
+ * Adds values to the specified constraint in the current schedule.
103
+ *
104
+ * @param {Object} sched: The schedule to add the constraint to
105
+ * @param {String} name: Name of constraint to add
106
+ * @param {Number} min: Minimum value for this constraint
107
+ * @param {Number} max: Maximum value for this constraint
108
+ */
109
+
110
+
111
+ function add(sched, name, min, max) {
112
+ var inc = arguments.length <= 4 || arguments[4] === undefined ? 0 : arguments[4];
113
+ var i = min;
114
+
115
+ if (!sched[name]) {
116
+ sched[name] = [];
117
+ }
118
+
119
+ while (i <= max) {
120
+ if (sched[name].indexOf(i) < 0) {
121
+ sched[name].push(i);
122
+ }
123
+
124
+ i += inc || 1;
125
+ }
126
+
127
+ sched[name].sort(function (a, b) {
128
+ return a - b;
129
+ });
130
+ }
131
+ /**
132
+ * Adds a hash item (of the form x#y or xL) to the schedule.
133
+ *
134
+ * @param {Object} schedules: The current schedule array to add to
135
+ * @param {Object} curSched: The current schedule to add to
136
+ * @param {Number} value: The value to add (x of x#y or xL)
137
+ * @param {Number} hash: The hash value to add (y of x#y)
138
+ */
139
+
140
+
141
+ function addHash(schedules, curSched, value, hash) {
142
+ // if there are any existing day of week constraints that
143
+ // aren't equal to the one we're adding, create a new
144
+ // composite schedule
145
+ if (curSched.d && !curSched.dc || curSched.dc && curSched.dc.indexOf(hash) < 0) {
146
+ schedules.push(cloneSchedule(curSched));
147
+ curSched = schedules[schedules.length - 1];
148
+ }
149
+
150
+ add(curSched, 'd', value, value);
151
+ add(curSched, 'dc', hash, hash);
152
+ }
153
+ /**
154
+ *
155
+ * @param {Object} s: The existing set of schedules
156
+ * @param {Object} curSched: The current schedule to add to
157
+ * @param {Number} value
158
+ */
159
+
160
+
161
+ function addWeekday(s, curSched, value) {
162
+ var except1 = {},
163
+ except2 = {};
164
+
165
+ if (value === 1) {
166
+ // cron doesn't pass month boundaries, so if 1st is a
167
+ // weekend then we need to use 2nd or 3rd instead
168
+ add(curSched, 'D', 1, 3);
169
+ add(curSched, 'd', NAMES.MON, NAMES.FRI);
170
+ add(except1, 'D', 2, 2);
171
+ add(except1, 'd', NAMES.TUE, NAMES.FRI);
172
+ add(except2, 'D', 3, 3);
173
+ add(except2, 'd', NAMES.TUE, NAMES.FRI);
174
+ } else {
175
+ // normally you want the closest day, so if v is a
176
+ // Saturday, use the previous Friday. If it's a
177
+ // sunday, use the following Monday.
178
+ add(curSched, 'D', value - 1, value + 1);
179
+ add(curSched, 'd', NAMES.MON, NAMES.FRI);
180
+ add(except1, 'D', value - 1, value - 1);
181
+ add(except1, 'd', NAMES.MON, NAMES.THU);
182
+ add(except2, 'D', value + 1, value + 1);
183
+ add(except2, 'd', NAMES.TUE, NAMES.FRI);
184
+ }
185
+
186
+ s.exceptions.push(except1);
187
+ s.exceptions.push(except2);
188
+ }
189
+ /**
190
+ * Adds a range item (of the form x-y/z) to the schedule.
191
+ *
192
+ * @param {String} item: The cron expression item to add
193
+ * @param {Object} curSched: The current schedule to add to
194
+ * @param {String} name: The name to use for this constraint
195
+ * @param {Number} min: The min value for the constraint
196
+ * @param {Number} max: The max value for the constraint
197
+ * @param {Number} offset: The offset to apply to the cron value
198
+ */
199
+
200
+
201
+ function addRange(item, curSched, name, min, max, offset) {
202
+ // parse range/x
203
+ var incSplit = item.split('/'),
204
+ inc = +incSplit[1],
205
+ range = incSplit[0]; // parse x-y or * or 0
206
+
207
+ if (range !== '*' && range !== '0') {
208
+ var rangeSplit = range.split('-');
209
+ min = getValue(rangeSplit[0], offset, max); // fix for issue #13, range may be single digit
210
+
211
+ max = getValue(rangeSplit[1], offset, max) || max;
212
+ }
213
+
214
+ add(curSched, name, min, max, inc);
215
+ }
216
+ /**
217
+ * Parses a particular item within a cron expression.
218
+ *
219
+ * @param {String} item: The cron expression item to parse
220
+ * @param {Object} s: The existing set of schedules
221
+ * @param {String} name: The name to use for this constraint
222
+ * @param {Number} min: The min value for the constraint
223
+ * @param {Number} max: The max value for the constraint
224
+ * @param {Number} offset: The offset to apply to the cron value
225
+ */
226
+
227
+
228
+ function parse(item, s, name, min, max, offset) {
229
+ var value,
230
+ split,
231
+ schedules = s.schedules,
232
+ curSched = schedules[schedules.length - 1]; // L just means min - 1 (this also makes it work for any field)
233
+
234
+ if (item === 'L') {
235
+ item = (min - 1).toString(10);
236
+ } // parse x
237
+
238
+
239
+ if ((value = getValue(item, offset, max)) !== null) {
240
+ add(curSched, name, value, value);
241
+ } // parse xW
242
+ else if ((value = getValue(item.replace('W', ''), offset, max)) !== null) {
243
+ addWeekday(s, curSched, value);
244
+ } // parse xL
245
+ else if ((value = getValue(item.replace('L', ''), offset, max)) !== null) {
246
+ addHash(schedules, curSched, value, min - 1);
247
+ } // parse x#y
248
+ else if ((split = item.split('#')).length === 2) {
249
+ value = getValue(split[0], offset, max);
250
+ addHash(schedules, curSched, value, getValue(split[1]));
251
+ } // parse x-y or x-y/z or */z or 0/z
252
+ else {
253
+ addRange(item, curSched, name, min, max, offset);
254
+ }
255
+ }
256
+ /**
257
+ * Returns true if the item is either of the form x#y or xL.
258
+ *
259
+ * @param {String} item: The expression item to check
260
+ */
261
+
262
+
263
+ function isHash(item) {
264
+ return item.indexOf('#') > -1 || item.indexOf('L') > 0;
265
+ }
266
+
267
+ function itemSorter(a, b) {
268
+ return isHash(a) && !isHash(b) ? 1 : a - b;
269
+ }
270
+ /**
271
+ * Parses each of the fields in a cron expression. The expression must
272
+ * include the seconds field, the year field is optional.
273
+ *
274
+ * @param {String} expr: The cron expression to parse
275
+ */
276
+
277
+
278
+ function parseExpr(expr) {
279
+ var schedule = {
280
+ schedules: [{}],
281
+ exceptions: []
282
+ };
283
+ var components = expr.replace(/(\s)+/g, ' ').split(' ');
284
+ var field;
285
+ var f;
286
+ var component;
287
+ var items;
288
+
289
+ for (field in FIELDS) {
290
+ f = FIELDS[field];
291
+ component = components[f[0]];
292
+
293
+ if (component && component !== '*' && component !== '?') {
294
+ // need to sort so that any #'s come last, otherwise
295
+ // schedule clones to handle # won't contain all of the
296
+ // other constraints
297
+ items = component.split(',').sort(itemSorter);
298
+ var i = void 0;
299
+ var length = items.length;
300
+
301
+ for (i = 0; i < length; i++) {
302
+ parse(items[i], schedule, field, f[1], f[2], f[3]);
303
+ }
304
+ }
305
+ }
306
+
307
+ return schedule;
308
+ }
309
+ /**
310
+ * Make cron expression parsable.
311
+ *
312
+ * @param {String} expr: The cron expression to prepare
313
+ */
314
+
315
+
316
+ function prepareExpr(expr) {
317
+ var prepared = expr.toUpperCase();
318
+ return REPLACEMENTS[prepared] || prepared;
319
+ }
320
+
321
+ function parseCron(expr, hasSeconds) {
322
+ var e = prepareExpr(expr);
323
+ return parseExpr(hasSeconds ? e : '0 ' + e);
324
+ }
325
+
326
+ var schedule = parseCron(cronspec, withSeconds);
327
+
328
+ function absFloor(number) {
329
+ if (number < 0) {
330
+ return Math.ceil(number);
331
+ } else {
332
+ return Math.floor(number);
333
+ }
334
+ }
335
+
336
+ function toInt(argumentForCoercion) {
337
+ var coercedNumber = +argumentForCoercion;
338
+ var value = 0;
339
+
340
+ if (coercedNumber !== 0 && isFinite(coercedNumber)) {
341
+ value = absFloor(coercedNumber);
342
+ }
343
+
344
+ return value;
345
+ }
346
+
347
+ function ordinal(number) {
348
+ var b = number % 10,
349
+ output = toInt(number % 100 / 10) === 1 ? locale.ORDINALS.th : b === 1 ? locale.ORDINALS.st : b === 2 ? locale.ORDINALS.nd : b === 3 ? locale.ORDINALS.rd : locale.ORDINALS.th;
350
+ return number + output;
351
+ }
352
+ /**
353
+ * For an array of numbers, e.g. a list of hours in a schedule,
354
+ * return a string listing out all of the values (complete with
355
+ * "and" plus ordinal text on the last item).
356
+ * @param {Number[]} numbers
357
+ * @returns {string}
358
+ */
359
+
360
+
361
+ function numberList(numbers) {
362
+ if (numbers.length < 2) {
363
+ return ordinal(numbers);
364
+ }
365
+
366
+ var lastVal = numbers.pop();
367
+ return numbers.join(', ') + ' ' + locale['and'] + ' ' + ordinal(lastVal);
368
+ }
369
+ /**
370
+ * Parse a number into day of week, or a month name;
371
+ * used in dateList below.
372
+ * @param {Number|String} value
373
+ * @param {String} type
374
+ * @returns {String}
375
+ */
376
+
377
+
378
+ function numberToDateName(value, type) {
379
+ if (type === 'dow') {
380
+ return locale.DOW[value - 1];
381
+ } else if (type === 'mon') {
382
+ return locale.MONTH[value - 1];
383
+ }
384
+ }
385
+ /**
386
+ * From an array of numbers corresponding to dates (given in type: either
387
+ * days of the week, or months), return a string listing all the values.
388
+ * @param {Number[]} numbers
389
+ * @param {String} type
390
+ * @returns {String}
391
+ */
392
+
393
+
394
+ function dateList(numbers, type) {
395
+ if (numbers.length < 2) {
396
+ return numberToDateName('' + numbers[0], type);
397
+ }
398
+
399
+ var lastVal = '' + numbers.pop();
400
+ var outputText = '';
401
+
402
+ for (var i = 0, value; value = numbers[i]; i++) {
403
+ if (outputText.length > 0) {
404
+ outputText += ', ';
405
+ }
406
+
407
+ outputText += numberToDateName(value, type);
408
+ }
409
+
410
+ return outputText + ' ' + locale['and'] + ' ' + numberToDateName(lastVal, type);
411
+ }
412
+ /**
413
+ * Pad to equivalent of sprintf('%02d').
414
+ * @param {Number} x
415
+ * @returns {string}
416
+ */
417
+
418
+
419
+ function zeroPad(x) {
420
+ return x < 10 ? '0' + x : x;
421
+ } //----------------
422
+
423
+ /**
424
+ * Given a schedule, generate a friendly sentence description.
425
+ * @param {Object} schedule
426
+ * @param {boolean} withSeconds
427
+ * @returns {string}
428
+ */
429
+
430
+
431
+ function scheduleToSentence(schedule, withSeconds) {
432
+ var outputText = locale.Every + ' ';
433
+
434
+ if (schedule['h'] && schedule['m'] && schedule['h'].length <= 2 && schedule['m'].length <= 2 && withSeconds && schedule['s'] && schedule['s'].length <= 2) {
435
+ // If there are only one or two specified values for
436
+ // hour or minute, print them in HH:MM:SS format
437
+ var hm = [];
438
+
439
+ for (var i = 0; i < schedule['h'].length; i++) {
440
+ for (var j = 0; j < schedule['m'].length; j++) {
441
+ for (var k = 0; k < schedule['s'].length; k++) {
442
+ hm.push(zeroPad(schedule['h'][i]) + ':' + zeroPad(schedule['m'][j]) + ':' + zeroPad(schedule['s'][k]));
443
+ }
444
+ }
445
+ }
446
+
447
+ if (hm.length < 2) {
448
+ outputText = locale['At'] + ' ' + hm[0];
449
+ } else {
450
+ var lastVal = hm.pop();
451
+ outputText = locale['At'] + ' ' + hm.join(', ') + ' ' + locale.and + ' ' + lastVal;
452
+ }
453
+
454
+ if (!schedule['d'] && !schedule['D']) {
455
+ outputText += ' ' + locale['every day'] + ' ';
456
+ }
457
+ } else if (schedule['h'] && schedule['m'] && schedule['h'].length <= 2 && schedule['m'].length <= 2) {
458
+ // If there are only one or two specified values for
459
+ // hour or minute, print them in HH:MM format
460
+ var _hm = [];
461
+
462
+ for (var _i = 0; _i < schedule['h'].length; _i++) {
463
+ for (var _j = 0; _j < schedule['m'].length; _j++) {
464
+ _hm.push(zeroPad(schedule['h'][_i]) + ':' + zeroPad(schedule['m'][_j]));
465
+ }
466
+ }
467
+
468
+ if (_hm.length < 2) {
469
+ outputText = locale['At'] + ' ' + _hm[0];
470
+ } else {
471
+ var _lastVal = _hm.pop();
472
+
473
+ outputText = locale['At'] + ' ' + _hm.join(', ') + ' ' + locale.and + ' ' + _lastVal;
474
+ }
475
+
476
+ if (!schedule['d'] && !schedule['D']) {
477
+ outputText += ' ' + locale['every day'] + ' ';
478
+ }
479
+ } else {
480
+ // Otherwise, list out every specified hour/minute value.
481
+ if (schedule['h']) {
482
+ // runs only at specific hours
483
+ if (schedule['m']) {
484
+ // and only at specific minutes
485
+ if (withSeconds) {
486
+ if (!schedule['s'] || schedule['s'].length === 60) {
487
+ outputText += locale['second of every'] + ' ' + numberList(schedule['m']) + ' ' + locale['minute past the'] + ' ' + numberList(schedule['h']) + ' ' + locale['hour'];
488
+ } else {
489
+ outputText += numberList(schedule['s']) + ' ' + locale['second of every'] + ' ' + numberList(schedule['m']) + ' ' + locale['minute past the'] + ' ' + numberList(schedule['h']) + ' ' + locale['hour'];
490
+ }
491
+ } else {
492
+ outputText += numberList(schedule['m']) + ' ' + locale['minute past the'] + ' ' + numberList(schedule['h']) + ' ' + locale['hour'];
493
+ }
494
+ } else {
495
+ // specific hours, but every minute
496
+ if (withSeconds) {
497
+ if (!schedule['s'] || schedule['s'].length === 60) {
498
+ outputText += locale['second of every'] + ' ' + locale['minute of'] + ' ' + numberList(schedule['h']) + ' ' + locale['hour'];
499
+ } else {
500
+ outputText += numberList(schedule['s']) + ' ' + locale['second of every'] + ' ' + locale['minute of'] + ' ' + numberList(schedule['h']) + ' ' + locale['hour'];
501
+ }
502
+ } else {
503
+ outputText += locale['minute of'] + ' ' + numberList(schedule['h']) + ' ' + locale['hour'];
504
+ }
505
+ }
506
+ } else if (schedule['m']) {
507
+ // every hour, but specific minutes
508
+ if (withSeconds) {
509
+ if (!schedule['s'] || schedule['s'].length === 60) {
510
+ outputText += locale['second of every'] + ' ' + numberList(schedule['m']) + ' ' + locale['minute every hour'];
511
+ } else {
512
+ outputText += numberList(schedule['s']) + ' ' + locale['second of every'] + ' ' + numberList(schedule['m']) + ' ' + locale['minute every hour'];
513
+ }
514
+ } else {
515
+ outputText += numberList(schedule['m']) + ' ' + locale['minute every hour'];
516
+ }
517
+ } else if (withSeconds) {
518
+ if (!schedule['s'] || schedule['s'].length === 60) {
519
+ outputText += locale['second'];
520
+ } else {
521
+ outputText += numberList(schedule['s']) + ' ' + locale['second'];
522
+ }
523
+ } else {
524
+ // cronspec has "*" for both hour and minute
525
+ outputText += locale['minute'];
526
+ }
527
+ }
528
+
529
+ if (schedule['D']) {
530
+ // runs only on specific day(s) of month
531
+ outputText += (locale['on the'] ? ' ' + locale['on the'] + ' ' : ' ') + numberList(schedule['D']);
532
+
533
+ if (!schedule['M']) {
534
+ outputText += ' ' + locale['of every month'];
535
+ }
536
+ }
537
+
538
+ if (schedule['d']) {
539
+ // runs only on specific day(s) of week
540
+ if (schedule['D']) {
541
+ // if both day fields are specified, cron uses both; superuser.com/a/348372
542
+ outputText += ' ' + locale['and every'] + ' ';
543
+ } else {
544
+ outputText += ' ' + locale['on'] + ' ';
545
+ }
546
+
547
+ outputText += dateList(schedule['d'], 'dow');
548
+ }
549
+
550
+ if (schedule['M']) {
551
+ // runs only in specific months; put this output last
552
+ outputText += ' ' + locale['in'] + ' ' + dateList(schedule['M'], 'mon');
553
+ }
554
+
555
+ return outputText;
556
+ }
557
+
558
+ return scheduleToSentence(schedule.schedules[0], withSeconds);
559
+ }
560
+
561
+ var _default = cronToText;
562
+ exports["default"] = _default;
563
+ //# sourceMappingURL=cron2text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["SimpleCron/cron2text.js"],"names":["cronToText","cronspec","withSeconds","locale","NAMES","JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC","SUN","MON","TUE","WED","THU","FRI","SAT","REPLACEMENTS","FIELDS","s","m","h","D","M","Y","d","getValue","value","offset","arguments","length","undefined","max","isNaN","Math","min","cloneSchedule","sched","clone","field","slice","add","name","inc","i","indexOf","push","sort","a","b","addHash","schedules","curSched","hash","dc","addWeekday","except1","except2","exceptions","addRange","item","incSplit","split","range","rangeSplit","parse","toString","replace","isHash","itemSorter","parseExpr","expr","schedule","components","f","component","items","prepareExpr","prepared","toUpperCase","parseCron","hasSeconds","e","absFloor","number","ceil","floor","toInt","argumentForCoercion","coercedNumber","isFinite","ordinal","output","ORDINALS","th","st","nd","rd","numberList","numbers","lastVal","pop","join","numberToDateName","type","DOW","MONTH","dateList","outputText","zeroPad","x","scheduleToSentence","Every","hm","j","k","and"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,UAAT,CAAoBC,QAApB,EAA8BC,WAA9B,EAA2CC,MAA3C,EAAmD;AAE/C;AACA,MAAMC,KAAK,GAAG;AACVC,IAAAA,GAAG,EAAE,CADK;AACFC,IAAAA,GAAG,EAAE,CADH;AACMC,IAAAA,GAAG,EAAE,CADX;AACcC,IAAAA,GAAG,EAAE,CADnB;AACsBC,IAAAA,GAAG,EAAE,CAD3B;AAC8BC,IAAAA,GAAG,EAAE,CADnC;AACsCC,IAAAA,GAAG,EAAE,CAD3C;AAC8CC,IAAAA,GAAG,EAAE,CADnD;AAEVC,IAAAA,GAAG,EAAE,CAFK;AAEFC,IAAAA,GAAG,EAAE,EAFH;AAEOC,IAAAA,GAAG,EAAE,EAFZ;AAEgBC,IAAAA,GAAG,EAAE,EAFrB;AAGVC,IAAAA,GAAG,EAAE,CAHK;AAGFC,IAAAA,GAAG,EAAE,CAHH;AAGMC,IAAAA,GAAG,EAAE,CAHX;AAGcC,IAAAA,GAAG,EAAE,CAHnB;AAGsBC,IAAAA,GAAG,EAAE,CAH3B;AAG8BC,IAAAA,GAAG,EAAE,CAHnC;AAGsCC,IAAAA,GAAG,EAAE;AAH3C,GAAd,CAH+C,CAS/C;;AACA,MAAMC,YAAY,GAAG;AACjB,mBAAe,eADE;AAEjB,eAAW,WAFM;AAGjB,iBAAa,WAHI;AAIjB,gBAAY,WAJK;AAKjB,eAAW,WALM;AAMjB,cAAU,WANO;AAOjB,eAAW;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AAlF;;AACA,UAAI,CAACA,QAAQ,CAAC,GAAD,CAAb,EAAoB;AAChBoC,QAAAA,UAAU,IAAI,MAAMhH,MAAM,CAAC,gBAAD,CAA1B;AACH;AACJ;;AAED,QAAI4E,QAAQ,CAAC,GAAD,CAAZ,EAAmB;AAAE;AACjB,UAAIA,QAAQ,CAAC,GAAD,CAAZ,EAAmB;AACf;AACAoC,QAAAA,UAAU,IAAI,MAAMhH,MAAM,CAAC,WAAD,CAAZ,GAA4B,GAA1C;AACH,OAHD,MAGO;AACHgH,QAAAA,UAAU,IAAI,MAAMhH,MAAM,CAAC,IAAD,CAAZ,GAAqB,GAAnC;AACH;;AACDgH,MAAAA,UAAU,IAAID,QAAQ,CAACnC,QAAQ,CAAC,GAAD,CAAT,EAAgB,KAAhB,CAAtB;AACH;;AAED,QAAIA,QAAQ,CAAC,GAAD,CAAZ,EAAmB;AACf;AACAoC,MAAAA,UAAU,IAAI,MAAMhH,MAAM,CAAC,IAAD,CAAZ,GAAqB,GAArB,GAA2B+G,QAAQ,CAACnC,QAAQ,CAAC,GAAD,CAAT,EAAgB,KAAhB,CAAjD;AACH;;AAED,WAAOoC,UAAP;AACH;;AAED,SAAOG,kBAAkB,CAACvC,QAAQ,CAACrB,SAAT,CAAmB,CAAnB,CAAD,EAAwBxD,WAAxB,CAAzB;AACH;;eAEcF,U","sourcesContent":["/**\n * Given a cronspec, return the human-readable string.\n * @param {string} cronspec\n * @param withSeconds\n * @param {Object=} locale\n */\nfunction cronToText(cronspec, withSeconds, locale) {\n\n // Constant array to convert valid names to values\n const NAMES = {\n JAN: 1, FEB: 2, MAR: 3, APR: 4, MAY: 5, JUN: 6, JUL: 7, AUG: 8,\n SEP: 9, OCT: 10, NOV: 11, DEC: 12,\n SUN: 1, MON: 2, TUE: 3, WED: 4, THU: 5, FRI: 6, SAT: 7\n };\n\n // Parsable replacements for common expressions\n const REPLACEMENTS = {\n '* * * * * *': '0/1 * * * * *',\n '@YEARLY': '0 0 1 1 *',\n '@ANNUALLY': '0 0 1 1 *',\n '@MONTHLY': '0 0 1 * *',\n '@WEEKLY': '0 0 * * 0',\n '@DAILY': '0 0 * * *',\n '@HOURLY': '0 * * * *'\n };\n\n // Contains the index, min, and max for each of the constraints\n const FIELDS = {\n s: [0, 0, 59], // seconds\n m: [1, 0, 59], // minutes\n h: [2, 0, 23], // hours\n D: [3, 1, 31], // day of month\n M: [4, 1, 12], // month\n Y: [6, 1970, 2099], // year\n d: [5, 1, 7, 1] // day of week\n };\n\n /**\n * Returns the value + offset if value is a number, otherwise it\n * attempts to look up the value in the NAMES table and returns\n * that result instead.\n *\n * @param {Number,String} value: The value that should be parsed\n * @param {Number=} offset: Any offset that must be added to the value\n * @param {Number=} max\n * @returns {Number|null}\n */\n function getValue(value) {\n const offset = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1];\n const max = arguments.length <= 2 || arguments[2] === undefined ? 9999 : arguments[2];\n\n return isNaN(value) ? NAMES[value] || null : Math.min(+value + offset, max);\n }\n\n /**\n * Returns a deep clone of a schedule skipping any day of week\n * constraints.\n *\n * @param {Object} sched: The schedule that will be cloned\n * @returns {Object}\n */\n function cloneSchedule(sched) {\n const clone = {};\n let field;\n\n for (field in sched) {\n if (field !== 'dc' && field !== 'd') {\n clone[field] = sched[field].slice(0);\n }\n }\n\n return clone;\n }\n\n /**\n * Adds values to the specified constraint in the current schedule.\n *\n * @param {Object} sched: The schedule to add the constraint to\n * @param {String} name: Name of constraint to add\n * @param {Number} min: Minimum value for this constraint\n * @param {Number} max: Maximum value for this constraint\n */\n function add(sched, name, min, max) {\n const inc = arguments.length <= 4 || arguments[4] === undefined ? 0 : arguments[4];\n\n let i = min;\n\n if (!sched[name]) {\n sched[name] = [];\n }\n\n while (i <= max) {\n if (sched[name].indexOf(i) < 0) {\n sched[name].push(i);\n }\n i += inc || 1;\n }\n\n sched[name].sort(function (a, b) {\n return a - b;\n });\n }\n\n /**\n * Adds a hash item (of the form x#y or xL) to the schedule.\n *\n * @param {Object} schedules: The current schedule array to add to\n * @param {Object} curSched: The current schedule to add to\n * @param {Number} value: The value to add (x of x#y or xL)\n * @param {Number} hash: The hash value to add (y of x#y)\n */\n function addHash(schedules, curSched, value, hash) {\n // if there are any existing day of week constraints that\n // aren't equal to the one we're adding, create a new\n // composite schedule\n if ((curSched.d && !curSched.dc) || (curSched.dc && curSched.dc.indexOf(hash) < 0)) {\n schedules.push(cloneSchedule(curSched));\n curSched = schedules[schedules.length - 1];\n }\n\n add(curSched, 'd', value, value);\n add(curSched, 'dc', hash, hash);\n }\n\n /**\n *\n * @param {Object} s: The existing set of schedules\n * @param {Object} curSched: The current schedule to add to\n * @param {Number} value\n */\n function addWeekday(s, curSched, value) {\n const except1 = {},\n except2 = {};\n if (value === 1) {\n // cron doesn't pass month boundaries, so if 1st is a\n // weekend then we need to use 2nd or 3rd instead\n add(curSched, 'D', 1, 3);\n add(curSched, 'd', NAMES.MON, NAMES.FRI);\n add(except1, 'D', 2, 2);\n add(except1, 'd', NAMES.TUE, NAMES.FRI);\n add(except2, 'D', 3, 3);\n add(except2, 'd', NAMES.TUE, NAMES.FRI);\n } else {\n // normally you want the closest day, so if v is a\n // Saturday, use the previous Friday. If it's a\n // sunday, use the following Monday.\n add(curSched, 'D', value - 1, value + 1);\n add(curSched, 'd', NAMES.MON, NAMES.FRI);\n add(except1, 'D', value - 1, value - 1);\n add(except1, 'd', NAMES.MON, NAMES.THU);\n add(except2, 'D', value + 1, value + 1);\n add(except2, 'd', NAMES.TUE, NAMES.FRI);\n }\n s.exceptions.push(except1);\n s.exceptions.push(except2);\n }\n\n /**\n * Adds a range item (of the form x-y/z) to the schedule.\n *\n * @param {String} item: The cron expression item to add\n * @param {Object} curSched: The current schedule to add to\n * @param {String} name: The name to use for this constraint\n * @param {Number} min: The min value for the constraint\n * @param {Number} max: The max value for the constraint\n * @param {Number} offset: The offset to apply to the cron value\n */\n function addRange(item, curSched, name, min, max, offset) {\n // parse range/x\n const incSplit = item.split('/'),\n inc = +incSplit[1],\n range = incSplit[0];\n\n // parse x-y or * or 0\n if (range !== '*' && range !== '0') {\n const rangeSplit = range.split('-');\n min = getValue(rangeSplit[0], offset, max);\n\n // fix for issue #13, range may be single digit\n max = getValue(rangeSplit[1], offset, max) || max;\n }\n\n add(curSched, name, min, max, inc);\n }\n\n /**\n * Parses a particular item within a cron expression.\n *\n * @param {String} item: The cron expression item to parse\n * @param {Object} s: The existing set of schedules\n * @param {String} name: The name to use for this constraint\n * @param {Number} min: The min value for the constraint\n * @param {Number} max: The max value for the constraint\n * @param {Number} offset: The offset to apply to the cron value\n */\n function parse(item, s, name, min, max, offset) {\n let value,\n split,\n schedules = s.schedules,\n curSched = schedules[schedules.length - 1];\n\n // L just means min - 1 (this also makes it work for any field)\n if (item === 'L') {\n item = (min - 1).toString(10);\n }\n\n // parse x\n if ((value = getValue(item, offset, max)) !== null) {\n add(curSched, name, value, value);\n }\n // parse xW\n else if ((value = getValue(item.replace('W', ''), offset, max)) !== null) {\n addWeekday(s, curSched, value);\n }\n // parse xL\n else if ((value = getValue(item.replace('L', ''), offset, max)) !== null) {\n addHash(schedules, curSched, value, min - 1);\n }\n // parse x#y\n else if ((split = item.split('#')).length === 2) {\n value = getValue(split[0], offset, max);\n addHash(schedules, curSched, value, getValue(split[1]));\n }\n // parse x-y or x-y/z or */z or 0/z\n else {\n addRange(item, curSched, name, min, max, offset);\n }\n }\n\n /**\n * Returns true if the item is either of the form x#y or xL.\n *\n * @param {String} item: The expression item to check\n */\n function isHash(item) {\n return item.indexOf('#') > -1 || item.indexOf('L') > 0;\n }\n\n function itemSorter(a, b) {\n return isHash(a) && !isHash(b) ? 1 : a - b;\n }\n\n /**\n * Parses each of the fields in a cron expression. The expression must\n * include the seconds field, the year field is optional.\n *\n * @param {String} expr: The cron expression to parse\n */\n function parseExpr(expr) {\n const schedule = { schedules: [{}], exceptions: [] };\n const components = expr.replace(/(\\s)+/g, ' ').split(' ');\n let field;\n let f;\n let component;\n let items;\n\n for (field in FIELDS) {\n f = FIELDS[field];\n component = components[f[0]];\n if (component && component !== '*' && component !== '?') {\n // need to sort so that any #'s come last, otherwise\n // schedule clones to handle # won't contain all of the\n // other constraints\n items = component.split(',').sort(itemSorter);\n let i;\n const length = items.length;\n for (i = 0; i < length; i++) {\n parse(items[i], schedule, field, f[1], f[2], f[3]);\n }\n }\n }\n\n return schedule;\n }\n\n /**\n * Make cron expression parsable.\n *\n * @param {String} expr: The cron expression to prepare\n */\n function prepareExpr(expr) {\n const prepared = expr.toUpperCase();\n return REPLACEMENTS[prepared] || prepared;\n }\n\n function parseCron(expr, hasSeconds) {\n const e = prepareExpr(expr);\n return parseExpr(hasSeconds ? e : '0 ' + e);\n }\n\n const schedule = parseCron(cronspec, withSeconds);\n\n function absFloor(number) {\n if (number < 0) {\n return Math.ceil(number);\n } else {\n return Math.floor(number);\n }\n }\n\n function toInt(argumentForCoercion) {\n const coercedNumber = +argumentForCoercion;\n let value = 0;\n\n if (coercedNumber !== 0 && isFinite(coercedNumber)) {\n value = absFloor(coercedNumber);\n }\n\n return value;\n }\n\n function ordinal(number) {\n const b = number % 10,\n output = (toInt(number % 100 / 10) === 1) ? locale.ORDINALS.th :\n (b === 1) ? locale.ORDINALS.st :\n (b === 2) ? locale.ORDINALS.nd :\n (b === 3) ? locale.ORDINALS.rd : locale.ORDINALS.th;\n return number + output;\n }\n\n /**\n * For an array of numbers, e.g. a list of hours in a schedule,\n * return a string listing out all of the values (complete with\n * \"and\" plus ordinal text on the last item).\n * @param {Number[]} numbers\n * @returns {string}\n */\n function numberList(numbers) {\n if (numbers.length < 2) {\n return ordinal(numbers);\n }\n\n const lastVal = numbers.pop();\n return numbers.join(', ') + ' ' + locale['and'] + ' ' + ordinal(lastVal);\n }\n\n /**\n * Parse a number into day of week, or a month name;\n * used in dateList below.\n * @param {Number|String} value\n * @param {String} type\n * @returns {String}\n */\n function numberToDateName(value, type) {\n if (type === 'dow') {\n return locale.DOW[value - 1];\n } else if (type === 'mon') {\n return locale.MONTH[value - 1];\n }\n }\n\n /**\n * From an array of numbers corresponding to dates (given in type: either\n * days of the week, or months), return a string listing all the values.\n * @param {Number[]} numbers\n * @param {String} type\n * @returns {String}\n */\n function dateList(numbers, type) {\n if (numbers.length < 2) {\n return numberToDateName('' + numbers[0], type);\n }\n\n const lastVal = '' + numbers.pop();\n let outputText = '';\n\n for (let i = 0, value; (value = numbers[i]); i++) {\n if (outputText.length > 0) {\n outputText += ', ';\n }\n outputText += numberToDateName(value, type);\n }\n return outputText + ' ' + locale['and'] + ' ' + numberToDateName(lastVal, type);\n }\n\n /**\n * Pad to equivalent of sprintf('%02d').\n * @param {Number} x\n * @returns {string}\n */\n function zeroPad(x) {\n return (x < 10) ? '0' + x : x;\n }\n\n //----------------\n\n /**\n * Given a schedule, generate a friendly sentence description.\n * @param {Object} schedule\n * @param {boolean} withSeconds\n * @returns {string}\n */\n function scheduleToSentence(schedule, withSeconds) {\n let outputText = locale.Every + ' ';\n\n if (schedule['h'] && schedule['m'] && schedule['h'].length <= 2 && schedule['m'].length <= 2 && withSeconds && schedule['s'] && schedule['s'].length <= 2 ) {\n // If there are only one or two specified values for\n // hour or minute, print them in HH:MM:SS format\n\n const hm = [];\n for (let i = 0; i < schedule['h'].length; i++) {\n for (let j = 0; j < schedule['m'].length; j++) {\n for (let k = 0; k < schedule['s'].length; k++) {\n hm.push(zeroPad(schedule['h'][i]) + ':' + zeroPad(schedule['m'][j]) + ':' + zeroPad(schedule['s'][k]));\n }\n }\n }\n if (hm.length < 2) {\n outputText = locale['At'] + ' ' + hm[0];\n } else {\n const lastVal = hm.pop();\n outputText = locale['At'] + ' ' + hm.join(', ') + ' ' + locale.and + ' ' + lastVal;\n }\n if (!schedule['d'] && !schedule['D']) {\n outputText += ' ' + locale['every day'] + ' ';\n }\n } else\n if (schedule['h'] && schedule['m'] && schedule['h'].length <= 2 && schedule['m'].length <= 2) {\n // If there are only one or two specified values for\n // hour or minute, print them in HH:MM format\n\n const hm = [];\n for (let i = 0; i < schedule['h'].length; i++) {\n for (let j = 0; j < schedule['m'].length; j++) {\n hm.push(zeroPad(schedule['h'][i]) + ':' + zeroPad(schedule['m'][j]));\n }\n }\n if (hm.length < 2) {\n outputText = locale['At'] + ' ' + hm[0];\n } else {\n const lastVal = hm.pop();\n outputText = locale['At'] + ' ' + hm.join(', ') + ' ' + locale.and + ' ' + lastVal;\n }\n\n if (!schedule['d'] && !schedule['D']) {\n outputText += ' ' + locale['every day'] + ' ';\n }\n } else {\n // Otherwise, list out every specified hour/minute value.\n\n if (schedule['h']) { // runs only at specific hours\n if (schedule['m']) { // and only at specific minutes\n if (withSeconds) {\n if (!schedule['s'] || schedule['s'].length === 60) {\n outputText += locale['second of every'] + ' ' + numberList(schedule['m']) + ' ' + locale['minute past the'] + ' ' + numberList(schedule['h']) + ' ' + locale['hour'];\n } else {\n outputText += numberList(schedule['s']) + ' ' + locale['second of every'] + ' ' +numberList(schedule['m']) + ' ' + locale['minute past the'] + ' ' + numberList(schedule['h']) + ' ' + locale['hour'];\n }\n } else {\n outputText += numberList(schedule['m']) + ' ' + locale['minute past the'] + ' ' + numberList(schedule['h']) + ' ' + locale['hour'];\n }\n } else { // specific hours, but every minute\n if (withSeconds) {\n if (!schedule['s'] || schedule['s'].length === 60) {\n outputText += locale['second of every'] + ' ' + locale['minute of'] + ' ' + numberList(schedule['h']) + ' ' + locale['hour'];\n } else {\n outputText += numberList(schedule['s']) + ' ' + locale['second of every'] + ' ' + locale['minute of'] + ' ' + numberList(schedule['h']) + ' ' + locale['hour'];\n }\n } else {\n outputText += locale['minute of'] + ' ' + numberList(schedule['h']) + ' ' + locale['hour'];\n }\n }\n } else if (schedule['m']) { // every hour, but specific minutes\n if (withSeconds) {\n if (!schedule['s'] || schedule['s'].length === 60) {\n outputText += locale['second of every'] + ' ' + numberList(schedule['m']) + ' ' + locale['minute every hour'];\n } else {\n outputText += numberList(schedule['s']) + ' ' + locale['second of every'] + ' ' + numberList(schedule['m']) + ' ' + locale['minute every hour'];\n }\n } else {\n outputText += numberList(schedule['m']) + ' ' + locale['minute every hour'];\n }\n } else if (withSeconds) {\n if (!schedule['s'] || schedule['s'].length === 60) {\n outputText += locale['second'];\n } else {\n outputText += numberList(schedule['s']) + ' ' + locale['second'];\n }\n } else { // cronspec has \"*\" for both hour and minute\n outputText += locale['minute'];\n }\n }\n\n if (schedule['D']) { // runs only on specific day(s) of month\n outputText += (locale['on the'] ? ' ' + locale['on the'] + ' ' : ' ') + numberList(schedule['D']);\n if (!schedule['M']) {\n outputText += ' ' + locale['of every month'];\n }\n }\n\n if (schedule['d']) { // runs only on specific day(s) of week\n if (schedule['D']) {\n // if both day fields are specified, cron uses both; superuser.com/a/348372\n outputText += ' ' + locale['and every'] + ' ';\n } else {\n outputText += ' ' + locale['on'] + ' ';\n }\n outputText += dateList(schedule['d'], 'dow');\n }\n\n if (schedule['M']) {\n // runs only in specific months; put this output last\n outputText += ' ' + locale['in'] + ' ' + dateList(schedule['M'], 'mon');\n }\n\n return outputText;\n }\n\n return scheduleToSentence(schedule.schedules[0], withSeconds);\n}\n\nexport default cronToText;\n"],"file":"cron2text.js"}