@pi-r/jimp 0.5.0 → 0.6.2

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.
Files changed (3) hide show
  1. package/README.md +2 -0
  2. package/index.js +11 -11
  3. package/package.json +3 -3
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  ### @pi-r/jimp
2
2
 
3
+ https://e-mc.readthedocs.io/en/latest/image/index.html
4
+
3
5
  ### LICENSE
4
6
 
5
7
  MIT
package/index.js CHANGED
@@ -73,9 +73,9 @@ function getMethodName(value) {
73
73
  }
74
74
  }
75
75
  }
76
- function performCommand(host, instance, localUri, command, outputType, finalAs, buffer, parent) {
76
+ async function performCommand(host, instance, localUri, command, outputType, finalAs, buffer, parent) {
77
77
  return jimp.read((buffer || localUri))
78
- .then(img => {
78
+ .then(async (img) => {
79
79
  return transformCommand(localUri, new JimpHandler(img, instance, host), command, outputType, finalAs, parent);
80
80
  });
81
81
  }
@@ -381,7 +381,7 @@ class JimpHandler {
381
381
  const settings = instance.settings;
382
382
  const webp = settings.webp || (settings.webp = {});
383
383
  const data = instance.qualityData;
384
- const replace = instance.getCommand().indexOf('@') !== -1;
384
+ const replace = instance.getCommand().includes('@');
385
385
  const filename = (0, util_1.renameExt)(output, 'webp', replace);
386
386
  const args = [(0, util_1.normalizePath)(output)];
387
387
  if (data) {
@@ -453,10 +453,10 @@ class JimpHandler {
453
453
  callback(null, output);
454
454
  }
455
455
  }
456
- getBuffer(tempFile, saveAs) {
456
+ async getBuffer(tempFile, saveAs) {
457
457
  const empty = () => tempFile ? '' : null;
458
458
  const output = getTempPath.call(this.instance, this.instance.outputAs || (saveAs && util_1.MIME_OUTPUT.has('image/' + (saveAs === 'jpg' ? 'jpeg' : saveAs)) ? saveAs : this.handler.getMIME().split('/').pop()));
459
- return !output ? Promise.resolve(empty()) : new Promise(resolve => {
459
+ return !output ? empty() : new Promise(resolve => {
460
460
  this.handler.write(output, error => {
461
461
  if (error) {
462
462
  resolve(empty());
@@ -526,12 +526,12 @@ class JimpHandler {
526
526
  }
527
527
  });
528
528
  }
529
- writeAsync(output, callback) {
529
+ async writeAsync(output, callback) {
530
530
  if (this.aborted) {
531
531
  if (callback) {
532
532
  callback((0, types_1.createAbortError)(), '');
533
533
  }
534
- return Promise.resolve();
534
+ return;
535
535
  }
536
536
  return this.handler.writeAsync(output)
537
537
  .then(() => this.finalize(output, callback))
@@ -608,7 +608,7 @@ class Jimp extends Image {
608
608
  [buffer, tempFile, ctimeMs] = getImageCache.call(instance, tempKey = file + command + (options.mimeType || ''));
609
609
  if (buffer) {
610
610
  writeMessage(false, ctimeMs);
611
- return Promise.resolve(buffer);
611
+ return buffer;
612
612
  }
613
613
  }
614
614
  instance.formatMessage(Image.LOG_TYPE.IMAGE, "jimp" /* STRINGS.MODULE_NAME */, ["Transforming image..." /* STRINGS.TRANSFORM */, filename], command);
@@ -657,7 +657,7 @@ class Jimp extends Image {
657
657
  reject((0, types_1.errorValue)("Invalid format" /* ERR_MESSAGE.FORMAT */, /^\w+/.exec(command)?.[0] || "Unknown" /* ERR_MESSAGE.UNKNOWN */));
658
658
  return;
659
659
  }
660
- const replace = command.indexOf('@') !== -1;
660
+ const replace = command.includes('@');
661
661
  const output = host.addCopy(data.getObject({ command, outputType }), saveAs, replace);
662
662
  if (!output) {
663
663
  reject((0, types_1.errorValue)("Not able to copy file" /* ERR_MESSAGE.NOT_COPYABLE */, outputType));
@@ -675,7 +675,7 @@ class Jimp extends Image {
675
675
  host.writeImage(document, data.getObject({ command, output: result }));
676
676
  }
677
677
  if (host.getLocalUri(data) !== result) {
678
- if (command.indexOf('%') !== -1) {
678
+ if (command.includes('%')) {
679
679
  const files = host.filesToCompare.get(file);
680
680
  if (files) {
681
681
  files.push(result);
@@ -850,7 +850,7 @@ class Jimp extends Image {
850
850
  GifUtil.read(file.buffer || localUri)
851
851
  .then(gif => {
852
852
  rotateAnim(cmd);
853
- Promise.all(gif.frames.map(frame => {
853
+ Promise.all(gif.frames.map(async (frame) => {
854
854
  const handler = new JimpHandler(GifUtil.shareAsJimp(jimp, frame), this);
855
855
  return transformCommand(localUri, handler, cmd, jimp.MIME_GIF);
856
856
  }))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/jimp",
3
- "version": "0.5.0",
3
+ "version": "0.6.2",
4
4
  "description": "Jimp image constructor for E-mc.",
5
5
  "main": "index.js",
6
6
  "publishConfig": {
@@ -20,8 +20,8 @@
20
20
  "license": "MIT",
21
21
  "homepage": "https://github.com/anpham6/pi-r#readme",
22
22
  "dependencies": {
23
- "@e-mc/image": "^0.7.0",
24
- "@e-mc/types": "^0.7.0",
23
+ "@e-mc/image": "^0.8.2",
24
+ "@e-mc/types": "^0.8.2",
25
25
  "bmp-js": "^0.1.0",
26
26
  "gifwrap": "^0.10.1",
27
27
  "jimp": "^0.22.10"