Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jimp/custom

Package Overview
Dependencies
Maintainers
2
Versions
219
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jimp/custom - npm Package Compare versions

Comparing version 0.8.1-canary.786.217.0 to 0.8.1-canary.786.223.0

6

package.json
{
"name": "@jimp/custom",
"version": "0.8.1-canary.786.217.0",
"version": "0.8.1-canary.786.223.0",
"description": "Interface to customize jimp configuration",

@@ -20,3 +20,3 @@ "main": "dist/index.js",

"dependencies": {
"@jimp/core": "0.8.1-canary.786.217.0",
"@jimp/core": "0.8.1-canary.786.223.0",
"core-js": "^2.5.7"

@@ -27,3 +27,3 @@ },

},
"gitHead": "f9d0b4a1a3de789557a2fedd477fbdd2a81f12c5"
"gitHead": "62486b053cb9cc408422e1b131813927d87edbbe"
}

@@ -5,10 +5,35 @@ // TypeScript Version: 3.1

FunctionRet,
GetIntersectionAddons,
Jimp,
JimpPlugin,
JimpType
JimpType,
GetIntersectionFromPlugins
} from '@jimp/core';
export default function configure<
declare function configure<
PluginFuncArr extends FunctionRet<JimpPlugin>,
JimpInstance extends Jimp = Jimp
>(
configuration: {
plugins: PluginFuncArr;
},
jimpInstance?: JimpInstance
// Since JimpInstance is required, we want to use the default `Jimp` type
): Exclude<JimpInstance, undefined> &
GetIntersectionFromPlugins<PluginFuncArr>;
declare function configure<
TypesFuncArr extends FunctionRet<JimpType>,
JimpInstance extends Jimp = Jimp
>(
configuration: {
types: TypesFuncArr;
},
jimpInstance?: JimpInstance
// Since JimpInstance is required, we want to use the default `Jimp` type
): Exclude<JimpInstance, undefined> &
GetIntersectionFromPlugins<TypesFuncArr>;
declare function configure<
TypesFuncArr extends FunctionRet<JimpType>,
PluginFuncArr extends FunctionRet<JimpPlugin>,

@@ -24,2 +49,5 @@ JimpInstance extends Jimp = Jimp

): Exclude<JimpInstance, undefined> &
GetIntersectionAddons<TypesFuncArr, PluginFuncArr>;
GetIntersectionFromPlugins<TypesFuncArr> &
GetIntersectionFromPlugins<PluginFuncArr>;
export default configure;

@@ -7,2 +7,4 @@ import configure from '@jimp/custom';

import scale from '@jimp/plugin-scale';
import types from '@jimp/types';
import plugins from '@jimp/plugins';

@@ -16,3 +18,3 @@ // configure should return a valid Jimp type with addons

// Methods from types should be applied
CustomJimp.filterType(4);
CustomJimp.deflateLevel(4);
// Constants from types should be applied

@@ -40,40 +42,114 @@ // $ExpectType 0

// Can compose
const OtherCustomJimp = configure({
plugins: [scale]
}, CustomJimp);
test('can compose', () => {
const OtherCustomJimp = configure({
plugins: [scale]
}, CustomJimp);
// Methods from new plugins should be applied
OtherCustomJimp.scale(3);
// Methods from new plugins should be applied
OtherCustomJimp.scale(3);
// Methods from types should be applied
OtherCustomJimp.filterType(4);
// Constants from types should be applied
/**
* This is commented out as TS assigns the value of `any` due to the complexity of typing
*
* This may be fixed/improved in a future version of TS, but as-of 3.6 even this relatively
* trivial composing of `configure` will be typed as `any`
*
* Tests left for future-proofing all-the-same
*/
//// $ExpectType 0
OtherCustomJimp.PNG_FILTER_NONE;
// Methods from types should be applied
OtherCustomJimp.filterType(4);
// Constants from types should be applied
// $ExpectType 0
OtherCustomJimp.PNG_FILTER_NONE;
// Core functions should still work from Jimp
OtherCustomJimp.read('Test');
// Core functions should still work from Jimp
OtherCustomJimp.read('Test');
// Constants should be applied from ill-formed plugins
OtherCustomJimp.displace(OtherCustomJimp, 2);
// Constants should be applied from ill-formed plugins
OtherCustomJimp.displace(OtherCustomJimp, 2);
// Methods should be applied from well-formed plugins
OtherCustomJimp.resize(40, 40)
// Methods should be applied from well-formed plugins
OtherCustomJimp.resize(40, 40);
// Constants should be applied from well-formed plugins
OtherCustomJimp.RESIZE_NEAREST_NEIGHBOR
// Constants should be applied from well-formed plugins
OtherCustomJimp.RESIZE_NEAREST_NEIGHBOR;
// $ExpectError
OtherCustomJimp.test;
// $ExpectError
OtherCustomJimp.test;
// $ExpectError
OtherCustomJimp.func();
// $ExpectError
OtherCustomJimp.func();
});
test('can handle only plugins', () => {
const PluginsJimp = configure({
plugins: [plugins]
});
// Core functions should still work from Jimp
PluginsJimp.read('Test');
// Constants should be applied from ill-formed plugins
PluginsJimp.displace(PluginsJimp, 2);
// Methods should be applied from well-formed plugins
PluginsJimp.resize(40, 40);
// Constants should be applied from well-formed plugins
// $ExpectType "nearestNeighbor"
PluginsJimp.RESIZE_NEAREST_NEIGHBOR;
// $ExpectError
PluginsJimp.test;
// $ExpectError
PluginsJimp.func();
})
test('can handle only all types', () => {
const TypesJimp = configure({
types: [types]
});
// Methods from types should be applied
TypesJimp.filterType(4);
// Constants from types should be applied
// Commented for complexity errors
// $ExpectType 0
TypesJimp.PNG_FILTER_NONE;
// $ExpectError
TypesJimp.test;
// $ExpectError
TypesJimp.func();
});
test('can handle only one type', () => {
const PngJimp = configure({
types: [png]
});
// Constants from types should be applied
// Commented for complexity errors
// $ExpectType 0
PngJimp.PNG_FILTER_NONE;
// $ExpectError
PngJimp.test;
// $ExpectError
PngJimp.func();
});
test('can handle only one plugin', () => {
const PngJimp = configure({
plugins: [resize]
});
// Constants from types should be applied
// Commented for complexity errors
// $ExpectType "nearestNeighbor"
PngJimp.RESIZE_NEAREST_NEIGHBOR;
PngJimp.resize(2, 2);
// $ExpectError
PngJimp.test;
// $ExpectError
PngJimp.func();
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc