@bitbybit-dev/base 0.19.8 → 0.20.0
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/babel.config.cjs +1 -0
- package/babel.config.d.cts +5 -0
- package/index.d.ts +1 -0
- package/{index.ts → index.js} +1 -2
- package/lib/api/index.js +1 -0
- package/lib/api/inputs/base-inputs.d.ts +35 -0
- package/lib/api/inputs/base-inputs.js +1 -0
- package/lib/api/inputs/{color-inputs.ts → color-inputs.d.ts} +26 -48
- package/lib/api/inputs/color-inputs.js +164 -0
- package/lib/api/inputs/dates-inputs.d.ts +216 -0
- package/lib/api/inputs/dates-inputs.js +271 -0
- package/lib/api/inputs/{index.ts → index.d.ts} +1 -0
- package/lib/api/inputs/index.js +10 -0
- package/lib/api/inputs/{inputs.ts → inputs.d.ts} +1 -0
- package/lib/api/inputs/inputs.js +10 -0
- package/lib/api/inputs/{lists-inputs.ts → lists-inputs.d.ts} +91 -190
- package/lib/api/inputs/lists-inputs.js +576 -0
- package/lib/api/inputs/{logic-inputs.ts → logic-inputs.d.ts} +24 -46
- package/lib/api/inputs/logic-inputs.js +111 -0
- package/lib/api/inputs/{math-inputs.ts → math-inputs.d.ts} +53 -97
- package/lib/api/inputs/math-inputs.js +391 -0
- package/lib/api/inputs/{point-inputs.ts → point-inputs.d.ts} +77 -168
- package/lib/api/inputs/point-inputs.js +521 -0
- package/lib/api/inputs/text-inputs.d.ts +83 -0
- package/lib/api/inputs/text-inputs.js +120 -0
- package/lib/api/inputs/{transforms-inputs.ts → transforms-inputs.d.ts} +35 -64
- package/lib/api/inputs/transforms-inputs.js +200 -0
- package/lib/api/inputs/{vector-inputs.ts → vector-inputs.d.ts} +48 -104
- package/lib/api/inputs/vector-inputs.js +304 -0
- package/lib/api/services/color.d.ts +114 -0
- package/lib/api/services/{color.ts → color.js} +15 -34
- package/lib/api/services/dates.d.ts +367 -0
- package/lib/api/services/dates.js +450 -0
- package/lib/api/services/geometry-helper.d.ts +15 -0
- package/lib/api/services/{geometry-helper.ts → geometry-helper.js} +31 -43
- package/lib/api/services/{index.ts → index.d.ts} +2 -1
- package/lib/api/services/index.js +10 -0
- package/lib/api/services/lists.d.ts +287 -0
- package/lib/api/services/{lists.ts → lists.js} +59 -83
- package/lib/api/services/logic.d.ts +99 -0
- package/lib/api/services/{logic.ts → logic.js} +24 -32
- package/lib/api/services/math.d.ts +349 -0
- package/lib/api/services/{math.ts → math.js} +71 -136
- package/lib/api/services/point.d.ts +222 -0
- package/lib/api/services/{point.ts → point.js} +32 -67
- package/lib/api/services/text.d.ts +69 -0
- package/lib/api/services/{text.ts → text.js} +7 -17
- package/lib/api/services/transforms.d.ts +122 -0
- package/lib/api/services/{transforms.ts → transforms.js} +37 -83
- package/lib/api/services/vector.d.ts +320 -0
- package/lib/api/services/{vector.ts → vector.js} +42 -80
- package/lib/{index.ts → index.d.ts} +0 -1
- package/lib/index.js +1 -0
- package/package.json +1 -1
- package/lib/api/inputs/base-inputs.ts +0 -18
- package/lib/api/inputs/text-inputs.ts +0 -108
- package/lib/api/services/color.test.ts +0 -86
- package/lib/api/services/lists.test.ts +0 -612
- package/lib/api/services/logic.test.ts +0 -187
- package/lib/api/services/math.test.ts +0 -622
- package/lib/api/services/text.test.ts +0 -55
- package/lib/api/services/vector.test.ts +0 -360
- package/tsconfig.bitbybit.json +0 -26
- package/tsconfig.json +0 -24
- /package/lib/api/{index.ts → index.d.ts} +0 -0
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { Color } from "./color";
|
|
2
|
-
import { MathBitByBit } from "./math";
|
|
3
|
-
|
|
4
|
-
describe("Color unit tests", () => {
|
|
5
|
-
let color: Color;
|
|
6
|
-
|
|
7
|
-
beforeAll(async () => {
|
|
8
|
-
const math = new MathBitByBit();
|
|
9
|
-
color = new Color(math);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it("should create hex color", () => {
|
|
13
|
-
const res = color.hexColor({ color: "#ff0000" });
|
|
14
|
-
expect(res).toEqual("#ff0000");
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it("should convert hex to rgb", () => {
|
|
18
|
-
const res = color.hexToRgb({ color: "#ff0000" });
|
|
19
|
-
expect(res).toEqual({ r: 255, g: 0, b: 0 });
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("should convert hex to rgb mapped", () => {
|
|
23
|
-
const res = color.hexToRgbMapped({ color: "#ff0000", from: 0, to: 1 });
|
|
24
|
-
expect(res).toEqual({ r: 1, g: 0, b: 0 });
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("should get red param", () => {
|
|
28
|
-
const res = color.getRedParam({ color: "#ff0000", from: 0, to: 1 });
|
|
29
|
-
expect(res).toEqual(1);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it("should get green param", () => {
|
|
33
|
-
const res = color.getGreenParam({ color: "#00ff00", from: 0, to: 1 });
|
|
34
|
-
expect(res).toEqual(1);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("should get blue param", () => {
|
|
38
|
-
const res = color.getBlueParam({ color: "#0000ff", from: 0, to: 1 });
|
|
39
|
-
expect(res).toEqual(1);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("should convert rgb to hex", () => {
|
|
43
|
-
const res = color.rgbToHex({ r: 255, g: 150, b: 23, min: 0, max: 255 });
|
|
44
|
-
expect(res).toEqual("#ff9617");
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("should convert rgb to hex", () => {
|
|
48
|
-
const res = color.rgbToHex({ r: 1, g: 0.3, b: 0.6, min: 0, max: 1 });
|
|
49
|
-
expect(res).toEqual("#ff4d99");
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("should convert rgb obj to hex", () => {
|
|
53
|
-
const res = color.rgbObjToHex({ rgb: { r: 1, g: 0.3, b: 0.6 }, min: 0, max: 1 });
|
|
54
|
-
expect(res).toEqual("#ff4d99");
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it("should get R from rgb obj", () => {
|
|
58
|
-
const res = color.rgbToRed({ rgb: { r: 1, g: 0.3, b: 0.6 } });
|
|
59
|
-
expect(res).toEqual(1);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it("should get G from rgb obj", () => {
|
|
63
|
-
const res = color.rgbToGreen({ rgb: { r: 1, g: 0.3, b: 0.6 } });
|
|
64
|
-
expect(res).toEqual(0.3);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("should get B from rgb obj", () => {
|
|
68
|
-
const res = color.rgbToBlue({ rgb: { r: 1, g: 0.3, b: 0.6 } });
|
|
69
|
-
expect(res).toEqual(0.6);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it("should invert colors", () => {
|
|
73
|
-
const res = color.invert({ color: "#ff4d99", blackAndWhite: false });
|
|
74
|
-
expect(res).toEqual("#00b266");
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it("should invert colors to black and white", () => {
|
|
78
|
-
const res = color.invert({ color: "#ff4d99", blackAndWhite: true });
|
|
79
|
-
expect(res).toEqual("#ffffff");
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it("should invert colors to black and white", () => {
|
|
83
|
-
const res = color.invert({ color: "#ffeeaa", blackAndWhite: true });
|
|
84
|
-
expect(res).toEqual("#000000");
|
|
85
|
-
});
|
|
86
|
-
});
|