cbor-x 1.3.1 → 1.3.2

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/decode.d.ts CHANGED
@@ -39,6 +39,7 @@ export class Decoder {
39
39
  export function decode(messagePack: Buffer | Uint8Array): any
40
40
  export function decodeMultiple(messagePack: Buffer | Uint8Array, forEach?: (value: any) => any): [] | void
41
41
  export function addExtension(extension: Extension): void
42
+ export function clearSource(): void
42
43
  export function roundFloat32(float32Number: number): number
43
44
  export let isNativeAccelerationEnabled: boolean
44
45
 
package/dist/node.cjs CHANGED
@@ -2250,17 +2250,19 @@ function decodeIter (bufferIterator, options = {}) {
2250
2250
  const useRecords = false;
2251
2251
  const mapsAsObjects = true;
2252
2252
 
2253
- const extractor = tryRequire('cbor-extract');
2254
- if (extractor)
2255
- setExtractor(extractor.extractStrings);
2253
+ const nativeAccelerationDisabled = process.env.CBOR_NATIVE_ACCELERATION_DISABLED !== undefined && process.env.CBOR_NATIVE_ACCELERATION_DISABLED.toLowerCase() === 'true';
2256
2254
 
2257
- function tryRequire(moduleId) {
2255
+ if (!nativeAccelerationDisabled) {
2256
+ let extractor;
2258
2257
  try {
2259
- let require$1 = module$1.createRequire((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('node.cjs', document.baseURI).href)));
2260
- return require$1(moduleId)
2258
+ if (typeof require == 'function')
2259
+ extractor = require('cbor-extract');
2260
+ else
2261
+ extractor = module$1.createRequire((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('node.cjs', document.baseURI).href)))('cbor-extract');
2262
+ if (extractor)
2263
+ setExtractor(extractor.extractStrings);
2261
2264
  } catch (error) {
2262
- if (typeof window != 'undefined')
2263
- console.warn('For browser usage, directly use cbor-x/decode or cbor-x/encode modules. ' + error.message.split('\n')[0]);
2265
+ // native module is optional
2264
2266
  }
2265
2267
  }
2266
2268
 
package/dist/test.js CHANGED
@@ -1,586 +1,10 @@
1
- (function (CBOR, chai) {
1
+ (function (CBOR, chai, fs) {
2
2
  'use strict';
3
3
 
4
4
  chai = chai && Object.prototype.hasOwnProperty.call(chai, 'default') ? chai['default'] : chai;
5
5
 
6
- var metadata = {
7
- Designs: [
8
- "Randomized Controlled Trial"
9
- ],
10
- Types: [
11
- ],
12
- BriefSummary: "To determine the efficacy, long-term safety, and tolerability of alirocumab 300 mg every 4\n weeks (Q4W), in comparison with placebo, as well as its potential as a starting regimen. The\n dose regimen of 75 mg every 2 weeks (Q2W), as used in other studies, was added as a\n calibrator.",
13
- Abstract: "To determine the efficacy, long-term safety, and tolerability of alirocumab 300 mg every 4\n weeks (Q4W), in comparison with placebo, as well as its potential as a starting regimen. The\n dose regimen of 75 mg every 2 weeks (Q2W), as used in other studies, was added as a\n calibrator.",
14
- Acronym: null,
15
- ArticleId: "Qy3gwKWSoaWRmbmFEQA",
16
- Authors: null,
17
- CochraneID: null,
18
- Confidential: false,
19
- CorporateAuthor: null,
20
- Country: "Bulgaria, Canada, Hungary, Israel, Norway, Slovakia, United Kingdom, United States",
21
- CustomData: null,
22
- DatabaseType: "ClinicalTrials.gov",
23
- DOI: null,
24
- EmbaseAccessionNumber: null,
25
- Emtree: null,
26
- ErrataText: null,
27
- FullTextURL: null,
28
- Institution: null,
29
- ISSN: null,
30
- Issue: null,
31
- JournalTitle: null,
32
- MedlineID: null,
33
- MeSH: "Hypercholesterolemia|Antibodies, Monoclonal",
34
- Pages: null,
35
- ParentChildStatus: null,
36
- ParentID: null,
37
- PublicationDate: "March 21, 2017",
38
- PublicationYear: 2017,
39
- PubType: null,
40
- ReferenceStudy: null,
41
- SecondarySourceID: null,
42
- Source: "Regeneron Pharmaceuticals",
43
- SourceReferenceId: "NCT01926782",
44
- TaStudyDesign: "Randomized",
45
- Title: "A Randomized, Double-Blind, Placebo-Controlled Study to Evaluate the Efficacy and Safety of an Every Four Weeks Treatment Regimen of Alirocumab in Patients With Primary Hypercholesterolemia",
46
- TrialOutcome: null,
47
- Volume: null,
48
- Id: 179246831,
49
- Created: "2020-04-10T14:48:20.4384957Z",
50
- VersionNo: 2,
51
- ExtractData: null,
52
- Digitized: true,
53
- IsRapidExtract: false,
54
- IsUploaded: false
55
- };
56
- var design = "Randomized Controlled Trial";
57
- var conditions = [
58
- {
59
- label: "Cholesterol Total Increased",
60
- id: "SUE_c"
61
- }
62
- ];
63
- var phase = 3;
64
- var name = "NCT01926782";
65
- var trialIds = [
66
- "NCT01926782"
67
- ];
68
- var acronyms = [
69
- ];
70
- var outcomeCount = 156;
71
- var id = 179246831;
72
- var groups = [
73
- {
74
- Id: "4r",
75
- RefId: "B5|O2~Alirocumab 75 mg Q2W/Up 150 mg Q2W Without Concomitant Statin",
76
- OriginalName: "Alirocumab 75 mg Q2W/Up 150 mg Q2W Without Concomitant Statin",
77
- N: 37,
78
- age: 59.3,
79
- ageSD: 11.3,
80
- male: 37.83783783783784,
81
- Interventions: [
82
- {
83
- termIds: [
84
- [
85
- "SUBYEL",
86
- "SUB_Oc"
87
- ],
88
- [
89
- "SUNUVb"
90
- ]
91
- ]
92
- }
93
- ],
94
- analyzeAs: "Alirocumab",
95
- analyzableScore: 1.0717734625362931,
96
- matchingScore: 0
97
- },
98
- {
99
- Id: "zB",
100
- RefId: "B6|O3~Alirocumab 300 mg Q4W/Up 150 mg Q2W Without Concomitant Statin",
101
- OriginalName: "Alirocumab 300 mg Q4W/Up 150 mg Q2W Without Concomitant Statin",
102
- N: 146,
103
- age: 59.2,
104
- ageSD: 10.8,
105
- male: 45.205479452054796,
106
- Interventions: [
107
- {
108
- termIds: [
109
- [
110
- "SUBYEL",
111
- "SUB_Oc"
112
- ]
113
- ]
114
- }
115
- ],
116
- analyzeAs: "Statins",
117
- analyzableScore: 1.0717734625362931,
118
- matchingScore: 0
119
- },
120
- {
121
- Id: "3!",
122
- RefId: "B4|O1~Placebo Q2W Without Concomitant Statin",
123
- OriginalName: "Placebo Q2W Without Concomitant Statin",
124
- N: 73,
125
- age: 59.4,
126
- ageSD: 10.2,
127
- male: 54.794520547945204,
128
- Interventions: [
129
- {
130
- termIds: [
131
- [
132
- "SUGeLS"
133
- ],
134
- [
135
- "SUBYEL",
136
- "SUB_Oc"
137
- ]
138
- ]
139
- }
140
- ],
141
- analyzeAs: "Control",
142
- analyzableScore: 1.2020833333333334,
143
- matchingScore: 0
144
- },
145
- {
146
- Id: "tv",
147
- RefId: "E3",
148
- OriginalName: "Alirocumab 300 mg Q4W/Up 150 mg Q2W",
149
- Interventions: [
150
- {
151
- termIds: [
152
- [
153
- "SUCO54",
154
- "SUNUVb"
155
- ]
156
- ]
157
- }
158
- ]
159
- },
160
- {
161
- Id: "jt",
162
- RefId: "B3|O3~Alirocumab 300 mg Q4W/Up 150 mg Q2W With Concomitant Statin",
163
- OriginalName: "Alirocumab 300 mg Q4W/Up 150 mg Q2W With Concomitant Statin",
164
- N: 312,
165
- age: 61.6,
166
- ageSD: 10,
167
- male: 60.8974358974359,
168
- Interventions: [
169
- {
170
- termIds: [
171
- [
172
- "SUBYEL",
173
- "SUB_Oc"
174
- ]
175
- ]
176
- }
177
- ]
178
- },
179
- {
180
- Id: "5!",
181
- RefId: "E2",
182
- OriginalName: "Alirocumab 75 mg Q2W/Up 150 mg Q2W",
183
- Interventions: [
184
- {
185
- termIds: [
186
- [
187
- "SUNUVb"
188
- ]
189
- ]
190
- }
191
- ]
192
- },
193
- {
194
- Id: "4E",
195
- RefId: "B2|O2~Alirocumab 75 mg Q2W/Up 150 mg Q2W With Concomitant Statin",
196
- OriginalName: "Alirocumab 75 mg Q2W/Up 150 mg Q2W With Concomitant Statin",
197
- N: 78,
198
- age: 60.7,
199
- ageSD: 9.1,
200
- male: 65.38461538461539,
201
- Interventions: [
202
- {
203
- termIds: [
204
- [
205
- "SUBYEL",
206
- "SUB_Oc"
207
- ],
208
- [
209
- "SUNUVb"
210
- ]
211
- ]
212
- }
213
- ]
214
- },
215
- {
216
- Id: "i4",
217
- Interventions: [
218
- {
219
- Id: "Ya",
220
- Name: 178613599,
221
- Treatments: [
222
- {
223
- Id: "((",
224
- Phase: "k)"
225
- }
226
- ],
227
- Type: "Drug",
228
- termIds: [
229
- [
230
- "SUGeLS"
231
- ],
232
- [
233
- "SUNUVb"
234
- ]
235
- ],
236
- terms: [
237
- [
238
- "Placebo"
239
- ],
240
- [
241
- "Alirocumab"
242
- ]
243
- ]
244
- },
245
- {
246
- Id: "o)",
247
- Name: 2159990,
248
- Treatments: [
249
- {
250
- Id: "1$",
251
- Phase: "k)"
252
- }
253
- ],
254
- Type: "Drug",
255
- termIds: [
256
- [
257
- "SUBYEL"
258
- ]
259
- ],
260
- terms: [
261
- [
262
- "Statins"
263
- ]
264
- ]
265
- }
266
- ],
267
- RefId: "E1|Placebo Q2W",
268
- OriginalName: "Placebo Q2W"
269
- },
270
- {
271
- Id: "Ls",
272
- RefId: "B1|O1~Placebo Q2W With Concomitant Statin",
273
- OriginalName: "Placebo Q2W With Concomitant Statin",
274
- N: 157,
275
- age: 61.6,
276
- ageSD: 9.7,
277
- male: 64.3312101910828,
278
- Interventions: [
279
- {
280
- termIds: [
281
- [
282
- "SUGeLS"
283
- ],
284
- [
285
- "SUBYEL",
286
- "SUB_Oc"
287
- ]
288
- ]
289
- }
290
- ]
291
- }
292
- ];
293
- var hasDocData = true;
294
- var hasRapidExtract = false;
295
- var N = 803;
296
- var queryScore = 1.4868329805051381;
297
- var matchingScore = 7.960635921410255;
298
- var score = 22.084654254966498;
299
- var outcomes = [
300
- {
301
- id: "179246387",
302
- type: "Change",
303
- unit: "%",
304
- termIds: [
305
- [
306
- "SUF0R",
307
- "SUBskP"
308
- ]
309
- ],
310
- quantifiers: [
311
- ],
312
- name: "Calculated LDL-C in Not Receiving Concomitant Statin Therapy - On-Treatment Analysis",
313
- cells: [
314
- {
315
- number: -0.4,
316
- unit: "%",
317
- group: "3!",
318
- varType: "se",
319
- N: 70,
320
- se: 2,
321
- sd: 16.73
322
- },
323
- {
324
- number: -54.6,
325
- unit: "%",
326
- group: "4r",
327
- varType: "se",
328
- N: 37,
329
- se: 2.8,
330
- sd: 17.03
331
- },
332
- {
333
- number: -59.4,
334
- unit: "%",
335
- group: "zB",
336
- varType: "se",
337
- N: 141,
338
- se: 1.4,
339
- sd: 16.62
340
- }
341
- ],
342
- time: {
343
- Id: 67122072,
344
- Low: {
345
- Value: "Baseline"
346
- },
347
- High: {
348
- "Number": 24,
349
- Unit: "wk"
350
- },
351
- Type: "Total",
352
- days: 168,
353
- description: "24wk"
354
- },
355
- score: 2.08,
356
- matchingTerm: "SUF0R",
357
- suggestedPositive: false,
358
- sourceUnit: "%"
359
- },
360
- {
361
- id: "179246389",
362
- type: "Change",
363
- unit: "%",
364
- termIds: [
365
- [
366
- "SUF0R",
367
- "SUBskP"
368
- ]
369
- ],
370
- quantifiers: [
371
- ],
372
- name: "Calculated LDL-C in Receiving Concomitant Statin Therapy - On-Treatment Analysis",
373
- cells: [
374
- {
375
- number: -0.3,
376
- unit: "%",
377
- group: "Ls",
378
- varType: "se",
379
- N: 151,
380
- se: 2.1,
381
- sd: 25.81
382
- },
383
- {
384
- number: -55.1,
385
- unit: "%",
386
- group: "4E",
387
- varType: "se",
388
- N: 75,
389
- se: 3,
390
- sd: 25.98
391
- },
392
- {
393
- number: -62.3,
394
- unit: "%",
395
- group: "jt",
396
- varType: "se",
397
- N: 302,
398
- se: 1.5,
399
- sd: 26.07
400
- }
401
- ],
402
- time: {
403
- Id: 67122072,
404
- Low: {
405
- Value: "Baseline"
406
- },
407
- High: {
408
- "Number": 24,
409
- Unit: "wk"
410
- },
411
- Type: "Total",
412
- days: 168,
413
- description: "24wk"
414
- },
415
- score: 2.08,
416
- matchingTerm: "SUF0R",
417
- suggestedPositive: false,
418
- sourceUnit: "%"
419
- },
420
- {
421
- id: "179246393",
422
- type: "Change",
423
- unit: "%",
424
- termIds: [
425
- [
426
- "SUF0R",
427
- "SUBskP"
428
- ]
429
- ],
430
- quantifiers: [
431
- ],
432
- name: "Calculated LDL-C in Not Receiving Concomitant Statin Therapy - On-Treatment Analysis",
433
- cells: [
434
- {
435
- number: -0.5,
436
- unit: "%",
437
- group: "3!",
438
- varType: "se",
439
- N: 70,
440
- se: 2,
441
- sd: 16.73
442
- },
443
- {
444
- number: -53.9,
445
- unit: "%",
446
- group: "4r",
447
- varType: "se",
448
- N: 37,
449
- se: 2.7,
450
- sd: 16.42
451
- },
452
- {
453
- number: -60,
454
- unit: "%",
455
- group: "zB",
456
- varType: "se",
457
- N: 141,
458
- se: 1.4,
459
- sd: 16.62
460
- }
461
- ],
462
- time: {
463
- Id: 67122069,
464
- Low: {
465
- Value: "Baseline"
466
- },
467
- High: {
468
- "Number": 12,
469
- Unit: "wk"
470
- },
471
- Type: "Total",
472
- days: 84,
473
- description: "12wk"
474
- },
475
- score: 2.08,
476
- matchingTerm: "SUF0R",
477
- suggestedPositive: false,
478
- sourceUnit: "%"
479
- },
480
- {
481
- id: "179246394",
482
- type: "Change",
483
- unit: "%",
484
- termIds: [
485
- [
486
- "SUF0R",
487
- "SUBskP"
488
- ]
489
- ],
490
- quantifiers: [
491
- ],
492
- name: "Calculated LDL-C in Receiving Concomitant Statin Therapy - On-Treatment Analysis",
493
- cells: [
494
- {
495
- number: 1.4,
496
- unit: "%",
497
- group: "Ls",
498
- varType: "se",
499
- N: 151,
500
- se: 1.9,
501
- sd: 23.35
502
- },
503
- {
504
- number: -47.3,
505
- unit: "%",
506
- group: "4E",
507
- varType: "se",
508
- N: 75,
509
- se: 2.8,
510
- sd: 24.25
511
- },
512
- {
513
- number: -58,
514
- unit: "%",
515
- group: "jt",
516
- varType: "se",
517
- N: 302,
518
- se: 1.4,
519
- sd: 24.33
520
- }
521
- ],
522
- time: {
523
- Id: 67122069,
524
- Low: {
525
- Value: "Baseline"
526
- },
527
- High: {
528
- "Number": 12,
529
- Unit: "wk"
530
- },
531
- Type: "Total",
532
- days: 84,
533
- description: "12wk"
534
- },
535
- score: 2.08,
536
- matchingTerm: "SUF0R",
537
- suggestedPositive: false,
538
- sourceUnit: "%"
539
- }
540
- ];
541
- var characteristics = [
542
- {
543
- id: "179246354",
544
- type: "Binary",
545
- isCharacteristic: true,
546
- termIds: [
547
- [
548
- "SUE_c",
549
- "SUCbN",
550
- "SUyJj"
551
- ]
552
- ],
553
- quantifiers: [
554
- ],
555
- name: "Patients not having adequate control of their hypercholesterolemia based on their individual level of CVD risk",
556
- cells: [
557
- ],
558
- number: 100
559
- }
560
- ];
561
- var outcomesScore = 18.97947630112307;
562
- var sampleData = {
563
- metadata: metadata,
564
- design: design,
565
- conditions: conditions,
566
- phase: phase,
567
- name: name,
568
- trialIds: trialIds,
569
- acronyms: acronyms,
570
- outcomeCount: outcomeCount,
571
- id: id,
572
- groups: groups,
573
- hasDocData: hasDocData,
574
- hasRapidExtract: hasRapidExtract,
575
- N: N,
576
- queryScore: queryScore,
577
- matchingScore: matchingScore,
578
- score: score,
579
- outcomes: outcomes,
580
- characteristics: characteristics,
581
- outcomesScore: outcomesScore
582
- };
583
-
6
+ const sampleData = JSON.parse(fs.readFileSync(new URL('./example4.json', (document.currentScript && document.currentScript.src || new URL('test.js', document.baseURI).href))));
7
+
584
8
  const senmlData = [
585
9
  { bn: '/3303/0/5700', bt: 1278887, v: 35.5 },
586
10
  { t: 10, v: 34 },
@@ -1264,4 +688,4 @@
1264
688
  });
1265
689
  });
1266
690
 
1267
- }(CBOR, chai));
691
+ }(CBOR, chai, fs));
package/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- export { Decoder, decode, addExtension, FLOAT32_OPTIONS, clearSource, roundFloat32, isNativeAccelerationEnabled } from './decode.js'
2
- export { Encoder, encode } from './encode.js'
1
+ import { Options } from './decode'
2
+ export { Decoder, decode, addExtension, FLOAT32_OPTIONS, clearSource, roundFloat32, isNativeAccelerationEnabled } from './decode'
3
+ export { Encoder, encode } from './encode'
3
4
  import { Transform, Readable } from 'stream'
4
5
 
5
6
  export as namespace CBOR;
package/node-index.js CHANGED
@@ -7,16 +7,18 @@ export const mapsAsObjects = true
7
7
  import { setExtractor } from './decode.js'
8
8
  import { createRequire } from 'module'
9
9
 
10
- const extractor = tryRequire('cbor-extract')
11
- if (extractor)
12
- setExtractor(extractor.extractStrings)
10
+ const nativeAccelerationDisabled = process.env.CBOR_NATIVE_ACCELERATION_DISABLED !== undefined && process.env.CBOR_NATIVE_ACCELERATION_DISABLED.toLowerCase() === 'true';
13
11
 
14
- function tryRequire(moduleId) {
12
+ if (!nativeAccelerationDisabled) {
13
+ let extractor
15
14
  try {
16
- let require = createRequire(import.meta.url)
17
- return require(moduleId)
15
+ if (typeof require == 'function')
16
+ extractor = require('cbor-extract')
17
+ else
18
+ extractor = createRequire(import.meta.url)('cbor-extract')
19
+ if (extractor)
20
+ setExtractor(extractor.extractStrings)
18
21
  } catch (error) {
19
- if (typeof window != 'undefined')
20
- console.warn('For browser usage, directly use cbor-x/decode or cbor-x/encode modules. ' + error.message.split('\n')[0])
22
+ // native module is optional
21
23
  }
22
24
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cbor-x",
3
3
  "author": "Kris Zyp",
4
- "version": "1.3.1",
4
+ "version": "1.3.2",
5
5
  "description": "Ultra-fast and conformant CBOR (RFC 8949) implementation with support for numerous tag extensions including records and structured cloning",
6
6
  "license": "MIT",
7
7
  "types": "./index.d.ts",