@01-edu/shared 1.2.15 → 1.2.17

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": "@01-edu/shared",
3
- "version": "1.2.15",
3
+ "version": "1.2.17",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "scripts": {
@@ -1,19 +1,13 @@
1
1
  // because of the nature of esbuild we have to put the import string hard coded
2
2
  export const langTypeInfo = {
3
- go: {
4
- legacy: true,
5
- lang: 'go',
6
- load: () => import('@codemirror/legacy-modes/mode/go'),
7
- },
8
- sh: {
9
- legacy: true,
10
- lang: 'shell',
11
- load: () => import('@codemirror/legacy-modes/mode/shell'),
12
- },
3
+ go: { lang: 'go', load: () => import('@codemirror/lang-go') },
4
+ bash: { lang: 'bash', load: () => import('@fig/lezer-bash') },
5
+ sh: { lang: 'shell', load: () => import('@fig/lezer-bash') },
6
+ // The `label` is used for the UI (StatusBar) so it still shows "dart" instead of "javascript"
13
7
  dart: {
14
- lang: 'dart',
15
- legacy: true,
16
- load: () => import('@codemirror/legacy-modes/mode/clike'),
8
+ label: 'dart',
9
+ lang: 'javascript',
10
+ load: () => import('@codemirror/lang-javascript'),
17
11
  },
18
12
  css: { lang: 'css', load: () => import('@codemirror/lang-css') },
19
13
  html: { lang: 'html', load: () => import('@codemirror/lang-html') },
@@ -5,6 +5,16 @@ export const skillsSet = {
5
5
  description: 'Basics of computer programming',
6
6
  type: 'technical',
7
7
  },
8
+ 'intermediate-prog': {
9
+ name: 'Intermediate programming',
10
+ description: 'Intermediate notions of computer programming',
11
+ type: 'technical',
12
+ },
13
+ 'advanced-prog': {
14
+ name: 'Advanced programming',
15
+ description: 'Advanced notions of computer programming',
16
+ type: 'technical',
17
+ },
8
18
  algo: {
9
19
  name: 'Elementary algorithms',
10
20
  description: 'Problem-solving, algorithm design',
package/toolbox.js CHANGED
@@ -175,9 +175,14 @@ export const timeUnits = [
175
175
  ]
176
176
  export const formatedDuration = (
177
177
  seconds,
178
- { noSeconds, stopFirst, useFullLabel } = {},
178
+ { noSeconds, stopFirst, useFullLabel, stopLabel } = {},
179
179
  ) => {
180
180
  const parts = []
181
+ if (
182
+ stopLabel &&
183
+ seconds < timeUnits.find(u => u.fullLabel === stopLabel)?.size
184
+ )
185
+ return `less than 1${useFullLabel ? ` ${stopLabel}` : timeUnits.find(u => u.fullLabel === stopLabel).label}`
181
186
  for (const { label, size, fullLabel } of timeUnits) {
182
187
  const value = Math.floor(seconds / size)
183
188
  if (value !== 0) {
@@ -187,6 +192,9 @@ export const formatedDuration = (
187
192
  if (stopFirst) return parts
188
193
  seconds -= value * size
189
194
  }
195
+ if (fullLabel === stopLabel) {
196
+ return parts.join(' ') || (noSeconds ? '0m' : '0s')
197
+ }
190
198
  }
191
199
  if (!noSeconds && seconds !== 0) {
192
200
  parts.push(`${seconds}s`)
@@ -533,3 +541,31 @@ export const createFrequencyMap = arr =>
533
541
  map[item] = (map[item] || 0) + 1
534
542
  return map
535
543
  }, {})
544
+
545
+ export const postgresIntervalToMS = intervalStr => {
546
+ if (!intervalStr) return 0
547
+ // Regex to capture years, months, days, hours, minutes, seconds
548
+ const regex =
549
+ /(?:(\d+)\s+years?)?\s*(?:(\d+)\s+mons?)?\s*(?:(\d+)\s+days?)?\s*(?:(\d+):(\d+):([\d.]+))?/
550
+ const match = intervalStr.match(regex)
551
+
552
+ if (!match) return 0
553
+
554
+ const years = Number.parseInt(match[1] || 0, 10)
555
+ const months = Number.parseInt(match[2] || 0, 10)
556
+ const days = Number.parseInt(match[3] || 0, 10)
557
+ const hours = Number.parseInt(match[4] || 0, 10)
558
+ const minutes = Number.parseInt(match[5] || 0, 10)
559
+ const seconds = Number.parseFloat(match[6] || 0)
560
+
561
+ // Convert everything to milliseconds
562
+ const ms =
563
+ years * 365 * 24 * 60 * 60 * 1000 + // assume 1 year = 365 days
564
+ months * 30 * 24 * 60 * 60 * 1000 + // assume 1 month = 30 days
565
+ days * 24 * 60 * 60 * 1000 +
566
+ hours * 60 * 60 * 1000 +
567
+ minutes * 60 * 1000 +
568
+ seconds * 1000
569
+
570
+ return ms
571
+ }