@jimp/plugin-threshold 0.16.3-canary.993.1592.0 → 0.16.3

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/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # v0.16.3 (Sat Feb 04 2023)
2
+
3
+ #### ⚠️ Pushed to `master`
4
+
5
+ - upgrade prettier ([@hipstersmoothie](https://github.com/hipstersmoothie))
6
+
7
+ #### Authors: 1
8
+
9
+ - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
10
+
11
+ ---
12
+
1
13
  # v0.11.0 (Fri May 15 2020)
2
14
 
3
15
  #### 🚀 Enhancement
@@ -24,7 +36,7 @@
24
36
 
25
37
  # v0.9.3 (Tue Nov 26 2019)
26
38
 
27
- #### 🐛 Bug Fix
39
+ #### 🐛 Bug Fix
28
40
 
29
41
  - `@jimp/cli`, `@jimp/core`, `@jimp/custom`, `jimp`, `@jimp/plugin-blit`, `@jimp/plugin-blur`, `@jimp/plugin-circle`, `@jimp/plugin-color`, `@jimp/plugin-contain`, `@jimp/plugin-cover`, `@jimp/plugin-crop`, `@jimp/plugin-displace`, `@jimp/plugin-dither`, `@jimp/plugin-fisheye`, `@jimp/plugin-flip`, `@jimp/plugin-gaussian`, `@jimp/plugin-invert`, `@jimp/plugin-mask`, `@jimp/plugin-normalize`, `@jimp/plugin-print`, `@jimp/plugin-resize`, `@jimp/plugin-rotate`, `@jimp/plugin-scale`, `@jimp/plugin-shadow`, `@jimp/plugin-threshold`, `@jimp/plugins`, `@jimp/test-utils`, `@jimp/bmp`, `@jimp/gif`, `@jimp/jpeg`, `@jimp/png`, `@jimp/tiff`, `@jimp/types`, `@jimp/utils`
30
42
  - Fix regeneratorRuntime errors [#815](https://github.com/oliver-moran/jimp/pull/815) ([@crutchcorn](https://github.com/crutchcorn) [@hipstersmoothie](https://github.com/hipstersmoothie))
@@ -32,4 +44,4 @@
32
44
  #### Authors: 2
33
45
 
34
46
  - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
35
- - Corbin Crutchley ([@crutchcorn](https://github.com/crutchcorn))
47
+ - Corbin Crutchley ([@crutchcorn](https://github.com/crutchcorn))
package/README.md CHANGED
@@ -16,10 +16,10 @@ This is useful as a simplified method for processing scanned drawings, signature
16
16
  - @param {function(Error, Jimp)} cb (optional) a callback for when complete
17
17
 
18
18
  ```js
19
- import jimp from 'jimp';
19
+ import jimp from "jimp";
20
20
 
21
21
  async function main() {
22
- const image = await jimp.read('test/image.png');
22
+ const image = await jimp.read("test/image.png");
23
23
 
24
24
  image.threshold({ max: 150 });
25
25
  // or
package/babel.config.js CHANGED
@@ -1,38 +1,38 @@
1
- module.exports = api => {
1
+ module.exports = (api) => {
2
2
  api.cache(true);
3
3
 
4
4
  return {
5
5
  presets: [
6
6
  [
7
- '@babel/env',
7
+ "@babel/env",
8
8
  {
9
- useBuiltIns: 'usage'
10
- }
11
- ]
9
+ useBuiltIns: "usage",
10
+ },
11
+ ],
12
12
  ],
13
13
 
14
14
  plugins: [
15
- '@babel/proposal-class-properties',
16
- '@babel/syntax-object-rest-spread',
17
- process.env.BABEL_ENV !== 'module' && 'add-module-exports',
15
+ "@babel/proposal-class-properties",
16
+ "@babel/syntax-object-rest-spread",
17
+ process.env.BABEL_ENV !== "module" && "add-module-exports",
18
18
  [
19
- 'transform-inline-environment-variables',
20
- { include: ['BABEL_ENV', 'ENV'] }
21
- ]
19
+ "transform-inline-environment-variables",
20
+ { include: ["BABEL_ENV", "ENV"] },
21
+ ],
22
22
  ].filter(Boolean),
23
23
 
24
24
  env: {
25
25
  test: {
26
- plugins: ['istanbul']
26
+ plugins: ["istanbul"],
27
27
  },
28
28
  development: {
29
- plugins: [process.env.ENV !== 'browser' && 'source-map-support'].filter(
29
+ plugins: [process.env.ENV !== "browser" && "source-map-support"].filter(
30
30
  Boolean
31
- )
31
+ ),
32
32
  },
33
33
  module: {
34
- presets: [['@babel/env', { modules: false }]]
35
- }
36
- }
34
+ presets: [["@babel/env", { modules: false }]],
35
+ },
36
+ },
37
37
  };
38
38
  };
package/dist/index.js CHANGED
@@ -27,16 +27,16 @@ var _default = function _default() {
27
27
  _ref$autoGreyscale = _ref.autoGreyscale,
28
28
  autoGreyscale = _ref$autoGreyscale === void 0 ? true : _ref$autoGreyscale;
29
29
 
30
- if (typeof max !== 'number') {
31
- return _utils.throwError.call(this, 'max must be a number', cb);
30
+ if (typeof max !== "number") {
31
+ return _utils.throwError.call(this, "max must be a number", cb);
32
32
  }
33
33
 
34
- if (typeof replace !== 'number') {
35
- return _utils.throwError.call(this, 'replace must be a number', cb);
34
+ if (typeof replace !== "number") {
35
+ return _utils.throwError.call(this, "replace must be a number", cb);
36
36
  }
37
37
 
38
- if (typeof autoGreyscale !== 'boolean') {
39
- return _utils.throwError.call(this, 'autoGreyscale must be a boolean', cb);
38
+ if (typeof autoGreyscale !== "boolean") {
39
+ return _utils.throwError.call(this, "autoGreyscale must be a boolean", cb);
40
40
  }
41
41
 
42
42
  max = this.constructor.limit255(max);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["threshold","cb","max","replace","autoGreyscale","throwError","call","constructor","limit255","greyscale","scanQuiet","bitmap","width","height","x","y","idx","grey","data"],"mappings":";;;;;;;AAAA;;AAEA;;;;;;;;;eASe;AAAA,SAAO;AACpBA,IAAAA,SADoB,2BACoCC,EADpC,EACwC;AAAA;;AAAA,UAAhDC,GAAgD,QAAhDA,GAAgD;AAAA,8BAA3CC,OAA2C;AAAA,UAA3CA,OAA2C,6BAAjC,GAAiC;AAAA,oCAA5BC,aAA4B;AAAA,UAA5BA,aAA4B,mCAAZ,IAAY;;AAC1D,UAAI,OAAOF,GAAP,KAAe,QAAnB,EAA6B;AAC3B,eAAOG,kBAAWC,IAAX,CAAgB,IAAhB,EAAsB,sBAAtB,EAA8CL,EAA9C,CAAP;AACD;;AAED,UAAI,OAAOE,OAAP,KAAmB,QA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n/**\n * Applies a minimum color threshold to a greyscale image. Converts image to greyscale by default\n * @param {number} options object\n * max: A number auto limited between 0 - 255\n * replace: (optional) A number auto limited between 0 - 255 (default 255)\n * autoGreyscale: (optional) A boolean whether to apply greyscale beforehand (default true)\n * @param {number} cb (optional) a callback for when complete\n * @return {this} this for chaining of methods\n */\nexport default () => ({\n threshold({ max, replace = 255, autoGreyscale = true }, cb) {\n if (typeof max !== 'number') {\n return throwError.call(this, 'max must be a number', cb);\n }\n\n if (typeof replace !== 'number') {\n return throwError.call(this, 'replace must be a number', cb);\n }\n\n if (typeof autoGreyscale !== 'boolean') {\n return throwError.call(this, 'autoGreyscale must be a boolean', cb);\n }\n\n max = this.constructor.limit255(max);\n replace = this.constructor.limit255(replace);\n\n if (autoGreyscale) {\n this.greyscale();\n }\n\n this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, (x, y, idx) => {\n const grey =\n this.bitmap.data[idx] < max ? this.bitmap.data[idx] : replace;\n\n this.bitmap.data[idx] = grey;\n this.bitmap.data[idx + 1] = grey;\n this.bitmap.data[idx + 2] = grey;\n });\n\n if (isNodePattern(cb)) {\n cb.call(this, null, this);\n }\n\n return this;\n }\n});\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.js"],"names":["threshold","cb","max","replace","autoGreyscale","throwError","call","constructor","limit255","greyscale","scanQuiet","bitmap","width","height","x","y","idx","grey","data"],"mappings":";;;;;;;AAAA;;AAEA;;;;;;;;;eASe;AAAA,SAAO;AACpBA,IAAAA,SADoB,2BACoCC,EADpC,EACwC;AAAA;;AAAA,UAAhDC,GAAgD,QAAhDA,GAAgD;AAAA,8BAA3CC,OAA2C;AAAA,UAA3CA,OAA2C,6BAAjC,GAAiC;AAAA,oCAA5BC,aAA4B;AAAA,UAA5BA,aAA4B,mCAAZ,IAAY;;AAC1D,UAAI,OAAOF,GAAP,KAAe,QAAnB,EAA6B;AAC3B,eAAOG,kBAAWC,IAAX,CAAgB,IAAhB,EAAsB,sBAAtB,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nCmB,GAAP;AAAA,C","sourcesContent":["import { isNodePattern, throwError } from \"@jimp/utils\";\n\n/**\n * Applies a minimum color threshold to a greyscale image. Converts image to greyscale by default\n * @param {number} options object\n * max: A number auto limited between 0 - 255\n * replace: (optional) A number auto limited between 0 - 255 (default 255)\n * autoGreyscale: (optional) A boolean whether to apply greyscale beforehand (default true)\n * @param {number} cb (optional) a callback for when complete\n * @return {this} this for chaining of methods\n */\nexport default () => ({\n threshold({ max, replace = 255, autoGreyscale = true }, cb) {\n if (typeof max !== \"number\") {\n return throwError.call(this, \"max must be a number\", cb);\n }\n\n if (typeof replace !== \"number\") {\n return throwError.call(this, \"replace must be a number\", cb);\n }\n\n if (typeof autoGreyscale !== \"boolean\") {\n return throwError.call(this, \"autoGreyscale must be a boolean\", cb);\n }\n\n max = this.constructor.limit255(max);\n replace = this.constructor.limit255(replace);\n\n if (autoGreyscale) {\n this.greyscale();\n }\n\n this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, (x, y, idx) => {\n const grey =\n this.bitmap.data[idx] < max ? this.bitmap.data[idx] : replace;\n\n this.bitmap.data[idx] = grey;\n this.bitmap.data[idx + 1] = grey;\n this.bitmap.data[idx + 2] = grey;\n });\n\n if (isNodePattern(cb)) {\n cb.call(this, null, this);\n }\n\n return this;\n },\n});\n"],"file":"index.js"}
package/index.d.ts CHANGED
@@ -1,11 +1,14 @@
1
- import { ImageCallback } from '@jimp/core';
1
+ import { ImageCallback } from "@jimp/core";
2
2
 
3
3
  interface Threshold {
4
- threshold(opts: {
5
- max: number,
6
- replace?: number,
7
- autoGreyscale?: boolean
8
- }, cb?: ImageCallback<this>): this;
4
+ threshold(
5
+ opts: {
6
+ max: number;
7
+ replace?: number;
8
+ autoGreyscale?: boolean;
9
+ },
10
+ cb?: ImageCallback<this>
11
+ ): this;
9
12
  }
10
13
 
11
- export default function(): Threshold;
14
+ export default function (): Threshold;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jimp/plugin-threshold",
3
- "version": "0.16.3-canary.993.1592.0",
3
+ "version": "0.16.3",
4
4
  "description": "Lightens an image.",
5
5
  "main": "dist/index.js",
6
6
  "module": "es/index.js",
@@ -21,7 +21,7 @@
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
23
  "@babel/runtime": "^7.7.2",
24
- "@jimp/utils": "0.16.3-canary.993.1592.0"
24
+ "@jimp/utils": "^0.16.3"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "@jimp/custom": ">=0.3.5",
@@ -29,14 +29,14 @@
29
29
  "@jimp/plugin-resize": ">=0.8.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@jimp/custom": "0.16.3-canary.993.1592.0",
33
- "@jimp/jpeg": "0.16.3-canary.993.1592.0",
34
- "@jimp/plugin-color": "0.16.3-canary.993.1592.0",
35
- "@jimp/plugin-resize": "0.16.3-canary.993.1592.0",
36
- "@jimp/test-utils": "0.16.3-canary.993.1592.0"
32
+ "@jimp/custom": "^0.16.3",
33
+ "@jimp/jpeg": "^0.16.3",
34
+ "@jimp/plugin-color": "^0.16.3",
35
+ "@jimp/plugin-resize": "^0.16.3",
36
+ "@jimp/test-utils": "^0.16.3"
37
37
  },
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
- "gitHead": "944d160be95561140eae2ca1bd7e1403a08c543a"
41
+ "gitHead": "b9ac83d855d09deecde129a9c9b5b328ba7ea5b2"
42
42
  }
package/src/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { isNodePattern, throwError } from '@jimp/utils';
1
+ import { isNodePattern, throwError } from "@jimp/utils";
2
2
 
3
3
  /**
4
4
  * Applies a minimum color threshold to a greyscale image. Converts image to greyscale by default
@@ -11,16 +11,16 @@ import { isNodePattern, throwError } from '@jimp/utils';
11
11
  */
12
12
  export default () => ({
13
13
  threshold({ max, replace = 255, autoGreyscale = true }, cb) {
14
- if (typeof max !== 'number') {
15
- return throwError.call(this, 'max must be a number', cb);
14
+ if (typeof max !== "number") {
15
+ return throwError.call(this, "max must be a number", cb);
16
16
  }
17
17
 
18
- if (typeof replace !== 'number') {
19
- return throwError.call(this, 'replace must be a number', cb);
18
+ if (typeof replace !== "number") {
19
+ return throwError.call(this, "replace must be a number", cb);
20
20
  }
21
21
 
22
- if (typeof autoGreyscale !== 'boolean') {
23
- return throwError.call(this, 'autoGreyscale must be a boolean', cb);
22
+ if (typeof autoGreyscale !== "boolean") {
23
+ return throwError.call(this, "autoGreyscale must be a boolean", cb);
24
24
  }
25
25
 
26
26
  max = this.constructor.limit255(max);
@@ -44,5 +44,5 @@ export default () => ({
44
44
  }
45
45
 
46
46
  return this;
47
- }
47
+ },
48
48
  });
@@ -1,25 +1,25 @@
1
- import { Jimp, getTestDir } from '@jimp/test-utils';
2
- import configure from '@jimp/custom';
3
- import jpeg from '@jimp/jpeg';
4
- import color from '@jimp/plugin-color';
5
- import resize from '@jimp/plugin-resize';
1
+ import { Jimp, getTestDir } from "@jimp/test-utils";
2
+ import configure from "@jimp/custom";
3
+ import jpeg from "@jimp/jpeg";
4
+ import color from "@jimp/plugin-color";
5
+ import resize from "@jimp/plugin-resize";
6
6
 
7
- import threshold from '../src';
7
+ import threshold from "../src";
8
8
 
9
9
  const jimp = configure(
10
10
  { types: [jpeg], plugins: [threshold, color, resize] },
11
11
  Jimp
12
12
  );
13
13
 
14
- describe('Threshold', function() {
14
+ describe("Threshold", function () {
15
15
  this.timeout(15000);
16
16
 
17
- it('defines default threshold for lighter backgrounds', async () => {
17
+ it("defines default threshold for lighter backgrounds", async () => {
18
18
  const expectedImage = await jimp.read(
19
- getTestDir(__dirname) + '/images/hands_mx200_rp255.jpg'
19
+ getTestDir(__dirname) + "/images/hands_mx200_rp255.jpg"
20
20
  );
21
21
  const testImage = await jimp.read(
22
- getTestDir(__dirname) + '/images/hands.jpg'
22
+ getTestDir(__dirname) + "/images/hands.jpg"
23
23
  );
24
24
 
25
25
  testImage
package/es/index.js DELETED
@@ -1,66 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- var _utils = require("@jimp/utils");
9
-
10
- /**
11
- * Applies a minimum color threshold to a greyscale image. Converts image to greyscale by default
12
- * @param {number} options object
13
- * max: A number auto limited between 0 - 255
14
- * replace: (optional) A number auto limited between 0 - 255 (default 255)
15
- * autoGreyscale: (optional) A boolean whether to apply greyscale beforehand (default true)
16
- * @param {number} cb (optional) a callback for when complete
17
- * @return {this} this for chaining of methods
18
- */
19
- var _default = function _default() {
20
- return {
21
- threshold: function threshold(_ref, cb) {
22
- var _this = this;
23
-
24
- var max = _ref.max,
25
- _ref$replace = _ref.replace,
26
- replace = _ref$replace === void 0 ? 255 : _ref$replace,
27
- _ref$autoGreyscale = _ref.autoGreyscale,
28
- autoGreyscale = _ref$autoGreyscale === void 0 ? true : _ref$autoGreyscale;
29
-
30
- if (typeof max !== 'number') {
31
- return _utils.throwError.call(this, 'max must be a number', cb);
32
- }
33
-
34
- if (typeof replace !== 'number') {
35
- return _utils.throwError.call(this, 'replace must be a number', cb);
36
- }
37
-
38
- if (typeof autoGreyscale !== 'boolean') {
39
- return _utils.throwError.call(this, 'autoGreyscale must be a boolean', cb);
40
- }
41
-
42
- max = this.constructor.limit255(max);
43
- replace = this.constructor.limit255(replace);
44
-
45
- if (autoGreyscale) {
46
- this.greyscale();
47
- }
48
-
49
- this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function (x, y, idx) {
50
- var grey = _this.bitmap.data[idx] < max ? _this.bitmap.data[idx] : replace;
51
- _this.bitmap.data[idx] = grey;
52
- _this.bitmap.data[idx + 1] = grey;
53
- _this.bitmap.data[idx + 2] = grey;
54
- });
55
-
56
- if ((0, _utils.isNodePattern)(cb)) {
57
- cb.call(this, null, this);
58
- }
59
-
60
- return this;
61
- }
62
- };
63
- };
64
-
65
- exports["default"] = _default;
66
- //# sourceMappingURL=index.js.map
package/es/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["threshold","cb","max","replace","autoGreyscale","throwError","call","constructor","limit255","greyscale","scanQuiet","bitmap","width","height","x","y","idx","grey","data"],"mappings":";;;;;;;AAAA;;AAEA;;;;;;;;;eASe;AAAA,SAAO;AACpBA,IAAAA,SADoB,2BACoCC,EADpC,EACwC;AAAA;;AAAA,UAAhDC,GAAgD,QAAhDA,GAAgD;AAAA,8BAA3CC,OAA2C;AAAA,UAA3CA,OAA2C,6BAAjC,GAAiC;AAAA,oCAA5BC,aAA4B;AAAA,UAA5BA,aAA4B,mCAAZ,IAAY;;AAC1D,UAAI,OAAOF,GAAP,KAAe,QAAnB,EAA6B;AAC3B,eAAOG,kBAAWC,IAAX,CAAgB,IAAhB,EAAsB,sBAAtB,EAA8CL,EAA9C,CAAP;AACD;;AAED,UAAI,OAAOE,OAAP,KAAmB,QAAvB,EAAiC;AAC/B,eAAOE,kBAAWC,IAAX,CAAgB,IAAhB,EAAsB,0BAAtB,EAAkDL,EAAlD,CAAP;AACD;;AAED,UAAI,OAAOG,aAAP,KAAyB,SAA7B,EAAwC;AACtC,eAAOC,kBAAWC,IAAX,CAAgB,IAAhB,EAAsB,iCAAtB,EAAyDL,EAAzD,CAAP;AACD;;AAEDC,MAAAA,GAAG,GAAG,KAAKK,WAAL,CAAiBC,QAAjB,CAA0BN,GAA1B,CAAN;AACAC,MAAAA,OAAO,GAAG,KAAKI,WAAL,CAAiBC,QAAjB,CAA0BL,OAA1B,CAAV;;AAEA,UAAIC,aAAJ,EAAmB;AACjB,aAAKK,SAAL;AACD;;AAED,WAAKC,SAAL,CAAe,CAAf,EAAkB,CAAlB,EAAqB,KAAKC,MAAL,CAAYC,KAAjC,EAAwC,KAAKD,MAAL,CAAYE,MAApD,EAA4D,UAACC,CAAD,EAAIC,CAAJ,EAAOC,GAAP,EAAe;AACzE,YAAMC,IAAI,GACR,KAAI,CAACN,MAAL,CAAYO,IAAZ,CAAiBF,GAAjB,IAAwBd,GAAxB,GAA8B,KAAI,CAACS,MAAL,CAAYO,IAAZ,CAAiBF,GAAjB,CAA9B,GAAsDb,OADxD;AAGA,QAAA,KAAI,CAACQ,MAAL,CAAYO,IAAZ,CAAiBF,GAAjB,IAAwBC,IAAxB;AACA,QAAA,KAAI,CAACN,MAAL,CAAYO,IAAZ,CAAiBF,GAAG,GAAG,CAAvB,IAA4BC,IAA5B;AACA,QAAA,KAAI,CAACN,MAAL,CAAYO,IAAZ,CAAiBF,GAAG,GAAG,CAAvB,IAA4BC,IAA5B;AACD,OAPD;;AASA,UAAI,0BAAchB,EAAd,CAAJ,EAAuB;AACrBA,QAAAA,EAAE,CAACK,IAAH,CAAQ,IAAR,EAAc,IAAd,EAAoB,IAApB;AACD;;AAED,aAAO,IAAP;AACD;AAnCmB,GAAP;AAAA,C","sourcesContent":["import { isNodePattern, throwError } from '@jimp/utils';\n\n/**\n * Applies a minimum color threshold to a greyscale image. Converts image to greyscale by default\n * @param {number} options object\n * max: A number auto limited between 0 - 255\n * replace: (optional) A number auto limited between 0 - 255 (default 255)\n * autoGreyscale: (optional) A boolean whether to apply greyscale beforehand (default true)\n * @param {number} cb (optional) a callback for when complete\n * @return {this} this for chaining of methods\n */\nexport default () => ({\n threshold({ max, replace = 255, autoGreyscale = true }, cb) {\n if (typeof max !== 'number') {\n return throwError.call(this, 'max must be a number', cb);\n }\n\n if (typeof replace !== 'number') {\n return throwError.call(this, 'replace must be a number', cb);\n }\n\n if (typeof autoGreyscale !== 'boolean') {\n return throwError.call(this, 'autoGreyscale must be a boolean', cb);\n }\n\n max = this.constructor.limit255(max);\n replace = this.constructor.limit255(replace);\n\n if (autoGreyscale) {\n this.greyscale();\n }\n\n this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, (x, y, idx) => {\n const grey =\n this.bitmap.data[idx] < max ? this.bitmap.data[idx] : replace;\n\n this.bitmap.data[idx] = grey;\n this.bitmap.data[idx + 1] = grey;\n this.bitmap.data[idx + 2] = grey;\n });\n\n if (isNodePattern(cb)) {\n cb.call(this, null, this);\n }\n\n return this;\n }\n});\n"],"file":"index.js"}