File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ /**
4+ * TankCircuit is a class with methods that can be used without initializing.
5+ *
6+ * Its methods provide calculations for a Tank Circuit (LC), (Inductor and Capacitor) resonant circuit.
7+ *
8+ * @example
9+ *
10+ * RCCircuit.lowPassFilter(1000, 1 / 100000000);
11+ *
12+ */
13+ class RCCircuit {
14+
15+ /**
16+ *
17+ * Take a value of resistance in ohms and value of capacitance in farads and calculates the
18+ * cut off frequency of a low-pass circuit. The return value is in hertz.
19+ *
20+ * @param {number } resistance
21+ * @param {number } capacitance
22+ * @returns {number }
23+ */
24+ static lowPassFilter ( resistance , capacitance ) {
25+ return 1 / ( 2 * Math . PI * resistance * capacitance ) ;
26+ }
27+
28+
29+ }
30+
31+ export default RCCircuit ;
Original file line number Diff line number Diff line change 1+ const RCCircuit = require ( './RC-Circuit' ) ;
2+
3+
4+ describe ( 'TankCircuit' , ( ) => {
5+
6+ test ( 'if resistance in ohms is 1000 and capacitance in farads is .00000001 then cut-off frequency should be 15915.494309189537' , ( ) => {
7+ const resistance = 1000 ;
8+ const capacitance = .00000001 ;
9+
10+ expect ( RCCircuit . lowPassFilter ( resistance , capacitance ) ) . toEqual ( 15915.494309189537 )
11+ } ) ;
12+
13+
14+ } ) ;
You can’t perform that action at this time.
0 commit comments