Potential API Changes #28
Replies: 4 comments 1 reply
-
Currently,
It may be better that instead of a import sgqr from 'sgqr'
const generate = sgqr.generate({
number: '+6591234567',
amount: '1.69'
})
const svg = await generate.to_svg()
const png = await generate.to_png() The only issue I have with this is that it can lead to quite ugly code. import sgqr from 'sgqr'
const generate = await sgqr.generate({
number: '+6591234567',
amount: '1.69'
}).to_svg() |
Beta Was this translation helpful? Give feedback.
-
Currently, import sgqr from 'sgqr'
for (let i = 0; i < 10000; i++) {
const code = sgqr.generate({
number: '+6591234567',
amount: '1.69'
})
} So instead of the above, I am thinking of storing the table in a class and letting the GC handle the disposal of the CRC table. I have benchmarked this on JSPerf and at 100,000 requests, we do see about an 80% performance improvement. import { SGQR } from 'sgqr'
const sgqr = new SGQR({
number: '+6591234567',
amount: '1.69'
})
for (let i = 0; i < 10000; i++) {
const code = sgqr.generate()
} However, it may lead to even more 'ugly' code. import { SGQR } from 'sgqr'
const sgqr = await new SGQR({
number: '+6591234567',
amount: '1.69'
}).generate().to_svg().catch(console.error) |
Beta Was this translation helpful? Give feedback.
-
Maybe the CLI should be able to produce the QR code string as well as the image. |
Beta Was this translation helpful? Give feedback.
-
No idea how I missed this until now but I should move to camelCase. |
Beta Was this translation helpful? Give feedback.
-
This discussion will contain the future possible API changes to
sgqr
before v1.0.0.Beta Was this translation helpful? Give feedback.
All reactions