scv-esm 1.111.125 → 1.112.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": "scv-esm",
3
- "version": "1.111.125",
3
+ "version": "1.112.0",
4
4
  "description": "SuttaCentral Voice ES Module",
5
5
  "main": "index.js",
6
6
  "module": "main.mjs",
@@ -27,7 +27,7 @@
27
27
  "eslint": "^9.17.0",
28
28
  "memo-again": "^0.8.0",
29
29
  "mocha": "^11.0.1",
30
- "scv-bilara": "^3.168.37",
30
+ "scv-bilara": "^3.168.38",
31
31
  "should": "^13.2.3",
32
32
  "suttacentral-api": "^2.16.18"
33
33
  }
@@ -1,6 +1,6 @@
1
1
  import AUTHORSV2 from "./auto/authors-v2.mjs";
2
2
  import { default as SuttaRef } from './sutta-ref.mjs';
3
- import { DBG, } from './defines.mjs';
3
+ import { DBG } from './defines.mjs';
4
4
 
5
5
  import { default as suidMap } from './auto/suid-map.mjs';
6
6
 
@@ -10,9 +10,8 @@ export default class AuthorsV2 {
10
10
  }
11
11
 
12
12
  static authorInfo(author, lang) {
13
- const msg = "AuthorsV2.authorInfo() ";
14
- const dbg = DBG.AUTHOR;
15
- const dbgv = DBG.VERBOSE && dbg;
13
+ const msg = "a72.authorInfo() ";
14
+ const dbg = DBG.A72_AUTHOR_INFO;
16
15
  let keys = Object.keys(AUTHORSV2);
17
16
  let authorInfo = keys.reduce((a,k)=>{
18
17
  let info = AUTHORSV2[k];
@@ -20,13 +19,13 @@ export default class AuthorsV2 {
20
19
  return a;
21
20
  }
22
21
  if (info.lang === lang || a==null) {
23
- dbgv && console.log(msg, '[1]info', info.author);
22
+ dbg>1 && console.log(msg, '[1]info', info.author);
24
23
  return info;
25
24
  }
26
- dbgv && console.log(msg, '[2]!lang', info.lang, info.author);
25
+ dbg>1 && console.log(msg, '[2]!lang', info.lang, info.author);
27
26
  return a;
28
27
  }, undefined);
29
- dbgv && console.log(msg, '[3]info', author, authorInfo);
28
+ dbg>1 && console.log(msg, '[3]info', author, authorInfo);
30
29
  return authorInfo;
31
30
  }
32
31
 
@@ -75,8 +74,8 @@ export default class AuthorsV2 {
75
74
  }
76
75
 
77
76
  static langAuthor(lang, opts={}) {
78
- const msg = "AuthorsV2.langAuthor()";
79
- const dbg = DBG.AUTHOR;
77
+ const msg = "a72.langAuthor()";
78
+ const dbg = DBG.A72_LANG_AUTHOR;
80
79
  let {
81
80
  category='sutta',
82
81
  } = opts;
@@ -114,9 +113,8 @@ export default class AuthorsV2 {
114
113
  }
115
114
 
116
115
  static compareInfo(info1, info2) {
117
- const msg = "AuthorsV2.compareInfo()";
118
- const dbg = DBG.AUTHOR;
119
- const dbgv = DBG.VERBOSE && dbg;
116
+ const msg = "a72.compareInfo()";
117
+ const dbg = DBG.A72_COMPARE_INFO;
120
118
  if (info1 === info2) {
121
119
  return 0;
122
120
  }
@@ -135,10 +133,10 @@ export default class AuthorsV2 {
135
133
  let deepl2 = info2.author.startsWith('ebt-deepl') ? 1 : 2;
136
134
  let cmp = deepl1 - deepl2;
137
135
  //if (info1.author.startsWith('ebt-deepl')) {
138
- //dbgv && console.log(msg, '[1]info1', info1.name);
136
+ //dbg>1 && console.log(msg, '[1]info1', info1.name);
139
137
  //cmp = -1;
140
138
  //} else if (info2.author.startsWith('ebt-deepl')) {
141
- //dbgv && console.log(msg, '[2]info2', info2.name);
139
+ //dbg>1 && console.log(msg, '[2]info2', info2.name);
142
140
  //cmp = 1;
143
141
  //}
144
142
  }
@@ -149,8 +147,8 @@ export default class AuthorsV2 {
149
147
  }
150
148
 
151
149
  static compare(author1, author2) {
152
- const msg = "authors-v2.compare() ";
153
- const dbg = 0 || DBG.AUTHOR;
150
+ const msg = "a72.compare() ";
151
+ const dbg = DBG.A72_COMPARE;
154
152
  author1 = !!author1 ? author1 : '';
155
153
  author2 = !!author2 ? author2 : '';
156
154
  let noauthor = {author:'no-author'};
@@ -206,8 +204,8 @@ export default class AuthorsV2 {
206
204
  }
207
205
 
208
206
  static suttaAuthor(suttaRef) {
209
- const msg = 'AuthorsV2.suttaAuthor()';
210
- const dbg = DBG.AUTHOR;
207
+ const msg = 'a72.suttaAuthor()';
208
+ const dbg = DBG.A72_SUTTA_AUTHOR;
211
209
  let {
212
210
  sutta_uid, lang, author
213
211
  } = SuttaRef.create(suttaRef);
@@ -223,6 +221,10 @@ export default class AuthorsV2 {
223
221
  let bpv = bPaths[bpk] || '';
224
222
  let [ ignore, bpLang, bpAuthor ] = bpk.split('/');
225
223
  let info = AuthorsV2.authorInfo(bpAuthor, bpLang);
224
+ if (info == null) { // aligned legacy (fr/wijayaratna)
225
+ dbg && console.log(msg, {bpAuthor, bpLang});
226
+ return a;
227
+ }
226
228
  let { stats } = info;
227
229
  let bpvParts = bpv && bpv.split('/');
228
230
  let statsScore = stats
package/src/defines.mjs CHANGED
@@ -1,7 +1,6 @@
1
1
  export const DBG = {
2
- AUTHOR: 0,
3
- COMPARE: 0,
4
- SUTTA_REF: 0,
5
- VERBOSE: 0,
2
+ A72_SUTTA_AUTHOR: 0,
3
+ A72_COMPARE: 0,
4
+ S6F_CREATE_OPTS: 0,
6
5
  };
7
6
 
package/src/sutta-ref.mjs CHANGED
@@ -24,8 +24,8 @@ export default class SuttaRef {
24
24
  }
25
25
 
26
26
  static createFromString(str='', defaultLang="pli", suids=SUIDS) {
27
- const msg = 'SuttaRef.createFromString()';
28
- const dbg = DBG.SUTTA_REF;
27
+ const msg = 's6f.createFromString()';
28
+ const dbg = DBG.S6F_CREATE_FROM_STRING;
29
29
  let refLower = str.toLowerCase();
30
30
  let segMatch = refLower.match(/:[-0-9.]*/);
31
31
  let segnum;
@@ -114,7 +114,7 @@ export default class SuttaRef {
114
114
  }
115
115
 
116
116
  static createFromObject(obj, defaultLang="pli", suids=SUIDS) {
117
- const msg = "SuttaRef.createFromObject() ";
117
+ const msg = "s6f.createFromObject() ";
118
118
  let parsed = SuttaRef.createFromString(
119
119
  obj.sutta_uid,
120
120
  obj.lang || defaultLang
@@ -145,18 +145,21 @@ export default class SuttaRef {
145
145
  }
146
146
 
147
147
  static create(strOrObj, defaultLang="pli", suids=SUIDS) {
148
+ const msg = 's6f.create:';
148
149
  try {
149
150
  return SuttaRef.createWithError(strOrObj, defaultLang, suids);
150
151
  } catch(e) {
151
152
  let args = JSON.stringify(strOrObj);
152
- let msg = `SuttaRef.create() ${args} => ${e.message}`;
153
- logger.warn(msg);
153
+ let emsg = `${msg} ${args} => ${e.message}`;
154
+ logger.warn(emsg);
154
155
  }
155
156
 
156
157
  return null;
157
158
  }
158
159
 
159
160
  static createOpts(strOrObj, opts={}) {
161
+ const msg = 's6f.createOpts:';
162
+ const dbg = DBG.S6F_CREATE_OPTS;
160
163
  let {
161
164
  defaultLang = 'pli',
162
165
  suids = SUIDS,
@@ -167,6 +170,7 @@ export default class SuttaRef {
167
170
  return undefined;
168
171
  }
169
172
 
173
+ dbg && console.log(msg, '[1]', {strOrObj, defaultLang, normalize});
170
174
  let sref = typeof strOrObj === 'string'
171
175
  ? SuttaRef.create(strOrObj, defaultLang, suids)
172
176
  : SuttaRef.create(Object.assign({},strOrObj), defaultLang, suids);
@@ -174,6 +178,7 @@ export default class SuttaRef {
174
178
  if (normalize && sref) {
175
179
  let { sutta_uid, lang, author, segnum } = sref;
176
180
  if (sutta_uid && author == null) {
181
+ dbg && console.log(msg, '[2]author?', {sref});
177
182
  sref.author = AuthorsV2.suttaAuthor(sref);
178
183
  }
179
184
  }