verity-table

A simple verity table

Usage no npm install needed!

<script type="module">
  import verityTable from 'https://cdn.skypack.dev/verity-table';
</script>

README

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