Skip to content
Merged
5 changes: 1 addition & 4 deletions src/accessibility/gridOutput.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ function _gridMap(idT, ingredients) {
let shapeNumber = 0;
let table = '';
//create an array of arrays 10*10 of empty cells
let cells = Array.apply(null, Array(10)).map(function() {});
for (let r in cells) {
cells[r] = Array.apply(null, Array(10)).map(function() {});
}
let cells = Array.from(Array(10), () => Array(10));
for (let x in ingredients) {
for (let y in ingredients[x]) {
let fill;
Expand Down
8 changes: 4 additions & 4 deletions src/core/friendly_errors/fes_core.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ if (typeof IS_MINIFIED !== 'undefined') {

msg = translator('fes.misspelling', {
name: errSym,
suggestions: suggestions,
suggestions,
location: locationObj ? translator('fes.location', locationObj) : '',
count: matchedSymbols.length
});
Expand Down Expand Up @@ -443,7 +443,7 @@ if (typeof IS_MINIFIED !== 'undefined') {
translationObj = {
func: frame.functionName,
line: frame.lineNumber,
location: location,
location,
file: frame.fileName.split('/').slice(-1)
};
if (idx === 0) {
Expand Down Expand Up @@ -568,7 +568,7 @@ if (typeof IS_MINIFIED !== 'undefined') {
) {
p5._friendlyError(
translator('fes.wrongPreload', {
func: func,
func,
location: locationObj
? translator('fes.location', locationObj)
: '',
Expand All @@ -580,7 +580,7 @@ if (typeof IS_MINIFIED !== 'undefined') {
// Library error
p5._friendlyError(
translator('fes.libraryError', {
func: func,
func,
location: locationObj
? translator('fes.location', locationObj)
: '',
Expand Down
8 changes: 4 additions & 4 deletions src/core/friendly_errors/sketch_reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ if (typeof IS_MINIFIED !== 'undefined') {
//display the FES message if a match is found
p5._friendlyError(
translator('fes.sketchReaderErrors.reservedConst', {
url: url,
url,
symbol: variableArray[i]
})
);
Expand Down Expand Up @@ -103,7 +103,7 @@ if (typeof IS_MINIFIED !== 'undefined') {
let url = `https://p5js.org/reference/#/p5/${variableArray[i]}`;
p5._friendlyError(
translator('fes.sketchReaderErrors.reservedFunc', {
url: url,
url,
symbol: variableArray[i]
})
);
Expand Down Expand Up @@ -299,7 +299,7 @@ if (typeof IS_MINIFIED !== 'undefined') {
let url = `https://p5js.org/reference/#/p5/${tempArray[i]}`;
p5._friendlyError(
translator('fes.sketchReaderErrors.reservedConst', {
url: url,
url,
symbol: tempArray[i]
})
);
Expand Down Expand Up @@ -357,7 +357,7 @@ if (typeof IS_MINIFIED !== 'undefined') {
let url = `https://p5js.org/reference/#/p5/${functionArray[i]}`;
p5._friendlyError(
translator('fes.sketchReaderErrors.reservedFunc', {
url: url,
url,
symbol: functionArray[i]
})
);
Expand Down
12 changes: 5 additions & 7 deletions src/core/friendly_errors/stacktrace.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import p5 from '../main';
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
function ErrorStackParser() {
'use strict';

let FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\S+:\d+/;
let CHROME_IE_STACK_REGEXP = /^\s*at .*(\S+:\d+|\(native\))/m;
let SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\[native code])?$/;
Expand Down Expand Up @@ -101,8 +99,8 @@ function ErrorStackParser() {
: locationParts[0];

return {
functionName: functionName,
fileName: fileName,
functionName,
fileName,
lineNumber: locationParts[1],
columnNumber: locationParts[2],
source: line
Expand Down Expand Up @@ -138,7 +136,7 @@ function ErrorStackParser() {
);

return {
functionName: functionName,
functionName,
fileName: locationParts[0],
lineNumber: locationParts[1],
columnNumber: locationParts[2],
Expand Down Expand Up @@ -228,8 +226,8 @@ function ErrorStackParser() {
: argsRaw.split(',');

return {
functionName: functionName,
args: args,
functionName,
args,
fileName: locationParts[0],
lineNumber: locationParts[1],
columnNumber: locationParts[2],
Expand Down
2 changes: 1 addition & 1 deletion src/core/friendly_errors/validate_params.js
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ if (typeof IS_MINIFIED !== 'undefined') {
}`;

translationObj.location = translator('fes.location', {
location: location,
location,
// for e.g. get "sketch.js" from "https://example.com/abc/sketch.js"
file: parsed[3].fileName.split('/').slice(-1),
line: parsed[3].lineNumber
Expand Down
29 changes: 15 additions & 14 deletions src/core/p5.Graphics.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import * as constants from './constants';
* @param {p5} [pInst] pointer to p5 instance
*/
p5.Graphics = class extends p5.Element {
constructor (w, h, renderer, pInst) {
constructor(w, h, renderer, pInst) {
let canvas = document.createElement('canvas');
super(canvas, pInst);
const r = renderer || constants.P2D;
Expand Down Expand Up @@ -56,7 +56,7 @@ p5.Graphics = class extends p5.Element {
pInst._elements.push(this);

Object.defineProperty(this, 'deltaTime', {
get: function() {
get() {
return this._pInst.deltaTime;
}
});
Expand Down Expand Up @@ -184,19 +184,20 @@ p5.Graphics = class extends p5.Element {
this.elt.removeEventListener(elt_ev, this._events[elt_ev]);
}
}
};

/**
* Creates and returns a new <a href="#/p5.Framebuffer">p5.Framebuffer</a>
* inside a p5.Graphics WebGL context.
*
* This takes the same parameters as the <a href="#/p5/createFramebuffer">global
* createFramebuffer function.</a>
*
* @method createFramebuffer
*/
p5.Graphics.prototype.createFramebuffer = function(options) {
return new p5.Framebuffer(this, options);

/**
* Creates and returns a new <a href="#/p5.Framebuffer">p5.Framebuffer</a>
* inside a p5.Graphics WebGL context.
*
* This takes the same parameters as the <a href="#/p5/createFramebuffer">global
* createFramebuffer function.</a>
*
* @method createFramebuffer
*/
createFramebuffer(options) {
return new p5.Framebuffer(this, options);
}
};

export default p5.Graphics;
8 changes: 3 additions & 5 deletions src/core/preload.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

import p5 from './main';

p5.prototype._promisePreloads = [
Expand Down Expand Up @@ -117,13 +115,13 @@ p5.prototype._legacyPreloadGenerator = function(
// of a specific class.
const baseValueGenerator =
legacyPreloadSetup.createBaseObject || objectCreator;
let returnedFunction = function() {
let returnedFunction = function(...args) {
// Our then clause needs to run before setup, so we also increment the preload counter
this._incrementPreload();
// Generate the return value based on the generator.
const returnValue = baseValueGenerator.apply(this, arguments);
const returnValue = baseValueGenerator.apply(this, args);
// Run the original wrapper
fn.apply(this, arguments).then(data => {
fn.apply(this, args).then(data => {
// Copy each key from the resolved value into returnValue
Object.assign(returnValue, data);
// Decrement the preload counter, to allow setup to continue.
Expand Down
10 changes: 5 additions & 5 deletions src/core/shape/2d_primitives.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ p5.prototype.arc = function(x, y, w, h, start, stop, mode, detail) {
*/
p5.prototype.ellipse = function(x, y, w, h, detailX) {
p5._validateParameters('ellipse', arguments);
return this._renderEllipse.apply(this, arguments);
return this._renderEllipse(...arguments);
};

/**
Expand Down Expand Up @@ -304,7 +304,7 @@ p5.prototype.circle = function() {
const args = Array.prototype.slice.call(arguments, 0, 2);
args.push(arguments[2]);
args.push(arguments[2]);
return this._renderEllipse.apply(this, args);
return this._renderEllipse(...args);
};

// internal method for drawing ellipses (without parameter validation)
Expand Down Expand Up @@ -615,9 +615,9 @@ p5.prototype.quad = function(...args) {
* @param {Integer} [detailY] number of segments in the y-direction (for WebGL mode)
* @chainable
*/
p5.prototype.rect = function() {
p5._validateParameters('rect', arguments);
return this._renderRect.apply(this, arguments);
p5.prototype.rect = function(...args) {
p5._validateParameters('rect', args);
return this._renderRect(...args);
};

/**
Expand Down
10 changes: 5 additions & 5 deletions src/core/shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ window.requestAnimationFrame = (() =>
typeof Symbol === 'function' && typeof Symbol() === 'symbol';
const propIsEnumerable = Object.prototype.propertyIsEnumerable;
const isEnumerableOn = obj =>
function isEnumerable(prop) {
(function isEnumerable(prop) {
return propIsEnumerable.call(obj, prop);
};
});

// per ES6 spec, this function has to have a length of 2
const assignShim = function assign(target, source1) {
Expand All @@ -68,9 +68,9 @@ window.requestAnimationFrame = (() =>
source = Object(arguments[s]);
props = keys(source);
if (hasSymbols && Object.getOwnPropertySymbols) {
props.push.apply(
props,
Object.getOwnPropertySymbols(source).filter(isEnumerableOn(source))
props.push(
...Object.getOwnPropertySymbols(source)
.filter(isEnumerableOn(source))
);
}
for (i = 0; i < props.length; ++i) {
Expand Down
10 changes: 5 additions & 5 deletions src/core/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,12 @@ import p5 from './main';
* @param {Number} p numbers which define the 4x4 matrix to be multiplied
* @chainable
*/
p5.prototype.applyMatrix = function() {
let isTypedArray = arguments[0] instanceof Object.getPrototypeOf(Uint8Array);
if (Array.isArray(arguments[0]) || isTypedArray) {
this._renderer.applyMatrix(...arguments[0]);
p5.prototype.applyMatrix = function(...args) {
let isTypedArray = args[0] instanceof Object.getPrototypeOf(Uint8Array);
if (Array.isArray(args[0]) || isTypedArray) {
this._renderer.applyMatrix(...args[0]);
} else {
this._renderer.applyMatrix(...arguments);
this._renderer.applyMatrix(...args);
}
return this;
};
Expand Down
Loading