goscript 0.0.43 → 0.0.45

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.
@@ -210,11 +210,19 @@ export function MakeChan(typ: Type, buffer: number): Value {
210
210
  export function Select(cases: $.Slice<SelectCase>): [number, Value, boolean] {
211
211
  // Extract the backing array from the GoScript slice
212
212
  let selectCases: SelectCase[] = []
213
-
213
+
214
214
  if (cases && typeof cases === 'object') {
215
215
  if ('__meta__' in cases) {
216
216
  // This is a GoScript SliceProxy, extract the backing array
217
- const meta = (cases as { __meta__?: { backing?: SelectCase[], offset?: number, length?: number } }).__meta__
217
+ const meta = (
218
+ cases as {
219
+ __meta__?: {
220
+ backing?: SelectCase[]
221
+ offset?: number
222
+ length?: number
223
+ }
224
+ }
225
+ ).__meta__
218
226
  if (meta && meta.backing) {
219
227
  const offset = meta.offset ?? 0
220
228
  const length = meta.length ?? meta.backing.length
package/gs/time/time.ts CHANGED
@@ -34,7 +34,9 @@ export class Time {
34
34
 
35
35
  // UnixMicro returns t as a Unix time, the number of microseconds elapsed since January 1, 1970 UTC
36
36
  public UnixMicro(): number {
37
- return Math.floor(this._date.getTime() * 1000) + Math.floor(this._nsec / 1000)
37
+ return (
38
+ Math.floor(this._date.getTime() * 1000) + Math.floor(this._nsec / 1000)
39
+ )
38
40
  }
39
41
 
40
42
  // UnixNano returns t as a Unix time, the number of nanoseconds elapsed since January 1, 1970 UTC
@@ -656,7 +658,15 @@ export enum Weekday {
656
658
 
657
659
  // WeekdayString returns the string representation of a Weekday
658
660
  export function WeekdayString(w: Weekday): string {
659
- const names = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
661
+ const names = [
662
+ 'Sunday',
663
+ 'Monday',
664
+ 'Tuesday',
665
+ 'Wednesday',
666
+ 'Thursday',
667
+ 'Friday',
668
+ 'Saturday',
669
+ ]
660
670
  return names[w] || 'Unknown'
661
671
  }
662
672
 
@@ -712,7 +722,7 @@ export class Timer {
712
722
  this._duration = duration
713
723
  this._callback = callback
714
724
  const ms = duration.valueOf() / 1000000 // Convert nanoseconds to milliseconds
715
-
725
+
716
726
  if (callback) {
717
727
  this._timeout = setTimeout(callback, ms)
718
728
  } else {
@@ -775,10 +785,10 @@ export class Ticker {
775
785
  }
776
786
 
777
787
  // Channel returns an async iterator that yields time values
778
- public async* Channel(): AsyncIterableIterator<Time> {
788
+ public async *Channel(): AsyncIterableIterator<Time> {
779
789
  const ms = this._duration.valueOf() / 1000000
780
790
  while (!this._stopped) {
781
- await new Promise(resolve => setTimeout(resolve, ms))
791
+ await new Promise((resolve) => setTimeout(resolve, ms))
782
792
  if (!this._stopped) {
783
793
  yield Now()
784
794
  }
@@ -925,15 +935,15 @@ export function UnixNano(nsec: number): Time {
925
935
  export function ParseDuration(s: string): Duration {
926
936
  const regex = /^([+-]?)(\d+(?:\.\d+)?)(ns|us|µs|ms|s|m|h)$/
927
937
  const match = s.match(regex)
928
-
938
+
929
939
  if (!match) {
930
940
  throw new Error(`time: invalid duration "${s}"`)
931
941
  }
932
-
942
+
933
943
  const [, sign, valueStr, unit] = match
934
944
  let value = parseFloat(valueStr)
935
945
  if (sign === '-') value = -value
936
-
946
+
937
947
  let nanoseconds: number
938
948
  switch (unit) {
939
949
  case 'ns':
@@ -958,7 +968,7 @@ export function ParseDuration(s: string): Duration {
958
968
  default:
959
969
  throw new Error(`time: unknown unit "${unit}" in duration "${s}"`)
960
970
  }
961
-
971
+
962
972
  return new Duration(Math.floor(nanoseconds))
963
973
  }
964
974
 
@@ -968,31 +978,53 @@ export function Parse(layout: string, value: string): Time {
968
978
  }
969
979
 
970
980
  // ParseInLocation is like Parse but differs in two important ways
971
- export function ParseInLocation(layout: string, value: string, loc: Location): Time {
981
+ export function ParseInLocation(
982
+ layout: string,
983
+ value: string,
984
+ loc: Location,
985
+ ): Time {
972
986
  // This is a simplified implementation
973
987
  // A full implementation would need to parse according to the layout format
974
-
988
+
975
989
  // Handle common layouts
976
990
  if (layout === RFC3339 || layout === '2006-01-02T15:04:05Z07:00') {
977
991
  const date = new globalThis.Date(value)
978
992
  if (isNaN(date.getTime())) {
979
- throw new ParseError(layout, value, '', '', `parsing time "${value}" as "${layout}": cannot parse`)
993
+ throw new ParseError(
994
+ layout,
995
+ value,
996
+ '',
997
+ '',
998
+ `parsing time "${value}" as "${layout}": cannot parse`,
999
+ )
980
1000
  }
981
1001
  return new Time(date, 0, undefined, loc)
982
1002
  }
983
-
1003
+
984
1004
  if (layout === DateTime || layout === '2006-01-02 15:04:05') {
985
1005
  const date = new globalThis.Date(value)
986
1006
  if (isNaN(date.getTime())) {
987
- throw new ParseError(layout, value, '', '', `parsing time "${value}" as "${layout}": cannot parse`)
1007
+ throw new ParseError(
1008
+ layout,
1009
+ value,
1010
+ '',
1011
+ '',
1012
+ `parsing time "${value}" as "${layout}": cannot parse`,
1013
+ )
988
1014
  }
989
1015
  return new Time(date, 0, undefined, loc)
990
1016
  }
991
-
1017
+
992
1018
  // Fallback to standard Date parsing
993
1019
  const date = new globalThis.Date(value)
994
1020
  if (isNaN(date.getTime())) {
995
- throw new ParseError(layout, value, '', '', `parsing time "${value}" as "${layout}": cannot parse`)
1021
+ throw new ParseError(
1022
+ layout,
1023
+ value,
1024
+ '',
1025
+ '',
1026
+ `parsing time "${value}" as "${layout}": cannot parse`,
1027
+ )
996
1028
  }
997
1029
  return new Time(date, 0, undefined, loc)
998
1030
  }
@@ -1039,7 +1071,10 @@ export function LoadLocation(name: string): Location {
1039
1071
 
1040
1072
  // LoadLocationFromTZData returns a Location with the given name
1041
1073
  // This is a simplified implementation
1042
- export function LoadLocationFromTZData(name: string, _data: Uint8Array): Location {
1074
+ export function LoadLocationFromTZData(
1075
+ name: string,
1076
+ _data: Uint8Array,
1077
+ ): Location {
1043
1078
  // In a real implementation, this would parse the timezone data
1044
1079
  return new Location(name)
1045
1080
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "goscript",
3
3
  "description": "Go to TypeScript transpiler",
4
- "version": "0.0.43",
4
+ "version": "0.0.45",
5
5
  "author": {
6
6
  "name": "Aperture Robotics LLC.",
7
7
  "email": "support@aperture.us",