How to use the dbffile.DBFFile.create function in dbffile

To help you get started, we’ve selected a few dbffile examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yortus / DBFFile / test / writing-a-dbf-file.ts View on Github external
it(test.description, async () => {
            let expectedRecordCount = test.recordCount;
            let expectedFirstRecord: Record | undefined = test.firstRecord;
            let expectedError = test.error;
            try {
                let srcPath = path.join(__dirname, `./fixtures/${test.filename}`);
                let dstPath = path.join(__dirname, `./fixtures/${test.filename}.out`);
                let srcDbf = await DBFFile.open(srcPath, test.options);
                let dstDbf = await DBFFile.create(dstPath, srcDbf.fields.concat(test.newFields), test.options);
                let records = await srcDbf.readRecords(100);
                await dstDbf.appendRecords(records.map(test.newRecord));
                dstDbf = await DBFFile.open(dstPath, test.options);
                records = await dstDbf.readRecords(500);
                expect(dstDbf.recordCount, 'the record count should match').equals(expectedRecordCount);
                expect(records[0], 'first record should match').to.deep.include(expectedFirstRecord!);
            }
            catch (err) {
                expect(err.message).equals(expectedError);
                return;
            }
            expect(undefined).equals(expectedError);
        });
    });

dbffile

Read and write .dbf (dBase III & Visual FoxPro) files in Node.js

MIT
Latest version published 1 day ago

Package Health Score

78 / 100
Full package analysis