(records, opts = {})
| 2 | import { normalize_options } from "./api/normalize_options.js"; |
| 3 | |
| 4 | const stringify = function (records, opts = {}) { |
| 5 | const data = []; |
| 6 | const [err, options] = normalize_options(opts); |
| 7 | if (err !== undefined) throw err; |
| 8 | const state = { |
| 9 | stop: false, |
| 10 | }; |
| 11 | // Information |
| 12 | const info = { |
| 13 | records: 0, |
| 14 | }; |
| 15 | const api = stringifier(options, state, info); |
| 16 | for (const record of records) { |
| 17 | const err = api.__transform(record, function (record) { |
| 18 | data.push(record); |
| 19 | }); |
| 20 | if (err !== undefined) throw err; |
| 21 | } |
| 22 | if (data.length === 0) { |
| 23 | api.bom((d) => { |
| 24 | data.push(d); |
| 25 | }); |
| 26 | const err = api.headers((headers) => { |
| 27 | data.push(headers); |
| 28 | }); |
| 29 | if (err !== undefined) throw err; |
| 30 | } |
| 31 | return data.join(""); |
| 32 | }; |
| 33 | |
| 34 | export { stringify }; |
no test coverage detected