npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

digital-logic-gate

v1.0.4

Published

This is for simulation of basic digital logic gates using javascript

Downloads

15

Readme

digital-logic-gate

This is for simulation of basic digital logic gates using javascript

NPM JavaScript Style Guide

Welcome to the digital-logic-gate documentation!

Overview

The main motivation to create this npm based package is to connect the digital electronics simulation domain to the essence of javascript and also making the simulation of the basic gates simpler. Anyone wishing to contribute is most welcome to the repository.

Welcome contributors

What you need to learn before the start?

You have to know about the basics of digital gates AND, OR, NOT, NAND, NOR, XOR and XNOR.You have to know about the truth table of that particular gate for which you are writing code.

Head over to the wiki for more developer documentations.

Install

npm install --save digital-logic-gate

Usage

Here is the basic usage of the following basic gates.

import React, { Component } from 'react'

import { AndGate,ORGate,NoTGate,NANDGate,NORGate,XORGate,XNORGate } from 'digital-logic-gate'

function simuLateSomething(){

  const AndGateResult = AndGate(1,1); // 1
  const ORGateResult = ORGate(0,1); // 1
  const NoTGateResult = NoTGate(1);  // 0
  const NANDGateResult = NANDGate(0,0); //1
  const NORGateResult = NORGate(0,1); // 0
  const XORResult = XORGate(0,1); // 1
  const XNORResult = XNORGate(0,0); // 1

}

Gates Demonstration

AND Gate

The following figure shows the logic diagram of a 2 input AND gate.

Alt text

Here is the truth table of the above gate.

| A | B | F = A.B | | ---|:-:| -------:| | 0 | 0 | 0 | | 0 | 1 | 0 | | 1 | 0 | 0 | | 1 | 1 | 1 |

Usage of the above gate

import React, { Component } from 'react'

import { AndGate } from 'digital-logic-gate'


function simuLateSomething(){

  const AndGateResultA = AndGate(0,0); // 0
  const AndGateResultB = AndGate(0,1); // 0
  const AndGateResultC = AndGate(1,0); // 0
  const AndGateResultD = AndGate(1,1); // 1

}

OR Gate

The following figure shows the logic diagram of a 2 input OR gate.

Alt text

Here is the truth table of the above gate.

| A | B | F = A+B | | ---|:-:| -------:| | 0 | 0 | 0 | | 0 | 1 | 1 | | 1 | 0 | 1 | | 1 | 1 | 1 |

Usage of the above gate

import React, { Component } from 'react'

import { ORGate } from 'digital-logic-gate'


function simuLateSomething(){
  const ORGateResultA = ORGate(0,0); // 0
  const ORGateResultB = ORGate(0,1); // 1
  const ORGateResultC = ORGate(1,0); // 1
  const ORGateResultD = ORGate(1,1); // 1


}

NOT Gate

The following figure shows the logic diagram of a NOT gate.

Alt text

Here is the truth table of the above gate.

| A | F = A' | | ---|:-------:| | 0 | 1 | | 1 | 0 |

Usage of the above gate

import React, { Component } from 'react'

import { NoTGate } from 'digital-logic-gate'


function simuLateSomething(){
  const NoTGateResultA = NoTGate(1);  // 0
  const NoTGateResultB = NoTGate(0);  // 1


}

Other Basic Gate Functions

Before calling the functions always import them just like below

import React from 'react'
import { AndGate,ORGate,NoTGate,NANDGate,NORGate,XORGate,XNORGate } from 'digital-logic-gate'

| Gate | Logical Function | Usage of API | | --- |:----------------:|:-------------------------:| | NAND | F = (A.B)' | NANDGate(0,0) | | NOR | F = (A+B)' | NORGate(0,1) | | XOR | F = A'B + AB' | XORGate(0,1) | | XNOR | F = AB + A'B' | XNORGate(0,0) |

How to Contribute

Instructions-

  • Fork this Repository using the button at the top
  • Clone your forked repository to your pc ( git clone '[email protected]:ayan-biswas0412/digital-logic-gate.git')
  • Create a new branch for your modifications (ie. git branch new-user and check it out git checkout new-user and git checkout -b new-user)
  • Run npm install from inside the cloned project and run npm install from inside the example folder.
  • See the issues from the https://github.com/ayan-biswas0412/digital-logic-gate/issues and comment and ask for working
  • After your assigned work do the following
  • Add your files (git add -A), commit (git commit -m "added myself") and push (git push origin new-user)
  • Create a pull request to the develop branch and your pull request title must contain [dev] keyword and your work short title
  • Star this repository

If your branch is not fully updated with the develop branch please follow the below instructions before making any PR

CAUTION: Synch up your local repo with original repo (Upstream) before pushing your commits. This avoids unnecessary conflicts during the merge.

NOTE: You can do so by adding a remote handler reference to the original repo and pull the changes from the respective branch. Resolve the merge-conflicts if any.

#Add upstream repo
git remote add upstream https://github.com/ayan-biswas0412/digital-logic-gate.git

#Disable accidental push to the upstream
git remote set-url --push upstream DISABLE

#List the remote repo and fetch references
git remote -v && git fetch upstream

#Check for any new commits in the upstream branch
git log HEAD..upstream/master #No output indicates, upstream has not moved ahead

#See the patch difference between local and upstream branch
git diff -p HEAD..upstream/master

CAUTION: If the upstream has moved ahead, rebase your commit and resolve conflicts if any. [Skip otherwise]

git rebase upstream/master

7. Push your local commits to the remote repo.

git push -u origin <your_branch_name>

8. Create a PR !

9. Congratulations! Sit and relax, you've made your contribution to digital-logic-gates project.

Changelog

Keep an eye at the detailed Changelog wiki page

License

MIT © ayan-biswas0412