socket-function 0.137.0 → 0.138.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "socket-function",
3
- "version": "0.137.0",
3
+ "version": "0.138.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
@@ -362,9 +362,8 @@ export function requireMain() {
362
362
  };
363
363
  try {
364
364
  resultObj = JSON.parse(rawText);
365
- } catch (e) {
366
- console.log(rawText);
367
- throw e;
365
+ } catch (e: any) {
366
+ throw new Error(`Failed to require modules (likely permissions errors): ${JSON.stringify(requests)}. Start of response was: ${JSON.stringify(rawText.slice(0, 100))}. Error is: ${e.stack}`);
368
367
  }
369
368
  let { modules, requestsResolvedPaths, requireSeqNumProcessId, error } = resultObj;
370
369
 
@@ -230,6 +230,31 @@ export function formatDateTime(time: number) {
230
230
  return date.getFullYear() + "/" + p(date.getMonth() + 1) + "/" + p(date.getDate()) + " " + strTime;
231
231
  }
232
232
 
233
+ export function formatDateTimeDetailed(time: number) {
234
+ function p(s: number) {
235
+ return s.toString().padStart(2, "0");
236
+ }
237
+ let date = new Date(time);
238
+ let hours = date.getHours();
239
+ let minutes = date.getMinutes();
240
+ let seconds = date.getSeconds();
241
+ let milliseconds = date.getMilliseconds();
242
+ let millisecondsString = milliseconds.toString().padStart(3, "0");
243
+
244
+ let timeString = time.toString();
245
+ let decimalIndex = timeString.indexOf(".");
246
+ if (decimalIndex !== -1) {
247
+ let fractionalPart = timeString.substring(decimalIndex + 4);
248
+ millisecondsString += fractionalPart;
249
+ }
250
+
251
+ let ampm = hours >= 12 ? "PM" : "AM";
252
+ hours = hours % 12;
253
+ hours = hours ? hours : 12; // the hour '0' should be '12'
254
+ let strTime = p(hours) + ":" + p(minutes) + ":" + p(seconds) + "." + millisecondsString + " " + ampm;
255
+ return date.getFullYear() + "/" + p(date.getMonth() + 1) + "/" + p(date.getDate()) + " " + strTime;
256
+ }
257
+
233
258
  /** 2024 January 1, Monday, 12:53:02pm */
234
259
  export function formatNiceDateTime(time: number) {
235
260
  function p(s: number) {
@@ -2,6 +2,8 @@ import { SocketFunction } from "../SocketFunction";
2
2
  import { blue, green, red, yellow } from "../src/formatting/logColors";
3
3
  import { isNode } from "../src/misc";
4
4
 
5
+ // IMPOTRANT! We don't ensure that the times of return are unique. We cannot ensure they are unique because the amount of precision is only about ten thousand date times per millisecond, Which would mean if the calling code called date.now frequently enough, which doesn't even have to be that frequent, it could slowly drift farther and farther ahead of the real time, which would be really bad.
6
+
5
7
  module.allowclient = true;
6
8
 
7
9
  const UPDATE_INTERVAL = 1000 * 60 * 10;