Nanobots Protecting Microbots

    @thi.ng/dlogic
    TypeScript icon, indicating that this package has built-in type declarations

    2.1.6 • Public • Published

    dlogic

    npm version npm downloads Twitter Follow

    This project is part of the @thi.ng/umbrella monorepo.

    About

    Assorted digital logic gates and ops for boolean values to compose complex logic in a more functional manner, e.g. for DSL or simulation purposes. Truth tables and references are provided in the doc strings of each function.

    Also see @thi.ng/binary for binary versions of most of the ops provided by this package.

    Status

    STABLE - used in production

    Search or submit any issues for this package

    Installation

    yarn add @thi.ng/dlogic

    ES module import:

    <script type="module" src="https://cdn.skypack.dev/@thi.ng/dlogic"></script>

    Skypack documentation

    For Node.js REPL:

    # with flag only for < v16
    node --experimental-repl-await
    
    > const dlogic = await import("@thi.ng/dlogic");
    

    Package sizes (gzipped, pre-treeshake): ESM: 393 bytes

    Dependencies

    API

    Generated API docs

    import { nand } from "@thi.ng/dlogic";
    
    // XOR construction only using NAND gates
    const xor = (a: boolean, b: boolean) => {
        const ab = nand(a,b);
        return nand(nand(a, ab), nand(b, ab));
    };
    
    xor(false, false)
    // false
    xor(false, true)
    // true
    xor(true, false)
    // true
    xor(true, true)
    // false

    Authors

    Karsten Schmidt

    If this project contributes to an academic publication, please cite it as:

    @misc{thing-dlogic,
      title = "@thi.ng/dlogic",
      author = "Karsten Schmidt",
      note = "https://thi.ng/dlogic",
      year = 2017
    }

    License

    © 2017 - 2022 Karsten Schmidt // Apache Software License 2.0

    Install

    npm i @thi.ng/dlogic

    DownloadsWeekly Downloads

    185

    Version

    2.1.6

    License

    Apache-2.0

    Unpacked Size

    29.1 kB

    Total Files

    6

    Last publish

    Collaborators

    • thi.ng