1.1.1 • Published 7 years ago

boolean-json-prune v1.1.1

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

boolean-json-prune

NPM

Build Status

This package cleans up boolean-json expressions.

Usage

const prune = require('boolean-json-prune');

const input = {
    and: [{
        or: [{
            and: [{
                and: ['foo', 'bar']
            }, {
                and: ['foo2', 'bar2']
            }]
        }, {
            or: ['foo3', 'bar4']
        }]
    }, 'foo4']
};

const output = prune(input);
/*
{
    and: [{
        or: [{
            and: ['foo', 'bar', 'foo2', 'bar2']
        }, 'foo3', 'bar4']
    }, 'foo4']
}
*/

Operations

Note: any combination of these operations is also possible.

Combining nested conjunctions/disjunctions

Input:

{
    "and": ["foo", "bar", {
        "and": ["baz", "foo2"]
    }]
}

Output:

{
    "and": ["foo", "bar", "baz", "foo2"]
}

Removing duplicates

Input:

{
    "and": ["foo", "foo", "bar"]
}

Output:

{
    "and": ["foo", "bar"]
}

Removing redundant nested conjunctions/disjunctions

Input:

{
    "or": ["foo", {
        "and": ["foo", "bar", "baz"]
    }]
}

Output:

"foo"

Input:

{
    "and": ["foo", {
        "or": ["foo", "bar", "baz"]
    }]
}

Output:

"foo"
1.1.1

7 years ago

1.1.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago