verity-table
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

verity-table

CI

verity-table is verity table utility lib for NodeJs.

Installation

npm install verity-table

Usage

import { createTable } from 'verity-table';

const table = createTable({
  lines: [
    [false, false, { data: 1 }],
    [false, true, { data: 2 }],
    [true, false, { data: 3 }],
    [true, true, { data: 4 }],
  ],
});

const result = table.run([false, true]);

expect(result).toEqual({ data: 2 });

// you can pass a callback as a result:
const tableWithCb = createTable({
  lines: [
    [false, false, { data: 1 }],
    [false, true, { data: 2 }],
    [true, false, { data: 3 }],
    [true, true, () => ({ data: 4 })],
  ],
});

const result2 = table.run([true, true]);

expect(result).toEqual({ data: 4 });

You can also display the table to visually check your verity table:

import { createTable } from 'verity-table';

const table = createTable({
  lines: [
    [false, false, { data: 1 }],
    [false, true, { data: 2 }],
    [true, false, { data: 3 }],
    [true, true, { data: 4 }],
  ],
});

table.display();

table

Tests

Standard unit test can be run with:

npm test

Readme

Keywords

Package Sidebar

Install

npm i verity-table

Weekly Downloads

5

Version

1.0.5

License

MIT

Unpacked Size

27.6 kB

Total Files

8

Last publish

Collaborators

  • peio