-
Notifications
You must be signed in to change notification settings - Fork 3
/
normalize.js
32 lines (26 loc) · 1.03 KB
/
normalize.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import Bir from 'bir1'
import { legacy, modern } from 'bir1/normalize'
/**
* In previous version of that library (1.x, 2.x), there was some preprocessing
* applied to keys and values. This is no longer needed, and by default the
* parsed objects are returned 'as is'. However if you want to use
* old approach, you can use legacy normalize function from `bir1/normalize`.
* Also you can use any other function exported from that module or provide
* your own.
*
* For further details see implementation file://src/normalize.ts .
*/
const myReport = {
regon: '010058960',
report: 'BIR11OsPrawna',
}
// run and compare all three approaches
// legacy approach (some preprocessing)
const birLegacy = new Bir({ normalizeFn: legacy })
console.log(await birLegacy.report(myReport))
// default approach (no preprocessing)
const birStraight = new Bir()
console.log(await birStraight.report(myReport))
// modern approach (some other preprocessing)
const birModern = new Bir({ normalizeFn: modern })
console.log(await birModern.report(myReport))