@wisemen/quantity 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/quantities/current/current-unit.enum.d.ts +29 -0
- package/dist/quantities/current/current-unit.enum.js +38 -0
- package/dist/quantities/current/current-unit.enum.js.map +1 -0
- package/dist/quantities/current/current.column.d.ts +3 -0
- package/dist/quantities/current/current.column.js +6 -0
- package/dist/quantities/current/current.column.js.map +1 -0
- package/dist/quantities/current/current.d.ts +8 -0
- package/dist/quantities/current/current.dto.d.ts +20 -0
- package/dist/quantities/current/current.dto.js +60 -0
- package/dist/quantities/current/current.dto.js.map +1 -0
- package/dist/quantities/current/current.js +39 -0
- package/dist/quantities/current/current.js.map +1 -0
- package/dist/quantities/current/index.d.ts +4 -0
- package/dist/quantities/current/index.js +5 -0
- package/dist/quantities/current/index.js.map +1 -0
- package/dist/quantities/current/tests/current.unit.test.d.ts +1 -0
- package/dist/quantities/current/tests/current.unit.test.js +31 -0
- package/dist/quantities/current/tests/current.unit.test.js.map +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAA;AAC9C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,mCAAmC,CAAA;AACjD,cAAc,8BAA8B,CAAA;AAC5C,cAAc,6BAA6B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAA;AAC7C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,mCAAmC,CAAA;AACjD,cAAc,8BAA8B,CAAA;AAC5C,cAAc,6BAA6B,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ApiPropertyOptions } from '@nestjs/swagger';
|
|
2
|
+
export declare enum CurrentUnitEnum {
|
|
3
|
+
AMPERE = "A",
|
|
4
|
+
DECIAMPERE = "dA",
|
|
5
|
+
CENTIAMPERE = "cA",
|
|
6
|
+
MILLIAMPERE = "mA",
|
|
7
|
+
MICROAMPERE = "\u03BCA",
|
|
8
|
+
NANOAMPERE = "nA",
|
|
9
|
+
PICOAMPERE = "pA",
|
|
10
|
+
FEMTOAMPERE = "fA",
|
|
11
|
+
ATTOAMPERE = "aA",
|
|
12
|
+
ZEPTOAMPERE = "zA",
|
|
13
|
+
YOCTOAMPERE = "yA",
|
|
14
|
+
RONTOAMPERE = "rA",
|
|
15
|
+
QUECTOAMPERE = "qA",
|
|
16
|
+
DECAAMPERE = "daA",
|
|
17
|
+
HECTOAMPERE = "hA",
|
|
18
|
+
KILOAMPERE = "kA",
|
|
19
|
+
MEGAAMPERE = "MA",
|
|
20
|
+
GIGAAMPERE = "GA",
|
|
21
|
+
TERAAMPERE = "TA",
|
|
22
|
+
PETAAMPERE = "PA",
|
|
23
|
+
EXAAMPERE = "EA",
|
|
24
|
+
ZETTAAMPERE = "ZA",
|
|
25
|
+
YOTTAAMPERE = "YA",
|
|
26
|
+
RONNAAMPERE = "RA",
|
|
27
|
+
QUETTAAMPERE = "QA"
|
|
28
|
+
}
|
|
29
|
+
export declare function CurrentUnitApiProperty(options?: ApiPropertyOptions): PropertyDecorator;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
2
|
+
export var CurrentUnitEnum;
|
|
3
|
+
(function (CurrentUnitEnum) {
|
|
4
|
+
CurrentUnitEnum["AMPERE"] = "A";
|
|
5
|
+
CurrentUnitEnum["DECIAMPERE"] = "dA";
|
|
6
|
+
CurrentUnitEnum["CENTIAMPERE"] = "cA";
|
|
7
|
+
CurrentUnitEnum["MILLIAMPERE"] = "mA";
|
|
8
|
+
CurrentUnitEnum["MICROAMPERE"] = "\u03BCA";
|
|
9
|
+
CurrentUnitEnum["NANOAMPERE"] = "nA";
|
|
10
|
+
CurrentUnitEnum["PICOAMPERE"] = "pA";
|
|
11
|
+
CurrentUnitEnum["FEMTOAMPERE"] = "fA";
|
|
12
|
+
CurrentUnitEnum["ATTOAMPERE"] = "aA";
|
|
13
|
+
CurrentUnitEnum["ZEPTOAMPERE"] = "zA";
|
|
14
|
+
CurrentUnitEnum["YOCTOAMPERE"] = "yA";
|
|
15
|
+
CurrentUnitEnum["RONTOAMPERE"] = "rA";
|
|
16
|
+
CurrentUnitEnum["QUECTOAMPERE"] = "qA";
|
|
17
|
+
CurrentUnitEnum["DECAAMPERE"] = "daA";
|
|
18
|
+
CurrentUnitEnum["HECTOAMPERE"] = "hA";
|
|
19
|
+
CurrentUnitEnum["KILOAMPERE"] = "kA";
|
|
20
|
+
CurrentUnitEnum["MEGAAMPERE"] = "MA";
|
|
21
|
+
CurrentUnitEnum["GIGAAMPERE"] = "GA";
|
|
22
|
+
CurrentUnitEnum["TERAAMPERE"] = "TA";
|
|
23
|
+
CurrentUnitEnum["PETAAMPERE"] = "PA";
|
|
24
|
+
CurrentUnitEnum["EXAAMPERE"] = "EA";
|
|
25
|
+
CurrentUnitEnum["ZETTAAMPERE"] = "ZA";
|
|
26
|
+
CurrentUnitEnum["YOTTAAMPERE"] = "YA";
|
|
27
|
+
CurrentUnitEnum["RONNAAMPERE"] = "RA";
|
|
28
|
+
CurrentUnitEnum["QUETTAAMPERE"] = "QA";
|
|
29
|
+
})(CurrentUnitEnum || (CurrentUnitEnum = {}));
|
|
30
|
+
export function CurrentUnitApiProperty(options) {
|
|
31
|
+
return ApiProperty({
|
|
32
|
+
...options,
|
|
33
|
+
enum: CurrentUnitEnum,
|
|
34
|
+
enumName: 'CurrentUnitEnum',
|
|
35
|
+
example: CurrentUnitEnum.AMPERE
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=current-unit.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"current-unit.enum.js","sourceRoot":"","sources":["../../../lib/quantities/current/current-unit.enum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAEjE,MAAM,CAAN,IAAY,eA4BX;AA5BD,WAAY,eAAe;IACzB,+BAAY,CAAA;IAEZ,oCAAiB,CAAA;IACjB,qCAAkB,CAAA;IAClB,qCAAkB,CAAA;IAClB,0CAAkB,CAAA;IAClB,oCAAiB,CAAA;IACjB,oCAAiB,CAAA;IACjB,qCAAkB,CAAA;IAClB,oCAAiB,CAAA;IACjB,qCAAkB,CAAA;IAClB,qCAAkB,CAAA;IAClB,qCAAkB,CAAA;IAClB,sCAAmB,CAAA;IAEnB,qCAAkB,CAAA;IAClB,qCAAkB,CAAA;IAClB,oCAAiB,CAAA;IACjB,oCAAiB,CAAA;IACjB,oCAAiB,CAAA;IACjB,oCAAiB,CAAA;IACjB,oCAAiB,CAAA;IACjB,mCAAgB,CAAA;IAChB,qCAAkB,CAAA;IAClB,qCAAkB,CAAA;IAClB,qCAAkB,CAAA;IAClB,sCAAmB,CAAA;AACrB,CAAC,EA5BW,eAAe,KAAf,eAAe,QA4B1B;AAED,MAAM,UAAU,sBAAsB,CAAE,OAA4B;IAClE,OAAO,WAAW,CAAC;QACjB,GAAG,OAAO;QACV,IAAI,EAAE,eAAe;QACrB,QAAQ,EAAE,iBAAiB;QAC3B,OAAO,EAAE,eAAe,CAAC,MAAM;KAChC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"current.column.js","sourceRoot":"","sources":["../../../lib/quantities/current/current.column.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAEzD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,MAAM,UAAU,aAAa,CAAE,WAA4B,EAAE,OAAoD;IAC/G,OAAO,cAAc,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,CAAA;AACtD,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Quantity } from '../../quantity.js';
|
|
2
|
+
import { CurrentUnitEnum } from './current-unit.enum.js';
|
|
3
|
+
export declare const CURRENT_MULTIPLIERS: Record<CurrentUnitEnum, number>;
|
|
4
|
+
export declare class Current extends Quantity<CurrentUnitEnum, Current> {
|
|
5
|
+
protected baseUnit: CurrentUnitEnum;
|
|
6
|
+
protected convertValueToBaseUnit(value: number, unit: CurrentUnitEnum): number;
|
|
7
|
+
protected convertBaseUnitValueTo(value: number, unit: CurrentUnitEnum): number;
|
|
8
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CurrentUnitEnum } from './current-unit.enum.js';
|
|
2
|
+
import { Current } from './current.js';
|
|
3
|
+
export declare class CurrentDto {
|
|
4
|
+
value: number;
|
|
5
|
+
unit: CurrentUnitEnum;
|
|
6
|
+
static from(current: undefined): undefined;
|
|
7
|
+
static from(current: null): null;
|
|
8
|
+
static from(current: Current): CurrentDto;
|
|
9
|
+
static from(current: Current | null): CurrentDto | null;
|
|
10
|
+
static from(current: Current | undefined): CurrentDto | undefined;
|
|
11
|
+
static from(current: Current | null | undefined): CurrentDto | null | undefined;
|
|
12
|
+
parse(): Current;
|
|
13
|
+
}
|
|
14
|
+
export declare class CurrentDtoBuilder {
|
|
15
|
+
private readonly dto;
|
|
16
|
+
constructor();
|
|
17
|
+
withValue(value: number): this;
|
|
18
|
+
withUnit(unit: CurrentUnitEnum): this;
|
|
19
|
+
build(): CurrentDto;
|
|
20
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
11
|
+
import { IsNumber, IsEnum } from 'class-validator';
|
|
12
|
+
import { CurrentUnitApiProperty, CurrentUnitEnum } from './current-unit.enum.js';
|
|
13
|
+
import { Current } from './current.js';
|
|
14
|
+
export class CurrentDto {
|
|
15
|
+
value;
|
|
16
|
+
unit;
|
|
17
|
+
static from(current) {
|
|
18
|
+
if (current === null)
|
|
19
|
+
return null;
|
|
20
|
+
if (current === undefined)
|
|
21
|
+
return undefined;
|
|
22
|
+
return new CurrentDtoBuilder()
|
|
23
|
+
.withValue(current.value)
|
|
24
|
+
.withUnit(current.unit)
|
|
25
|
+
.build();
|
|
26
|
+
}
|
|
27
|
+
parse() {
|
|
28
|
+
return new Current(this.value, this.unit);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
__decorate([
|
|
32
|
+
ApiProperty({ type: Number }),
|
|
33
|
+
IsNumber(),
|
|
34
|
+
__metadata("design:type", Number)
|
|
35
|
+
], CurrentDto.prototype, "value", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
CurrentUnitApiProperty(),
|
|
38
|
+
IsEnum(CurrentUnitEnum),
|
|
39
|
+
__metadata("design:type", String)
|
|
40
|
+
], CurrentDto.prototype, "unit", void 0);
|
|
41
|
+
export class CurrentDtoBuilder {
|
|
42
|
+
dto;
|
|
43
|
+
constructor() {
|
|
44
|
+
this.dto = new CurrentDto();
|
|
45
|
+
this.dto.value = 0;
|
|
46
|
+
this.dto.unit = CurrentUnitEnum.AMPERE;
|
|
47
|
+
}
|
|
48
|
+
withValue(value) {
|
|
49
|
+
this.dto.value = value;
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
withUnit(unit) {
|
|
53
|
+
this.dto.unit = unit;
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
build() {
|
|
57
|
+
return this.dto;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=current.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"current.dto.js","sourceRoot":"","sources":["../../../lib/quantities/current/current.dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,MAAM,OAAO,UAAU;IAGrB,KAAK,CAAQ;IAIb,IAAI,CAAiB;IASrB,MAAM,CAAC,IAAI,CAAE,OAAmC;QAC9C,IAAI,OAAO,KAAK,IAAI;YAAE,OAAO,IAAI,CAAA;QACjC,IAAI,OAAO,KAAK,SAAS;YAAE,OAAO,SAAS,CAAA;QAE3C,OAAO,IAAI,iBAAiB,EAAE;aAC3B,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC;aACxB,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC;aACtB,KAAK,EAAE,CAAA;IACZ,CAAC;IAED,KAAK;QACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;IAC3C,CAAC;CACF;AA1BC;IAFC,WAAW,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC7B,QAAQ,EAAE;;yCACE;AAIb;IAFC,sBAAsB,EAAE;IACxB,MAAM,CAAC,eAAe,CAAC;;wCACH;AAwBvB,MAAM,OAAO,iBAAiB;IACX,GAAG,CAAY;IAEhC;QACE,IAAI,CAAC,GAAG,GAAG,IAAI,UAAU,EAAE,CAAA;QAC3B,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAA;QAClB,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,eAAe,CAAC,MAAM,CAAA;IACxC,CAAC;IAED,SAAS,CAAE,KAAa;QACtB,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,KAAK,CAAA;QAEtB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,QAAQ,CAAE,IAAqB;QAC7B,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAA;QAEpB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,KAAK;QACH,OAAO,IAAI,CAAC,GAAG,CAAA;IACjB,CAAC;CACF"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Quantity } from '../../quantity.js';
|
|
2
|
+
import { CurrentUnitEnum } from './current-unit.enum.js';
|
|
3
|
+
export const CURRENT_MULTIPLIERS = {
|
|
4
|
+
[CurrentUnitEnum.AMPERE]: 1,
|
|
5
|
+
[CurrentUnitEnum.DECIAMPERE]: 1e-1,
|
|
6
|
+
[CurrentUnitEnum.CENTIAMPERE]: 1e-2,
|
|
7
|
+
[CurrentUnitEnum.MILLIAMPERE]: 1e-3,
|
|
8
|
+
[CurrentUnitEnum.MICROAMPERE]: 1e-6,
|
|
9
|
+
[CurrentUnitEnum.NANOAMPERE]: 1e-9,
|
|
10
|
+
[CurrentUnitEnum.PICOAMPERE]: 1e-12,
|
|
11
|
+
[CurrentUnitEnum.FEMTOAMPERE]: 1e-15,
|
|
12
|
+
[CurrentUnitEnum.ATTOAMPERE]: 1e-18,
|
|
13
|
+
[CurrentUnitEnum.ZEPTOAMPERE]: 1e-21,
|
|
14
|
+
[CurrentUnitEnum.YOCTOAMPERE]: 1e-24,
|
|
15
|
+
[CurrentUnitEnum.RONTOAMPERE]: 1e-27,
|
|
16
|
+
[CurrentUnitEnum.QUECTOAMPERE]: 1e-30,
|
|
17
|
+
[CurrentUnitEnum.DECAAMPERE]: 1e1,
|
|
18
|
+
[CurrentUnitEnum.HECTOAMPERE]: 1e2,
|
|
19
|
+
[CurrentUnitEnum.KILOAMPERE]: 1e3,
|
|
20
|
+
[CurrentUnitEnum.MEGAAMPERE]: 1e6,
|
|
21
|
+
[CurrentUnitEnum.GIGAAMPERE]: 1e9,
|
|
22
|
+
[CurrentUnitEnum.TERAAMPERE]: 1e12,
|
|
23
|
+
[CurrentUnitEnum.PETAAMPERE]: 1e15,
|
|
24
|
+
[CurrentUnitEnum.EXAAMPERE]: 1e18,
|
|
25
|
+
[CurrentUnitEnum.ZETTAAMPERE]: 1e21,
|
|
26
|
+
[CurrentUnitEnum.YOTTAAMPERE]: 1e24,
|
|
27
|
+
[CurrentUnitEnum.RONNAAMPERE]: 1e27,
|
|
28
|
+
[CurrentUnitEnum.QUETTAAMPERE]: 1e30
|
|
29
|
+
};
|
|
30
|
+
export class Current extends Quantity {
|
|
31
|
+
baseUnit = CurrentUnitEnum.AMPERE;
|
|
32
|
+
convertValueToBaseUnit(value, unit) {
|
|
33
|
+
return value * CURRENT_MULTIPLIERS[unit];
|
|
34
|
+
}
|
|
35
|
+
convertBaseUnitValueTo(value, unit) {
|
|
36
|
+
return value / CURRENT_MULTIPLIERS[unit];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=current.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"current.js","sourceRoot":"","sources":["../../../lib/quantities/current/current.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO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AI;IACnC,CAAC,eAAe,CAAC,YAAY,CAAC,EAAE,IAAI;CACrC,CAAA;AAED,MAAM,OAAO,OAAQ,SAAQ,QAAkC;IACnD,QAAQ,GAAG,eAAe,CAAC,MAAM,CAAA;IAEjC,sBAAsB,CAAE,KAAa,EAAE,IAAqB;QACpE,OAAO,KAAK,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAA;IAC1C,CAAC;IAES,sBAAsB,CAAE,KAAa,EAAE,IAAqB;QACpE,OAAO,KAAK,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAA;IAC1C,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/quantities/current/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,wBAAwB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
2
|
+
import { expect } from 'expect';
|
|
3
|
+
import { Current } from '../current.js';
|
|
4
|
+
import { CurrentUnitEnum } from '../current-unit.enum.js';
|
|
5
|
+
void describe('Current class', () => {
|
|
6
|
+
void describe('Current calculations', () => {
|
|
7
|
+
void it('adds currents', () => {
|
|
8
|
+
const c1 = new Current(10, CurrentUnitEnum.AMPERE);
|
|
9
|
+
const c2 = new Current(500, CurrentUnitEnum.MILLIAMPERE);
|
|
10
|
+
const r = c1.add(c2);
|
|
11
|
+
expect(r.isEqualTo(10.5, CurrentUnitEnum.AMPERE)).toBe(true);
|
|
12
|
+
});
|
|
13
|
+
void it('subtracts currents', () => {
|
|
14
|
+
const c1 = new Current(10, CurrentUnitEnum.AMPERE);
|
|
15
|
+
const c2 = new Current(500, CurrentUnitEnum.MILLIAMPERE);
|
|
16
|
+
const r = c1.subtract(c2);
|
|
17
|
+
expect(r.isEqualTo(9500, CurrentUnitEnum.MILLIAMPERE)).toBe(true);
|
|
18
|
+
});
|
|
19
|
+
void it('divides currents', () => {
|
|
20
|
+
const c1 = new Current(1, CurrentUnitEnum.AMPERE);
|
|
21
|
+
const c2 = new Current(250, CurrentUnitEnum.MILLIAMPERE);
|
|
22
|
+
const r1 = c1.divide(2);
|
|
23
|
+
const r2 = c1.divide(c2);
|
|
24
|
+
const r3 = c1.divide(0.5, CurrentUnitEnum.AMPERE);
|
|
25
|
+
expect(r1.isEqualTo(500, CurrentUnitEnum.MILLIAMPERE)).toBe(true);
|
|
26
|
+
expect(r2).toBe(4);
|
|
27
|
+
expect(r3).toBe(2);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=current.unit.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"current.unit.test.js","sourceRoot":"","sources":["../../../../lib/quantities/current/tests/current.unit.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAEzD,KAAK,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAClC,KAAK,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;QACzC,KAAK,EAAE,CAAC,eAAe,EAAE,GAAG,EAAE;YAC5B,MAAM,EAAE,GAAG,IAAI,OAAO,CAAC,EAAE,EAAE,eAAe,CAAC,MAAM,CAAC,CAAA;YAClD,MAAM,EAAE,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,eAAe,CAAC,WAAW,CAAC,CAAA;YACxD,MAAM,CAAC,GAAY,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;YAE7B,MAAM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