0.1.1 • Published 8 years ago

resistance.js v0.1.1

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

Table of Contents

Installation

$ npm install --save resistance.js

Usage

const resistance = require('resistance.js');

resistance([1, 2, 3], 'series');
//=> 6

resistance([1, 2, 3], 'parallel');
//=> 0.5454545454545455

console.log(resistance([1, 2, 3], 'series') + 'Ω')
// 6Ω

API

resistance(circuit, type)

circuit

Type: array

Description: Values of resistors associated in your circuit.

Example: [1, 2, 3, 4]

type

Type: string

Description: Type of resistors association in your circuit.

Options:

  • 'series' or 's': Resistors in series.
  • 'parallel' or 'p': Resistors in parallel.

Understand the Topic

Combinating resistors is very common in many circuits, when we want to reach a resistance level which only one resistor is not enough.

Resistors in Series

Let's take the following example:

Series Example

In an association of series resistors, the equivalent resistor is equal to the sum of all resistors that make up the association:

Req = R1 + R2 + R3 + R4 + ...

Also, the voltage in the electric generator is equal to the sum of all the voltages of resistors:

V = V1 + V2 + V3 + V4 + ...

The electric current flowing in each resistor is always the same:

i = i1 = i2 = i3 = i4 ...

And the initial example becomes:

Final

Resistors in Parallel

Let's take the following example:

Parallel Example

In an association of parallel resistors, the equivalent resistor is equal to the inverse of the sum of all the inverted resistors which make up the association:

1 / Req = (1 / R1) + (1 / R2) + (1 / R3) + (1 / R4) + ...

Also, the current in the equivalent resistor is equal to the sum of currents from the resistors:

 i = i1 + i2 + i3 + i4 + ...

The voltage in the electric generator is always the same:

V = V1 = V2 = V3 = V4 = ...

And the initial example becomes:

Final

Development

All the tasks needed for development automation are defined in the package.json scripts property and can be run via:

npm run <command>

Here is a summary of all the commands:

CommandDescription
compileRuns the Livescript compiler on the source.
testRuns Mocha in BDD mode.
buildRuns both compile and test commands.

Contributing

Contributions are very welcome! If you'd like to contribute, these guidelines may help you.

Motivation

I was studying resistors association because of my Constant Current discipline and then decided to put the basics into practice.

License

resistance.js is distributed under the MIT License, available in this repository. All contributions are assumed to be also licensed under the MIT License.

Credits

Some contents used in the explanation section were taken from here.

0.1.1

8 years ago

0.1.0

8 years ago