@basemaps/lambda-tiler 6.16.1 → 6.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.
Files changed (158) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/LICENSE +2 -2
  3. package/build/__test__/tile.style.json.test.d.ts +2 -0
  4. package/build/__test__/tile.style.json.test.d.ts.map +1 -0
  5. package/build/__test__/tile.style.json.test.js +33 -0
  6. package/build/__test__/xyz.test.js +35 -34
  7. package/build/cli/dump.js +2 -2
  8. package/build/index.d.ts.map +1 -1
  9. package/build/index.js +10 -0
  10. package/build/routes/esri/rest.d.ts +10 -0
  11. package/build/routes/esri/rest.d.ts.map +1 -0
  12. package/build/routes/esri/rest.js +87 -0
  13. package/build/routes/imagery.d.ts +10 -0
  14. package/build/routes/imagery.d.ts.map +1 -0
  15. package/build/routes/imagery.js +50 -0
  16. package/build/routes/response.d.ts +4 -0
  17. package/build/routes/response.d.ts.map +1 -0
  18. package/build/routes/response.js +3 -0
  19. package/build/routes/tile.d.ts +0 -20
  20. package/build/routes/tile.d.ts.map +1 -1
  21. package/build/routes/tile.js +11 -164
  22. package/build/routes/tile.json.d.ts +10 -0
  23. package/build/routes/tile.json.d.ts.map +1 -0
  24. package/build/routes/tile.json.js +31 -0
  25. package/build/routes/tile.style.json.d.ts +10 -0
  26. package/build/routes/tile.style.json.d.ts.map +1 -0
  27. package/build/routes/tile.style.json.js +74 -0
  28. package/build/routes/tile.wmts.d.ts +9 -0
  29. package/build/routes/tile.wmts.d.ts.map +1 -0
  30. package/build/routes/tile.wmts.js +57 -0
  31. package/build/routes/tile.xyz.d.ts +13 -0
  32. package/build/routes/tile.xyz.d.ts.map +1 -0
  33. package/build/routes/tile.xyz.js +28 -0
  34. package/build/tile.set.raster.d.ts +2 -0
  35. package/build/tile.set.raster.d.ts.map +1 -1
  36. package/build/tile.set.raster.js +3 -1
  37. package/build/tile.set.vector.js +1 -1
  38. package/dist/index.js +10580 -9573
  39. package/dist/node_modules/color/README.md +7 -7
  40. package/dist/node_modules/color/index.js +173 -158
  41. package/dist/node_modules/color/package.json +18 -16
  42. package/dist/node_modules/color-convert/conversions.js +281 -310
  43. package/dist/node_modules/color-convert/index.js +27 -24
  44. package/dist/node_modules/color-convert/package.json +16 -14
  45. package/dist/node_modules/color-convert/route.js +22 -22
  46. package/dist/node_modules/color-name/package.json +17 -14
  47. package/dist/node_modules/color-string/index.js +2 -2
  48. package/dist/node_modules/color-string/package.json +10 -10
  49. package/dist/node_modules/decompress-response/index.d.ts +14 -21
  50. package/dist/node_modules/decompress-response/index.js +34 -16
  51. package/dist/node_modules/decompress-response/license +1 -1
  52. package/dist/node_modules/decompress-response/package.json +23 -17
  53. package/dist/node_modules/decompress-response/readme.md +2 -6
  54. package/dist/node_modules/detect-libc/package.json +0 -1
  55. package/dist/node_modules/mimic-response/index.d.ts +2 -2
  56. package/dist/node_modules/mimic-response/index.js +41 -2
  57. package/dist/node_modules/mimic-response/package.json +17 -17
  58. package/dist/node_modules/mimic-response/readme.md +22 -1
  59. package/dist/node_modules/node-abi/.circleci/config.yml +63 -0
  60. package/dist/node_modules/node-abi/.releaserc.json +9 -0
  61. package/dist/node_modules/node-abi/abi_registry.json +39 -4
  62. package/dist/node_modules/node-abi/index.js +5 -2
  63. package/dist/node_modules/node-abi/package.json +17 -16
  64. package/dist/node_modules/node-abi/test/index.js +7 -15
  65. package/dist/node_modules/node-addon-api/README.md +2 -2
  66. package/dist/node_modules/node-addon-api/except.gypi +20 -11
  67. package/dist/node_modules/node-addon-api/napi-inl.h +734 -196
  68. package/dist/node_modules/node-addon-api/napi.h +420 -164
  69. package/dist/node_modules/node-addon-api/noexcept.gypi +21 -11
  70. package/dist/node_modules/node-addon-api/package.json +43 -14
  71. package/dist/node_modules/node-addon-api/tools/clang-format.js +18 -17
  72. package/dist/node_modules/node-addon-api/tools/eslint-format.js +71 -0
  73. package/dist/node_modules/prebuild-install/CHANGELOG.md +24 -7
  74. package/dist/node_modules/prebuild-install/README.md +24 -4
  75. package/dist/node_modules/prebuild-install/asset.js +10 -10
  76. package/dist/node_modules/prebuild-install/bin.js +13 -13
  77. package/dist/node_modules/prebuild-install/download.js +22 -22
  78. package/dist/node_modules/prebuild-install/log.js +4 -4
  79. package/dist/node_modules/prebuild-install/node_modules/detect-libc/LICENSE +201 -0
  80. package/dist/node_modules/prebuild-install/node_modules/detect-libc/README.md +160 -0
  81. package/dist/node_modules/prebuild-install/node_modules/detect-libc/index.d.ts +11 -0
  82. package/dist/node_modules/prebuild-install/node_modules/detect-libc/lib/detect-libc.js +178 -0
  83. package/dist/node_modules/prebuild-install/node_modules/detect-libc/lib/process.js +16 -0
  84. package/dist/node_modules/prebuild-install/node_modules/detect-libc/package.json +71 -0
  85. package/dist/node_modules/prebuild-install/package.json +18 -19
  86. package/dist/node_modules/prebuild-install/proxy.js +10 -10
  87. package/dist/node_modules/prebuild-install/rc.js +12 -12
  88. package/dist/node_modules/prebuild-install/util.js +14 -14
  89. package/dist/node_modules/semver/package.json +1 -0
  90. package/dist/node_modules/sharp/README.md +2 -2
  91. package/dist/node_modules/sharp/binding.gyp +12 -9
  92. package/dist/node_modules/sharp/build/Release/sharp-linux-x64.node +0 -0
  93. package/dist/node_modules/sharp/install/dll-copy.js +6 -6
  94. package/dist/node_modules/sharp/install/libvips.js +4 -8
  95. package/dist/node_modules/sharp/lib/channel.js +11 -7
  96. package/dist/node_modules/sharp/lib/colour.js +42 -1
  97. package/dist/node_modules/sharp/lib/constructor.js +18 -31
  98. package/dist/node_modules/sharp/lib/input.js +45 -3
  99. package/dist/node_modules/sharp/lib/is.js +19 -5
  100. package/dist/node_modules/sharp/lib/libvips.js +4 -19
  101. package/dist/node_modules/sharp/lib/operation.js +28 -5
  102. package/dist/node_modules/sharp/lib/output.js +147 -16
  103. package/dist/node_modules/sharp/lib/sharp.js +31 -0
  104. package/dist/node_modules/sharp/lib/utility.js +3 -2
  105. package/dist/node_modules/sharp/package.json +32 -23
  106. package/dist/node_modules/sharp/src/common.cc +67 -11
  107. package/dist/node_modules/sharp/src/common.h +25 -5
  108. package/dist/node_modules/sharp/src/libvips/cplusplus/VConnection.cpp +0 -26
  109. package/dist/node_modules/sharp/src/libvips/cplusplus/VImage.cpp +54 -16
  110. package/dist/node_modules/sharp/src/libvips/cplusplus/VInterpolate.cpp +0 -13
  111. package/dist/node_modules/sharp/src/libvips/cplusplus/vips-operators.cpp +185 -1
  112. package/dist/node_modules/sharp/src/metadata.cc +14 -0
  113. package/dist/node_modules/sharp/src/metadata.h +1 -0
  114. package/dist/node_modules/sharp/src/operations.cc +29 -3
  115. package/dist/node_modules/sharp/src/operations.h +13 -2
  116. package/dist/node_modules/sharp/src/pipeline.cc +103 -35
  117. package/dist/node_modules/sharp/src/pipeline.h +23 -3
  118. package/dist/node_modules/sharp/src/utilities.cc +1 -1
  119. package/dist/node_modules/sharp/vendor/{8.10.6 → 8.11.3/linux-x64}/THIRD-PARTY-NOTICES.md +2 -3
  120. package/dist/node_modules/sharp/vendor/{8.10.6 → 8.11.3/linux-x64}/lib/libvips-cpp.so.42 +0 -0
  121. package/dist/node_modules/sharp/vendor/{8.10.6 → 8.11.3/linux-x64}/platform.json +0 -0
  122. package/dist/node_modules/sharp/vendor/8.11.3/linux-x64/versions.json +30 -0
  123. package/dist/node_modules/simple-get/.github/dependabot.yml +15 -0
  124. package/dist/node_modules/simple-get/.github/workflows/ci.yml +23 -0
  125. package/dist/node_modules/simple-get/README.md +17 -3
  126. package/dist/node_modules/simple-get/index.js +9 -0
  127. package/dist/node_modules/simple-get/package.json +27 -13
  128. package/dist/package-lock.json +54 -54
  129. package/dist/package.json +11 -11
  130. package/package.json +12 -12
  131. package/src/__test__/tile.style.json.test.ts +40 -0
  132. package/src/__test__/xyz.test.ts +43 -41
  133. package/src/cli/dump.ts +2 -2
  134. package/src/index.ts +10 -0
  135. package/src/routes/esri/rest.ts +90 -0
  136. package/src/routes/imagery.ts +52 -0
  137. package/src/routes/response.ts +4 -0
  138. package/src/routes/tile.json.ts +44 -0
  139. package/src/routes/tile.style.json.ts +77 -0
  140. package/src/routes/tile.ts +11 -186
  141. package/src/routes/tile.wmts.ts +59 -0
  142. package/src/routes/tile.xyz.ts +30 -0
  143. package/src/tile.set.raster.ts +4 -1
  144. package/src/tile.set.vector.ts +1 -1
  145. package/tsconfig.tsbuildinfo +1 -1
  146. package/dist/node_modules/color-name/.eslintrc.json +0 -43
  147. package/dist/node_modules/color-name/test.js +0 -7
  148. package/dist/node_modules/node-abi/.travis.yml +0 -17
  149. package/dist/node_modules/node-abi/node_modules/semver/CHANGELOG.md +0 -39
  150. package/dist/node_modules/node-abi/node_modules/semver/LICENSE +0 -15
  151. package/dist/node_modules/node-abi/node_modules/semver/README.md +0 -412
  152. package/dist/node_modules/node-abi/node_modules/semver/bin/semver +0 -160
  153. package/dist/node_modules/node-abi/node_modules/semver/package.json +0 -60
  154. package/dist/node_modules/node-abi/node_modules/semver/range.bnf +0 -16
  155. package/dist/node_modules/node-abi/node_modules/semver/semver.js +0 -1483
  156. package/dist/node_modules/node-addon-api/CHANGELOG.md +0 -722
  157. package/dist/node_modules/sharp/build/Release/sharp.node +0 -0
  158. package/dist/node_modules/sharp/vendor/8.10.6/versions.json +0 -31
@@ -1,9 +1,9 @@
1
- # color [![Build Status](https://travis-ci.org/Qix-/color.svg?branch=master)](https://travis-ci.org/Qix-/color)
1
+ # color
2
2
 
3
3
  > JavaScript library for immutable color conversion and manipulation with support for CSS color strings.
4
4
 
5
5
  ```js
6
- var color = Color('#7743CE').alpha(0.5).lighten(0.5);
6
+ const color = Color('#7743CE').alpha(0.5).lighten(0.5);
7
7
  console.log(color.hsl().string()); // 'hsla(262, 59%, 81%, 0.5)'
8
8
 
9
9
  console.log(color.cmyk().round().array()); // [ 16, 25, 0, 8, 0.5 ]
@@ -18,15 +18,15 @@ $ npm install color
18
18
 
19
19
  ## Usage
20
20
  ```js
21
- var Color = require('color');
21
+ const Color = require('color');
22
22
  ```
23
23
 
24
24
  ### Constructors
25
25
  ```js
26
- var color = Color('rgb(255, 255, 255)')
27
- var color = Color({r: 255, g: 255, b: 255})
28
- var color = Color.rgb(255, 255, 255)
29
- var color = Color.rgb([255, 255, 255])
26
+ const color = Color('rgb(255, 255, 255)')
27
+ const color = Color({r: 255, g: 255, b: 255})
28
+ const color = Color.rgb(255, 255, 255)
29
+ const color = Color.rgb([255, 255, 255])
30
30
  ```
31
31
 
32
32
  Set the values for individual channels with `alpha`, `red`, `green`, `blue`, `hue`, `saturationl` (hsl), `saturationv` (hsv), `lightness`, `whiteness`, `blackness`, `cyan`, `magenta`, `yellow`, `black`
@@ -1,31 +1,29 @@
1
- 'use strict';
1
+ const colorString = require('color-string');
2
+ const convert = require('color-convert');
2
3
 
3
- var colorString = require('color-string');
4
- var convert = require('color-convert');
4
+ const _slice = [].slice;
5
5
 
6
- var _slice = [].slice;
7
-
8
- var skippedModels = [
9
- // to be honest, I don't really feel like keyword belongs in color convert, but eh.
6
+ const skippedModels = [
7
+ // To be honest, I don't really feel like keyword belongs in color convert, but eh.
10
8
  'keyword',
11
9
 
12
- // gray conflicts with some method names, and has its own method defined.
10
+ // Gray conflicts with some method names, and has its own method defined.
13
11
  'gray',
14
12
 
15
- // shouldn't really be in color-convert either...
16
- 'hex'
13
+ // Shouldn't really be in color-convert either...
14
+ 'hex',
17
15
  ];
18
16
 
19
- var hashedModelKeys = {};
20
- Object.keys(convert).forEach(function (model) {
17
+ const hashedModelKeys = {};
18
+ for (const model of Object.keys(convert)) {
21
19
  hashedModelKeys[_slice.call(convert[model].labels).sort().join('')] = model;
22
- });
20
+ }
23
21
 
24
- var limiters = {};
22
+ const limiters = {};
25
23
 
26
- function Color(obj, model) {
24
+ function Color(object, model) {
27
25
  if (!(this instanceof Color)) {
28
- return new Color(obj, model);
26
+ return new Color(object, model);
29
27
  }
30
28
 
31
29
  if (model && model in skippedModels) {
@@ -36,73 +34,72 @@ function Color(obj, model) {
36
34
  throw new Error('Unknown model: ' + model);
37
35
  }
38
36
 
39
- var i;
40
- var channels;
37
+ let i;
38
+ let channels;
41
39
 
42
- if (obj == null) { // eslint-disable-line no-eq-null,eqeqeq
40
+ if (object == null) { // eslint-disable-line no-eq-null,eqeqeq
43
41
  this.model = 'rgb';
44
42
  this.color = [0, 0, 0];
45
43
  this.valpha = 1;
46
- } else if (obj instanceof Color) {
47
- this.model = obj.model;
48
- this.color = obj.color.slice();
49
- this.valpha = obj.valpha;
50
- } else if (typeof obj === 'string') {
51
- var result = colorString.get(obj);
44
+ } else if (object instanceof Color) {
45
+ this.model = object.model;
46
+ this.color = object.color.slice();
47
+ this.valpha = object.valpha;
48
+ } else if (typeof object === 'string') {
49
+ const result = colorString.get(object);
52
50
  if (result === null) {
53
- throw new Error('Unable to parse color from string: ' + obj);
51
+ throw new Error('Unable to parse color from string: ' + object);
54
52
  }
55
53
 
56
54
  this.model = result.model;
57
55
  channels = convert[this.model].channels;
58
56
  this.color = result.value.slice(0, channels);
59
57
  this.valpha = typeof result.value[channels] === 'number' ? result.value[channels] : 1;
60
- } else if (obj.length) {
58
+ } else if (object.length > 0) {
61
59
  this.model = model || 'rgb';
62
60
  channels = convert[this.model].channels;
63
- var newArr = _slice.call(obj, 0, channels);
64
- this.color = zeroArray(newArr, channels);
65
- this.valpha = typeof obj[channels] === 'number' ? obj[channels] : 1;
66
- } else if (typeof obj === 'number') {
67
- // this is always RGB - can be converted later on.
68
- obj &= 0xFFFFFF;
61
+ const newArray = _slice.call(object, 0, channels);
62
+ this.color = zeroArray(newArray, channels);
63
+ this.valpha = typeof object[channels] === 'number' ? object[channels] : 1;
64
+ } else if (typeof object === 'number') {
65
+ // This is always RGB - can be converted later on.
69
66
  this.model = 'rgb';
70
67
  this.color = [
71
- (obj >> 16) & 0xFF,
72
- (obj >> 8) & 0xFF,
73
- obj & 0xFF
68
+ (object >> 16) & 0xFF,
69
+ (object >> 8) & 0xFF,
70
+ object & 0xFF,
74
71
  ];
75
72
  this.valpha = 1;
76
73
  } else {
77
74
  this.valpha = 1;
78
75
 
79
- var keys = Object.keys(obj);
80
- if ('alpha' in obj) {
76
+ const keys = Object.keys(object);
77
+ if ('alpha' in object) {
81
78
  keys.splice(keys.indexOf('alpha'), 1);
82
- this.valpha = typeof obj.alpha === 'number' ? obj.alpha : 0;
79
+ this.valpha = typeof object.alpha === 'number' ? object.alpha : 0;
83
80
  }
84
81
 
85
- var hashedKeys = keys.sort().join('');
82
+ const hashedKeys = keys.sort().join('');
86
83
  if (!(hashedKeys in hashedModelKeys)) {
87
- throw new Error('Unable to parse color from object: ' + JSON.stringify(obj));
84
+ throw new Error('Unable to parse color from object: ' + JSON.stringify(object));
88
85
  }
89
86
 
90
87
  this.model = hashedModelKeys[hashedKeys];
91
88
 
92
- var labels = convert[this.model].labels;
93
- var color = [];
89
+ const labels = convert[this.model].labels;
90
+ const color = [];
94
91
  for (i = 0; i < labels.length; i++) {
95
- color.push(obj[labels[i]]);
92
+ color.push(object[labels[i]]);
96
93
  }
97
94
 
98
95
  this.color = zeroArray(color);
99
96
  }
100
97
 
101
- // perform limitations (clamping, etc.)
98
+ // Perform limitations (clamping, etc.)
102
99
  if (limiters[this.model]) {
103
100
  channels = convert[this.model].channels;
104
101
  for (i = 0; i < channels; i++) {
105
- var limit = limiters[this.model][i];
102
+ const limit = limiters[this.model][i];
106
103
  if (limit) {
107
104
  this.color[i] = limit(this.color[i]);
108
105
  }
@@ -117,37 +114,37 @@ function Color(obj, model) {
117
114
  }
118
115
 
119
116
  Color.prototype = {
120
- toString: function () {
117
+ toString() {
121
118
  return this.string();
122
119
  },
123
120
 
124
- toJSON: function () {
121
+ toJSON() {
125
122
  return this[this.model]();
126
123
  },
127
124
 
128
- string: function (places) {
129
- var self = this.model in colorString.to ? this : this.rgb();
125
+ string(places) {
126
+ let self = this.model in colorString.to ? this : this.rgb();
130
127
  self = self.round(typeof places === 'number' ? places : 1);
131
- var args = self.valpha === 1 ? self.color : self.color.concat(this.valpha);
128
+ const args = self.valpha === 1 ? self.color : self.color.concat(this.valpha);
132
129
  return colorString.to[self.model](args);
133
130
  },
134
131
 
135
- percentString: function (places) {
136
- var self = this.rgb().round(typeof places === 'number' ? places : 1);
137
- var args = self.valpha === 1 ? self.color : self.color.concat(this.valpha);
132
+ percentString(places) {
133
+ const self = this.rgb().round(typeof places === 'number' ? places : 1);
134
+ const args = self.valpha === 1 ? self.color : self.color.concat(this.valpha);
138
135
  return colorString.to.rgb.percent(args);
139
136
  },
140
137
 
141
- array: function () {
138
+ array() {
142
139
  return this.valpha === 1 ? this.color.slice() : this.color.concat(this.valpha);
143
140
  },
144
141
 
145
- object: function () {
146
- var result = {};
147
- var channels = convert[this.model].channels;
148
- var labels = convert[this.model].labels;
142
+ object() {
143
+ const result = {};
144
+ const channels = convert[this.model].channels;
145
+ const labels = convert[this.model].labels;
149
146
 
150
- for (var i = 0; i < channels; i++) {
147
+ for (let i = 0; i < channels; i++) {
151
148
  result[labels[i]] = this.color[i];
152
149
  }
153
150
 
@@ -158,8 +155,8 @@ Color.prototype = {
158
155
  return result;
159
156
  },
160
157
 
161
- unitArray: function () {
162
- var rgb = this.rgb().color;
158
+ unitArray() {
159
+ const rgb = this.rgb().color;
163
160
  rgb[0] /= 255;
164
161
  rgb[1] /= 255;
165
162
  rgb[2] /= 255;
@@ -171,8 +168,8 @@ Color.prototype = {
171
168
  return rgb;
172
169
  },
173
170
 
174
- unitObject: function () {
175
- var rgb = this.rgb().object();
171
+ unitObject() {
172
+ const rgb = this.rgb().object();
176
173
  rgb.r /= 255;
177
174
  rgb.g /= 255;
178
175
  rgb.b /= 255;
@@ -184,25 +181,25 @@ Color.prototype = {
184
181
  return rgb;
185
182
  },
186
183
 
187
- round: function (places) {
184
+ round(places) {
188
185
  places = Math.max(places || 0, 0);
189
186
  return new Color(this.color.map(roundToPlace(places)).concat(this.valpha), this.model);
190
187
  },
191
188
 
192
- alpha: function (val) {
193
- if (arguments.length) {
194
- return new Color(this.color.concat(Math.max(0, Math.min(1, val))), this.model);
189
+ alpha(value) {
190
+ if (arguments.length > 0) {
191
+ return new Color(this.color.concat(Math.max(0, Math.min(1, value))), this.model);
195
192
  }
196
193
 
197
194
  return this.valpha;
198
195
  },
199
196
 
200
- // rgb
197
+ // Rgb
201
198
  red: getset('rgb', 0, maxfn(255)),
202
199
  green: getset('rgb', 1, maxfn(255)),
203
200
  blue: getset('rgb', 2, maxfn(255)),
204
201
 
205
- hue: getset(['hsl', 'hsv', 'hsl', 'hwb', 'hcg'], 0, function (val) { return ((val % 360) + 360) % 360; }), // eslint-disable-line brace-style
202
+ hue: getset(['hsl', 'hsv', 'hsl', 'hwb', 'hcg'], 0, value => ((value % 360) + 360) % 360),
206
203
 
207
204
  saturationl: getset('hsl', 1, maxfn(100)),
208
205
  lightness: getset('hsl', 2, maxfn(100)),
@@ -229,44 +226,59 @@ Color.prototype = {
229
226
  a: getset('lab', 1),
230
227
  b: getset('lab', 2),
231
228
 
232
- keyword: function (val) {
233
- if (arguments.length) {
234
- return new Color(val);
229
+ keyword(value) {
230
+ if (arguments.length > 0) {
231
+ return new Color(value);
235
232
  }
236
233
 
237
234
  return convert[this.model].keyword(this.color);
238
235
  },
239
236
 
240
- hex: function (val) {
241
- if (arguments.length) {
242
- return new Color(val);
237
+ hex(value) {
238
+ if (arguments.length > 0) {
239
+ return new Color(value);
243
240
  }
244
241
 
245
242
  return colorString.to.hex(this.rgb().round().color);
246
243
  },
247
244
 
248
- rgbNumber: function () {
249
- var rgb = this.rgb().color;
245
+ hexa(value) {
246
+ if (arguments.length > 0) {
247
+ return new Color(value);
248
+ }
249
+
250
+ const rgbArray = this.rgb().round().color;
251
+
252
+ let alphaHex = Math.round(this.valpha * 255).toString(16).toUpperCase();
253
+ if (alphaHex.length === 1) {
254
+ alphaHex = '0' + alphaHex;
255
+ }
256
+
257
+ return colorString.to.hex(rgbArray) + alphaHex;
258
+ },
259
+
260
+ rgbNumber() {
261
+ const rgb = this.rgb().color;
250
262
  return ((rgb[0] & 0xFF) << 16) | ((rgb[1] & 0xFF) << 8) | (rgb[2] & 0xFF);
251
263
  },
252
264
 
253
- luminosity: function () {
265
+ luminosity() {
254
266
  // http://www.w3.org/TR/WCAG20/#relativeluminancedef
255
- var rgb = this.rgb().color;
267
+ const rgb = this.rgb().color;
256
268
 
257
- var lum = [];
258
- for (var i = 0; i < rgb.length; i++) {
259
- var chan = rgb[i] / 255;
260
- lum[i] = (chan <= 0.03928) ? chan / 12.92 : Math.pow(((chan + 0.055) / 1.055), 2.4);
269
+ const lum = [];
270
+ for (const [i, element] of rgb.entries()) {
271
+ const chan = element / 255;
272
+ lum[i] = (chan <= 0.039_28) ? chan / 12.92 : ((chan + 0.055) / 1.055) ** 2.4;
261
273
  }
262
274
 
263
275
  return 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2];
264
276
  },
265
277
 
266
- contrast: function (color2) {
278
+ contrast(color2) {
267
279
  // http://www.w3.org/TR/WCAG20/#contrast-ratiodef
268
- var lum1 = this.luminosity();
269
- var lum2 = color2.luminosity();
280
+ const lum1 = this.luminosity();
281
+ const lum2 = color2.luminosity();
270
282
 
271
283
  if (lum1 > lum2) {
272
284
  return (lum1 + 0.05) / (lum2 + 0.05);
@@ -275,8 +287,8 @@ Color.prototype = {
275
287
  return (lum2 + 0.05) / (lum1 + 0.05);
276
288
  },
277
289
 
278
- level: function (color2) {
279
- var contrastRatio = this.contrast(color2);
290
+ level(color2) {
291
+ const contrastRatio = this.contrast(color2);
280
292
  if (contrastRatio >= 7.1) {
281
293
  return 'AAA';
282
294
  }
@@ -284,128 +296,130 @@ Color.prototype = {
284
296
  return (contrastRatio >= 4.5) ? 'AA' : '';
285
297
  },
286
298
 
287
- isDark: function () {
299
+ isDark() {
288
300
  // YIQ equation from http://24ways.org/2010/calculating-color-contrast
289
- var rgb = this.rgb().color;
290
- var yiq = (rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1000;
301
+ const rgb = this.rgb().color;
302
+ const yiq = (rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1000;
291
303
  return yiq < 128;
292
304
  },
293
305
 
294
- isLight: function () {
306
+ isLight() {
295
307
  return !this.isDark();
296
308
  },
297
309
 
298
- negate: function () {
299
- var rgb = this.rgb();
300
- for (var i = 0; i < 3; i++) {
310
+ negate() {
311
+ const rgb = this.rgb();
312
+ for (let i = 0; i < 3; i++) {
301
313
  rgb.color[i] = 255 - rgb.color[i];
302
314
  }
315
+
303
316
  return rgb;
304
317
  },
305
318
 
306
- lighten: function (ratio) {
307
- var hsl = this.hsl();
319
+ lighten(ratio) {
320
+ const hsl = this.hsl();
308
321
  hsl.color[2] += hsl.color[2] * ratio;
309
322
  return hsl;
310
323
  },
311
324
 
312
- darken: function (ratio) {
313
- var hsl = this.hsl();
325
+ darken(ratio) {
326
+ const hsl = this.hsl();
314
327
  hsl.color[2] -= hsl.color[2] * ratio;
315
328
  return hsl;
316
329
  },
317
330
 
318
- saturate: function (ratio) {
319
- var hsl = this.hsl();
331
+ saturate(ratio) {
332
+ const hsl = this.hsl();
320
333
  hsl.color[1] += hsl.color[1] * ratio;
321
334
  return hsl;
322
335
  },
323
336
 
324
- desaturate: function (ratio) {
325
- var hsl = this.hsl();
337
+ desaturate(ratio) {
338
+ const hsl = this.hsl();
326
339
  hsl.color[1] -= hsl.color[1] * ratio;
327
340
  return hsl;
328
341
  },
329
342
 
330
- whiten: function (ratio) {
331
- var hwb = this.hwb();
343
+ whiten(ratio) {
344
+ const hwb = this.hwb();
332
345
  hwb.color[1] += hwb.color[1] * ratio;
333
346
  return hwb;
334
347
  },
335
348
 
336
- blacken: function (ratio) {
337
- var hwb = this.hwb();
349
+ blacken(ratio) {
350
+ const hwb = this.hwb();
338
351
  hwb.color[2] += hwb.color[2] * ratio;
339
352
  return hwb;
340
353
  },
341
354
 
342
- grayscale: function () {
355
+ grayscale() {
343
356
  // http://en.wikipedia.org/wiki/Grayscale#Converting_color_to_grayscale
344
- var rgb = this.rgb().color;
345
- var val = rgb[0] * 0.3 + rgb[1] * 0.59 + rgb[2] * 0.11;
346
- return Color.rgb(val, val, val);
357
+ const rgb = this.rgb().color;
358
+ const value = rgb[0] * 0.3 + rgb[1] * 0.59 + rgb[2] * 0.11;
359
+ return Color.rgb(value, value, value);
347
360
  },
348
361
 
349
- fade: function (ratio) {
362
+ fade(ratio) {
350
363
  return this.alpha(this.valpha - (this.valpha * ratio));
351
364
  },
352
365
 
353
- opaquer: function (ratio) {
366
+ opaquer(ratio) {
354
367
  return this.alpha(this.valpha + (this.valpha * ratio));
355
368
  },
356
369
 
357
- rotate: function (degrees) {
358
- var hsl = this.hsl();
359
- var hue = hsl.color[0];
370
+ rotate(degrees) {
371
+ const hsl = this.hsl();
372
+ let hue = hsl.color[0];
360
373
  hue = (hue + degrees) % 360;
361
374
  hue = hue < 0 ? 360 + hue : hue;
362
375
  hsl.color[0] = hue;
363
376
  return hsl;
364
377
  },
365
378
 
366
- mix: function (mixinColor, weight) {
367
- // ported from sass implementation in C
379
+ mix(mixinColor, weight) {
380
+ // Ported from sass implementation in C
368
381
  // https://github.com/sass/libsass/blob/0e6b4a2850092356aa3ece07c6b249f0221caced/functions.cpp#L209
369
382
  if (!mixinColor || !mixinColor.rgb) {
370
383
  throw new Error('Argument to "mix" was not a Color instance, but rather an instance of ' + typeof mixinColor);
371
384
  }
372
- var color1 = mixinColor.rgb();
373
- var color2 = this.rgb();
374
- var p = weight === undefined ? 0.5 : weight;
375
385
 
376
- var w = 2 * p - 1;
377
- var a = color1.alpha() - color2.alpha();
386
+ const color1 = mixinColor.rgb();
387
+ const color2 = this.rgb();
388
+ const p = weight === undefined ? 0.5 : weight;
378
389
 
379
- var w1 = (((w * a === -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0;
380
- var w2 = 1 - w1;
390
+ const w = 2 * p - 1;
391
+ const a = color1.alpha() - color2.alpha();
392
+
393
+ const w1 = (((w * a === -1) ? w : (w + a) / (1 + w * a)) + 1) / 2;
394
+ const w2 = 1 - w1;
381
395
 
382
396
  return Color.rgb(
383
- w1 * color1.red() + w2 * color2.red(),
384
- w1 * color1.green() + w2 * color2.green(),
385
- w1 * color1.blue() + w2 * color2.blue(),
386
- color1.alpha() * p + color2.alpha() * (1 - p));
387
- }
397
+ w1 * color1.red() + w2 * color2.red(),
398
+ w1 * color1.green() + w2 * color2.green(),
399
+ w1 * color1.blue() + w2 * color2.blue(),
400
+ color1.alpha() * p + color2.alpha() * (1 - p));
401
+ },
388
402
  };
389
403
 
390
- // model conversion methods and static constructors
391
- Object.keys(convert).forEach(function (model) {
392
- if (skippedModels.indexOf(model) !== -1) {
393
- return;
404
+ // Model conversion methods and static constructors
405
+ for (const model of Object.keys(convert)) {
406
+ if (skippedModels.includes(model)) {
407
+ continue;
394
408
  }
395
409
 
396
- var channels = convert[model].channels;
410
+ const channels = convert[model].channels;
397
411
 
398
- // conversion methods
412
+ // Conversion methods
399
413
  Color.prototype[model] = function () {
400
414
  if (this.model === model) {
401
415
  return new Color(this);
402
416
  }
403
417
 
404
- if (arguments.length) {
418
+ if (arguments.length > 0) {
405
419
  return new Color(arguments, model);
406
420
  }
407
421
 
408
- var newAlpha = typeof arguments[channels] === 'number' ? channels : this.valpha;
422
+ const newAlpha = typeof arguments[channels] === 'number' ? channels : this.valpha;
409
423
  return new Color(assertArray(convert[this.model][model].raw(this.color)).concat(newAlpha), model);
410
424
  };
411
425
 
@@ -414,39 +428,40 @@ Object.keys(convert).forEach(function (model) {
414
428
  if (typeof color === 'number') {
415
429
  color = zeroArray(_slice.call(arguments), channels);
416
430
  }
431
+
417
432
  return new Color(color, model);
418
433
  };
419
- });
434
+ }
420
435
 
421
- function roundTo(num, places) {
422
- return Number(num.toFixed(places));
436
+ function roundTo(number, places) {
437
+ return Number(number.toFixed(places));
423
438
  }
424
439
 
425
440
  function roundToPlace(places) {
426
- return function (num) {
427
- return roundTo(num, places);
441
+ return function (number) {
442
+ return roundTo(number, places);
428
443
  };
429
444
  }
430
445
 
431
446
  function getset(model, channel, modifier) {
432
447
  model = Array.isArray(model) ? model : [model];
433
448
 
434
- model.forEach(function (m) {
449
+ for (const m of model) {
435
450
  (limiters[m] || (limiters[m] = []))[channel] = modifier;
436
- });
451
+ }
437
452
 
438
453
  model = model[0];
439
454
 
440
- return function (val) {
441
- var result;
455
+ return function (value) {
456
+ let result;
442
457
 
443
- if (arguments.length) {
458
+ if (arguments.length > 0) {
444
459
  if (modifier) {
445
- val = modifier(val);
460
+ value = modifier(value);
446
461
  }
447
462
 
448
463
  result = this[model]();
449
- result.color[channel] = val;
464
+ result.color[channel] = value;
450
465
  return result;
451
466
  }
452
467
 
@@ -465,18 +480,18 @@ function maxfn(max) {
465
480
  };
466
481
  }
467
482
 
468
- function assertArray(val) {
469
- return Array.isArray(val) ? val : [val];
483
+ function assertArray(value) {
484
+ return Array.isArray(value) ? value : [value];
470
485
  }
471
486
 
472
- function zeroArray(arr, length) {
473
- for (var i = 0; i < length; i++) {
474
- if (typeof arr[i] !== 'number') {
475
- arr[i] = 0;
487
+ function zeroArray(array, length) {
488
+ for (let i = 0; i < length; i++) {
489
+ if (typeof array[i] !== 'number') {
490
+ array[i] = 0;
476
491
  }
477
492
  }
478
493
 
479
- return arr;
494
+ return array;
480
495
  }
481
496
 
482
497
  module.exports = Color;