How to use dbffile - 4 common examples

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 / reading-a-dbf-file.ts View on Github external
it(test.description, async () => {
            let filepath = path.join(__dirname, `./fixtures/${test.filename}`);
            let options = test.options;
            let expectedRecordCount = test.recordCount;
            let expectedFirstRecord: Record | undefined = test.firstRecord;
            let expectedLastRecord: Record | undefined = test.lastRecord;
            let expectedDeletedCount = test.deletedCount;
            let expectedError = test.error;
            try {
                let dbf = await DBFFile.open(filepath, options);
                let records = await dbf.readRecords();
                expect(dbf.recordCount, 'the record count should match').equals(expectedRecordCount);
                expect(records[0], 'first record should match').to.deep.include(expectedFirstRecord!);
                expect(records[records.length - 1], 'last record should match').to.deep.include(expectedLastRecord!);
                expect(dbf.recordCount - records.length, 'deleted records should match').equals(expectedDeletedCount);
            }
            catch (err) {
                expect(err.message).equals(expectedError);
                return;
            }
            expect(undefined).equals(expectedError);
        });
    });
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);
        });
    });
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);
        });
    });
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 7 months ago

Package Health Score

64 / 100
Full package analysis