Skip to content

Commit 47c22c8

Browse files
authored
Merge branch 'master' into validation2
2 parents be11e31 + d6ebba0 commit 47c22c8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+20202
-2386
lines changed

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"node": true,
44
"browser": true,
55
"mocha": true,
6+
"amd": true,
67
"es6": true
78
},
89
"globals": {

Gruntfile.js

Lines changed: 60 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,34 +96,57 @@ module.exports = function(grunt) {
9696
keepalive = true;
9797
}
9898

99-
grunt.initConfig({
99+
let gruntConfig = {
100100
// read in the package, used for knowing the current version, et al.
101101
pkg: grunt.file.readJSON('package.json'),
102102

103103
// Configure style consistency checking for this file, the source, and the tests.
104104
eslint: {
105105
options: {
106+
format: 'unix',
106107
configFile: '.eslintrc'
107108
},
108109
build: {
109-
src: ['Gruntfile.js', 'tasks/**/*.js']
110-
},
111-
fix: {
112110
src: [
113111
'Gruntfile.js',
114-
'tasks/**/*.js',
115-
'test/unit/**/*.js',
116-
'src/**/*.js'
117-
],
112+
'grunt-karma.js',
113+
'docs/preprocessor.js',
114+
'utils/**/*.js',
115+
'tasks/**/*.js'
116+
]
117+
},
118+
fix: {
119+
// src: is calculated below...
118120
options: {
119121
fix: true
120122
}
121123
},
122124
source: {
123-
src: ['src/**/*.js']
125+
src: ['src/**/*.js', 'lib/addons/p5.dom.js']
124126
},
125127
test: {
126-
src: ['test/unit/**/*.js']
128+
src: [
129+
'bench/**/*.js',
130+
'test/test-docs-preprocessor/**/*.js',
131+
'test/node/**/*.js',
132+
'test/reporter/**/*.js',
133+
'test/unit/**/*.js'
134+
]
135+
}
136+
},
137+
138+
'eslint-samples': {
139+
options: {
140+
configFile: '.eslintrc',
141+
format: 'unix'
142+
},
143+
source: {
144+
src: ['src/**/*.js', 'lib/addons/p5.dom.js']
145+
},
146+
fix: {
147+
options: {
148+
fix: true
149+
}
127150
}
128151
},
129152

@@ -162,9 +185,13 @@ module.exports = function(grunt) {
162185
tasks: ['requirejs:yuidoc_theme']
163186
},
164187
// Watch the codebase for doc updates
188+
// launch with 'grunt requirejs connect watch:yui'
165189
yui: {
166190
files: ['src/**/*.js', 'lib/addons/*.js'],
167-
task: ['yuidoc']
191+
tasks: ['browserify', 'yuidoc:prod', 'minjson', 'uglify'],
192+
options: {
193+
livereload: true
194+
}
168195
}
169196
},
170197

@@ -320,7 +347,24 @@ module.exports = function(grunt) {
320347
}
321348
}
322349
}
323-
});
350+
};
351+
352+
// eslint fixes everything it checks:
353+
gruntConfig.eslint.fix.src = Object.keys(gruntConfig.eslint)
354+
.map(s => gruntConfig.eslint[s].src)
355+
.reduce((a, b) => a.concat(b), [])
356+
.filter(a => a);
357+
358+
/* not yet
359+
gruntConfig['eslint-samples'].fix.src = Object.keys(
360+
gruntConfig['eslint-samples']
361+
)
362+
.map(s => gruntConfig['eslint-samples'][s].src)
363+
.reduce((a, b) => a.concat(b), [])
364+
.filter(a => a);
365+
*/
366+
367+
grunt.initConfig(gruntConfig);
324368

325369
// Load build tasks.
326370
// This contains the complete build task ("browserify")
@@ -361,14 +405,16 @@ module.exports = function(grunt) {
361405
'requirejs'
362406
]);
363407
grunt.registerTask('lint-no-fix', [
408+
'yui', // required for eslint-samples
364409
'eslint:build',
365410
'eslint:source',
366-
'eslint:test'
411+
'eslint:test',
412+
'eslint-samples:source'
367413
]);
368414
grunt.registerTask('lint-fix', ['eslint:fix']);
369415
grunt.registerTask('test', [
370416
'lint-no-fix',
371-
'yuidoc:prod',
417+
//'yuidoc:prod', // already done by lint-no-fix
372418
'build',
373419
'connect',
374420
'mocha',

bench/math/random-fe-off.bench.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* global suite, benchmark */
2+
p5.disableFriendlyErrors = true;
3+
4+
var p5Inst = new p5();
5+
6+
/**
7+
* Instance random() vs Math.random()
8+
*/
9+
suite('Friendly Errors: OFF, Instance random() vs Math.random()', function() {
10+
benchmark('Instance random()', function() {
11+
return p5Inst.random();
12+
});
13+
14+
benchmark('Math.random()', function() {
15+
return Math.random();
16+
});
17+
});
18+
19+
/**
20+
* Window random() vs Math.random()
21+
*/
22+
suite('Friendly Errors: OFF, Window random() vs Math.random()', function() {
23+
benchmark('window random()', function() {
24+
return window.random();
25+
});
26+
27+
benchmark('Math.random()', function() {
28+
return Math.random();
29+
});
30+
});

bench/math/random-fe-on.bench.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* global suite, benchmark */
2+
p5.disableFriendlyErrors = false;
3+
4+
var p5Inst = new p5();
5+
6+
/**
7+
* Instance random() vs Math.random()
8+
*/
9+
suite('Friendly Errors: ON, Instance random() vs Math.random()', function() {
10+
benchmark('Instance random()', function() {
11+
return p5Inst.random();
12+
});
13+
14+
benchmark('Math.random()', function() {
15+
return Math.random();
16+
});
17+
});
18+
19+
/**
20+
* Window random() vs Math.random()
21+
*/
22+
suite('Friendly Errors: ON, Window random() vs Math.random()', function() {
23+
benchmark('window random()', function() {
24+
return window.random();
25+
});
26+
27+
benchmark('Math.random()', function() {
28+
return Math.random();
29+
});
30+
});

bench/math/sin.bench.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* global suite, benchmark */
2+
p5.disableFriendlyErrors = true;
3+
4+
var p5Inst = new p5();
5+
6+
/**
7+
* Compare the p5 sin() function to the native Math.sin()
8+
*/
9+
suite('p5 sin() vs Math.sin()', function() {
10+
benchmark('p5 sin()', function() {
11+
return p5Inst.sin();
12+
});
13+
14+
benchmark('Math.sin()', function() {
15+
return Math.sin();
16+
});
17+
});

bench/random.bench.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)