Skip to content

Commit

Permalink
Use rest parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
jfirebaugh committed May 25, 2017
1 parent cb84e67 commit ecede38
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
7 changes: 2 additions & 5 deletions src/style-spec/error/validation_error.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

const format = require('util').format;

function ValidationError(key, value /*, message, ...*/) {
this.message = (
(key ? `${key}: ` : '') +
format.apply(format, Array.prototype.slice.call(arguments, 2))
);
function ValidationError(key, value, ...args) {
this.message = (key ? `${key}: ` : '') + format.apply(format, args);

if (value !== null && value !== undefined && value.__line__) {
this.line = value.__line__;
Expand Down
6 changes: 3 additions & 3 deletions src/style-spec/function/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ function evaluateExponentialFunction(parameters, propertySpec, input) {
const interp = interpolate[propertySpec.type] || identityFunction;

if (typeof outputLower === 'function') {
return function() {
const evaluatedLower = outputLower.apply(undefined, arguments);
const evaluatedUpper = outputUpper.apply(undefined, arguments);
return function(...args) {
const evaluatedLower = outputLower.apply(undefined, args);
const evaluatedUpper = outputUpper.apply(undefined, args);
// Special case for fill-outline-color, which has no spec default.
if (evaluatedLower === undefined || evaluatedUpper === undefined) {
return undefined;
Expand Down
5 changes: 2 additions & 3 deletions src/style-spec/util/extend.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
'use strict';

module.exports = function (output) {
for (let i = 1; i < arguments.length; i++) {
const input = arguments[i];
module.exports = function (output, ...inputs) {
for (const input of inputs) {
for (const k in input) {
output[k] = input[k];
}
Expand Down
8 changes: 3 additions & 5 deletions src/util/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,11 @@ exports.keysDifference = function (obj: {[key: string]: mixed}, other: {[key: st
* source objects.
*
* @param dest destination object
* @param {...Object} sources sources from which properties are pulled
* @param sources sources from which properties are pulled
* @private
*/
// eslint-disable-next-line no-unused-vars
exports.extend = function (dest: Object, source0: Object, source1?: Object, source2?: Object): Object {
for (let i = 1; i < arguments.length; i++) {
const src = arguments[i];
exports.extend = function (dest: Object, ...sources: Array<Object>): Object {
for (const src of sources) {
for (const k in src) {
dest[k] = src[k];
}
Expand Down

0 comments on commit ecede38

Please sign in to comment.