jimp 0.17.9 → 0.17.10

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/types/test.ts CHANGED
@@ -3,10 +3,15 @@ import * as Jimp from "jimp";
3
3
  const jimpInst: Jimp = new Jimp("test");
4
4
 
5
5
  // Main Jimp export should already have all of these already applied
6
+ // $ExpectError
6
7
  jimpInst.read("Test");
7
8
  jimpInst.displace(jimpInst, 2);
8
9
  jimpInst.resize(40, 40);
9
- // $ExpectType 0
10
+ jimpInst.displace(jimpInst, 2);
11
+ jimpInst.shadow((err, val, coords) => {});
12
+ jimpInst.fishEye({ r: 12 });
13
+ jimpInst.circle({ radius: 12, x: 12, y: 12 });
14
+ // $ExpectError
10
15
  jimpInst.PNG_FILTER_NONE;
11
16
 
12
17
  // $ExpectError
@@ -17,9 +22,7 @@ jimpInst.func();
17
22
 
18
23
  // Main Jimp export should already have all of these already applied
19
24
  Jimp.read("Test");
20
- Jimp.displace(Jimp, 2);
21
- Jimp.shadow((err, val, coords) => {});
22
- Jimp.resize(40, 40);
25
+
23
26
  // $ExpectType 0
24
27
  Jimp.PNG_FILTER_NONE;
25
28
 
@@ -33,12 +36,12 @@ test("can clone properly", async () => {
33
36
  const baseImage = await Jimp.read("filename");
34
37
  const cloneBaseImage = baseImage.clone();
35
38
 
36
- // $ExpectType -1
37
- cloneBaseImage.PNG_FILTER_AUTO;
39
+ // $ExpectType number
40
+ cloneBaseImage._deflateLevel;
38
41
 
39
42
  test("can handle `this` returns on the core type properly", () => {
40
- // $ExpectType -1
41
- cloneBaseImage.diff(jimpInst, jimpInst).image.PNG_FILTER_AUTO;
43
+ // $ExpectType number
44
+ cloneBaseImage.posterize(3)._quality;
42
45
  });
43
46
 
44
47
  test("can handle `this` returns properly", () => {
@@ -49,16 +52,17 @@ test("can clone properly", async () => {
49
52
  .print("a" as any, 2, 2, "a" as any)
50
53
  .resize(1, 1)
51
54
  .quality(1)
52
- .deflateLevel(2).PNG_FILTER_AUTO;
55
+ .deflateLevel(2)._filterType;
53
56
  });
54
57
 
55
58
  test("can handle imageCallbacks `this` properly", () => {
56
59
  cloneBaseImage.rgba(false, (_, jimpCBIn) => {
60
+ // $ExpectError
57
61
  jimpCBIn.read("Test");
58
62
  jimpCBIn.displace(jimpInst, 2);
59
63
  jimpCBIn.resize(40, 40);
60
- // $ExpectType 0
61
- jimpCBIn.PNG_FILTER_NONE;
64
+ // $ExpectType number
65
+ jimpCBIn._filterType;
62
66
 
63
67
  // $ExpectError
64
68
  jimpCBIn.test;
@@ -73,11 +77,12 @@ test("Can handle callback with constructor", () => {
73
77
  const myBmpBuffer: Buffer = {} as any;
74
78
 
75
79
  Jimp.read(myBmpBuffer, (err, cbJimpInst) => {
80
+ // $ExpectError
76
81
  cbJimpInst.read("Test");
77
82
  cbJimpInst.displace(jimpInst, 2);
78
83
  cbJimpInst.resize(40, 40);
79
- // $ExpectType 0
80
- cbJimpInst.PNG_FILTER_NONE;
84
+ // $ExpectType number
85
+ cbJimpInst._filterType;
81
86
 
82
87
  // $ExpectError
83
88
  cbJimpInst.test;
@@ -86,16 +91,3 @@ test("Can handle callback with constructor", () => {
86
91
  cbJimpInst.func();
87
92
  });
88
93
  });
89
-
90
- test("Can handle appendConstructorOption", () => {
91
- Jimp.appendConstructorOption(
92
- "Name of Option",
93
- (args) => args.hasSomeCustomThing,
94
- function (resolve, reject, args) {
95
- // $ExpectError
96
- this.bitmap = 3;
97
- Jimp.resize(2, 2);
98
- resolve();
99
- }
100
- );
101
- });
@@ -1,51 +0,0 @@
1
- /**
2
- * While there is nothing in these typings that prevent it from running in TS 2.8 even,
3
- * due to the complexity of the typings anything lower than TS 3.1 will only see
4
- * Jimp as `any`. In order to test the strict versions of these types in our typing
5
- * test suite, the version has been bumped to 3.1
6
- */
7
-
8
- import {
9
- Jimp as JimpType,
10
- Bitmap,
11
- RGB,
12
- RGBA,
13
- UnionToIntersection,
14
- GetPluginVal,
15
- GetPluginConst,
16
- GetPluginEncoders,
17
- GetPluginDecoders,
18
- JimpConstructors,
19
- } from "@jimp/core";
20
- import typeFn from "@jimp/types";
21
- import pluginFn from "@jimp/plugins";
22
-
23
- type Types = ReturnType<typeof typeFn>;
24
- type Plugins = ReturnType<typeof pluginFn>;
25
-
26
- type IntersectedPluginTypes = UnionToIntersection<
27
- GetPluginVal<Types> | GetPluginVal<Plugins>
28
- >;
29
-
30
- type IntersectedPluginConsts = UnionToIntersection<
31
- GetPluginConst<Types> | GetPluginConst<Plugins>
32
- >;
33
-
34
- type IntersectedPluginEncoders = UnionToIntersection<
35
- GetPluginEncoders<Types> | GetPluginEncoders<Plugins>
36
- >;
37
-
38
- type IntersectedPluginDecoders = UnionToIntersection<
39
- GetPluginDecoders<Types> | GetPluginDecoders<Plugins>
40
- >;
41
-
42
- type Jimp = JimpType & IntersectedPluginTypes;
43
-
44
- declare const Jimp: JimpConstructors &
45
- IntersectedPluginConsts & {
46
- prototype: Jimp;
47
- encoders: IntersectedPluginEncoders;
48
- decoders: IntersectedPluginDecoders;
49
- };
50
-
51
- export = Jimp;
@@ -1,93 +0,0 @@
1
- import * as Jimp from "jimp";
2
-
3
- const jimpInst: Jimp = new Jimp("test");
4
-
5
- // Main Jimp export should already have all of these already applied
6
- // $ExpectError
7
- jimpInst.read("Test");
8
- jimpInst.displace(jimpInst, 2);
9
- jimpInst.resize(40, 40);
10
- jimpInst.displace(jimpInst, 2);
11
- jimpInst.shadow((err, val, coords) => {});
12
- jimpInst.fishEye({ r: 12 });
13
- jimpInst.circle({ radius: 12, x: 12, y: 12 });
14
- // $ExpectError
15
- jimpInst.PNG_FILTER_NONE;
16
-
17
- // $ExpectError
18
- jimpInst.test;
19
-
20
- // $ExpectError
21
- jimpInst.func();
22
-
23
- // Main Jimp export should already have all of these already applied
24
- Jimp.read("Test");
25
-
26
- // $ExpectType 0
27
- Jimp.PNG_FILTER_NONE;
28
-
29
- // $ExpectError
30
- Jimp.test;
31
-
32
- // $ExpectError
33
- Jimp.func();
34
-
35
- test("can clone properly", async () => {
36
- const baseImage = await Jimp.read("filename");
37
- const cloneBaseImage = baseImage.clone();
38
-
39
- // $ExpectType number
40
- cloneBaseImage._deflateLevel;
41
-
42
- test("can handle `this` returns on the core type properly", () => {
43
- // $ExpectType number
44
- cloneBaseImage.posterize(3)._quality;
45
- });
46
-
47
- test("can handle `this` returns properly", () => {
48
- cloneBaseImage
49
- .resize(1, 1)
50
- .crop(0, 0, 0, 0)
51
- .mask(cloneBaseImage, 2, 2)
52
- .print("a" as any, 2, 2, "a" as any)
53
- .resize(1, 1)
54
- .quality(1)
55
- .deflateLevel(2)._filterType;
56
- });
57
-
58
- test("can handle imageCallbacks `this` properly", () => {
59
- cloneBaseImage.rgba(false, (_, jimpCBIn) => {
60
- // $ExpectError
61
- jimpCBIn.read("Test");
62
- jimpCBIn.displace(jimpInst, 2);
63
- jimpCBIn.resize(40, 40);
64
- // $ExpectType number
65
- jimpCBIn._filterType;
66
-
67
- // $ExpectError
68
- jimpCBIn.test;
69
-
70
- // $ExpectError
71
- jimpCBIn.func();
72
- });
73
- });
74
- });
75
-
76
- test("Can handle callback with constructor", () => {
77
- const myBmpBuffer: Buffer = {} as any;
78
-
79
- Jimp.read(myBmpBuffer, (err, cbJimpInst) => {
80
- // $ExpectError
81
- cbJimpInst.read("Test");
82
- cbJimpInst.displace(jimpInst, 2);
83
- cbJimpInst.resize(40, 40);
84
- // $ExpectType number
85
- cbJimpInst._filterType;
86
-
87
- // $ExpectError
88
- cbJimpInst.test;
89
-
90
- // $ExpectError
91
- cbJimpInst.func();
92
- });
93
- });
@@ -1,18 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "module": "commonjs",
4
- "lib": ["es6"],
5
- "noImplicitAny": true,
6
- "noImplicitThis": true,
7
- "strictNullChecks": true,
8
- "strictFunctionTypes": true,
9
- "noEmit": true,
10
-
11
- // If the library is an external module (uses `export`), this allows your test file to import "mylib" instead of "./index".
12
- // If the library is global (cannot be imported via `import` or `require`), leave this out.
13
- "baseUrl": "../test",
14
- "paths": {
15
- "mylib": ["."]
16
- }
17
- }
18
- }