@voxgig/apidef 2.0.2 → 2.1.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/src/utility.ts CHANGED
@@ -8,6 +8,26 @@ import type {
8
8
  } from './types'
9
9
 
10
10
 
11
+ function getdlog(
12
+ tagin?: string,
13
+ filepath?: string)
14
+ : ((...args: any[]) => void) &
15
+ { tag: string, file: string, log: (fp?: string) => any[] } {
16
+ const tag = tagin || '-'
17
+ const file = Path.basename(filepath || '-')
18
+ const g = global as any
19
+ g.__dlog__ = (g.__dlog__ || [])
20
+ const dlog = (...args: any[]) =>
21
+ g.__dlog__.push([tag, file, Date.now(), ...args])
22
+ dlog.tag = tag
23
+ dlog.file = file
24
+ dlog.log = (filepath?: string, f?: string | null) =>
25
+ (f = null == filepath ? null : Path.basename(filepath),
26
+ g.__dlog__.filter((n: any[]) => n[0] === tag && (null == f || n[2] === f)))
27
+ return dlog
28
+ }
29
+
30
+
11
31
  function loadFile(path: string, what: string, fs: FsUtil, log: Log) {
12
32
  try {
13
33
  const source = fs.readFileSync(path, 'utf8')
@@ -36,27 +56,35 @@ function depluralize(word: string): string {
36
56
 
37
57
  // Common irregular plurals
38
58
  const irregulars: Record<string, string> = {
59
+ 'analyses': 'analysis',
60
+ 'appendices': 'appendix',
61
+ 'axes': 'axis',
39
62
  'children': 'child',
40
- 'men': 'man',
41
- 'women': 'woman',
42
- 'teeth': 'tooth',
63
+ 'courses': 'course',
64
+ 'crises': 'crisis',
65
+ 'criteria': 'criterion',
66
+ 'data': 'datum',
67
+ 'diagnoses': 'diagnosis',
43
68
  'feet': 'foot',
69
+ 'furnace': 'furnaces',
44
70
  'geese': 'goose',
45
- 'mice': 'mouse',
46
- 'people': 'person',
47
- 'data': 'datum',
48
- 'criteria': 'criterion',
49
- 'phenomena': 'phenomenon',
71
+ 'horses': 'horse',
72
+ 'house': 'houses',
50
73
  'indices': 'index',
74
+ 'license': 'licenses',
51
75
  'matrices': 'matrix',
52
- 'vertices': 'vertex',
53
- 'analyses': 'analysis',
54
- 'axes': 'axis',
55
- 'crises': 'crisis',
56
- 'diagnoses': 'diagnosis',
76
+ 'men': 'man',
77
+ 'mice': 'mouse',
78
+ 'notice': 'notices',
57
79
  'oases': 'oasis',
80
+ 'people': 'person',
81
+ 'phenomena': 'phenomenon',
82
+ 'practice': 'practices',
83
+ 'promise': 'promises',
84
+ 'teeth': 'tooth',
58
85
  'theses': 'thesis',
59
- 'appendices': 'appendix'
86
+ 'vertices': 'vertex',
87
+ 'women': 'woman',
60
88
  }
61
89
 
62
90
  if (irregulars[word]) {
@@ -65,6 +93,11 @@ function depluralize(word: string): string {
65
93
 
66
94
  // Rules for regular plurals (applied in order)
67
95
 
96
+ if (word.endsWith('ies') && word.length > 3) {
97
+ return word.slice(0, -3) + 'y'
98
+ }
99
+
100
+
68
101
  // -ies -> -y (cities -> city)
69
102
  if (word.endsWith('ies') && word.length > 3) {
70
103
  return word.slice(0, -3) + 'y'
@@ -153,6 +186,7 @@ function writeChanged(
153
186
 
154
187
 
155
188
  export {
189
+ getdlog,
156
190
  loadFile,
157
191
  formatJsonSrc,
158
192
  depluralize,