boolean-json-bifurcate

js
convert K-ary conjunctions and disjunctions to binary expressions
Version 0.1.2 License MIT
<script type="module"> import booleanJsonBifurcate from 'https://cdn.jsdelivr.net/npm/boolean-json-bifurcate@0.1.2/+esm' </script>
var assert = require('assert')
var bifurcate = require('boolean-json-bifurcate')
assert.deepEqual(
bifurcate({and: ['p', 'q']}),
{and: ['p', 'q']}
)
assert.deepEqual(
bifurcate({and: ['p', 'q', 'r', 's']}),
{and: ['p', {and: ['q', {and: ['r', 's']}]}]}
)
assert.deepEqual(
bifurcate({or: ['p', 'q', 'r', 's']}),
{or: ['p', {or: ['q', {or: ['r', 's']}]}]}
)
assert.deepEqual(
bifurcate({not: {or: [{not: 'p'}, 'q', 'r']}}),
{not: {or: [{not: 'p'}, {or: ['q', 'r']}]}}
)