Travis build: 1782 [cron]
This commit is contained in:
21
test/recordAnimationFrames/recordAnimationFrames.js
Normal file
21
test/recordAnimationFrames/recordAnimationFrames.js
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
const recordAnimationFrames = (callback, autoStart = true) => {
|
||||||
|
let running = true,
|
||||||
|
raf;
|
||||||
|
const stop = () => {
|
||||||
|
running = false;
|
||||||
|
cancelAnimationFrame(raf);
|
||||||
|
};
|
||||||
|
const start = () => {
|
||||||
|
running = true;
|
||||||
|
run();
|
||||||
|
};
|
||||||
|
const run = () => {
|
||||||
|
raf = requestAnimationFrame(() => {
|
||||||
|
callback();
|
||||||
|
if (running) run();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
if (autoStart) start();
|
||||||
|
return { start, stop };
|
||||||
|
};
|
||||||
|
module.exports = recordAnimationFrames;
|
||||||
13
test/recordAnimationFrames/recordAnimationFrames.test.js
Normal file
13
test/recordAnimationFrames/recordAnimationFrames.test.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
const test = require('tape');
|
||||||
|
const recordAnimationFrames = require('./recordAnimationFrames.js');
|
||||||
|
|
||||||
|
test('Testing recordAnimationFrames', (t) => {
|
||||||
|
//For more information on all the methods supported by tape
|
||||||
|
//Please go to https://github.com/substack/tape
|
||||||
|
t.true(typeof recordAnimationFrames === 'function', 'recordAnimationFrames is a Function');
|
||||||
|
//t.deepEqual(recordAnimationFrames(args..), 'Expected');
|
||||||
|
//t.equal(recordAnimationFrames(args..), 'Expected');
|
||||||
|
//t.false(recordAnimationFrames(args..), 'Expected');
|
||||||
|
//t.throws(recordAnimationFrames(args..), 'Expected');
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
12
test/testlog
12
test/testlog
@ -1,4 +1,4 @@
|
|||||||
Test log for: Mon Mar 05 2018 20:32:06 GMT+0000 (UTC)
|
Test log for: Tue Mar 06 2018 20:32:25 GMT+0000 (UTC)
|
||||||
|
|
||||||
> 30-seconds-of-code@0.0.2 test /home/travis/build/Chalarangelo/30-seconds-of-code
|
> 30-seconds-of-code@0.0.2 test /home/travis/build/Chalarangelo/30-seconds-of-code
|
||||||
> tape test/**/*.test.js | tap-spec
|
> tape test/**/*.test.js | tap-spec
|
||||||
@ -1398,6 +1398,10 @@ Test log for: Mon Mar 05 2018 20:32:06 GMT+0000 (UTC)
|
|||||||
✔ rearg is a Function
|
✔ rearg is a Function
|
||||||
✔ Reorders arguments in invoked function
|
✔ Reorders arguments in invoked function
|
||||||
|
|
||||||
|
Testing recordAnimationFrames
|
||||||
|
|
||||||
|
✔ recordAnimationFrames is a Function
|
||||||
|
|
||||||
Testing redirect
|
Testing redirect
|
||||||
|
|
||||||
✔ redirect is a Function
|
✔ redirect is a Function
|
||||||
@ -1972,10 +1976,10 @@ Test log for: Mon Mar 05 2018 20:32:06 GMT+0000 (UTC)
|
|||||||
✖ length of string is 8
|
✖ length of string is 8
|
||||||
|
|
||||||
|
|
||||||
total: 988
|
total: 989
|
||||||
passing: 986
|
passing: 987
|
||||||
failing: 2
|
failing: 2
|
||||||
duration: 2.6s
|
duration: 2.4s
|
||||||
|
|
||||||
|
|
||||||
undefined
|
undefined
|
||||||
@ -1,11 +1,8 @@
|
|||||||
const zipWith = (...arrays) => {
|
const zipWith = (...array) => {
|
||||||
const length = arrays.length;
|
const fn = typeof array[array.length - 1] === 'function' ? array.pop() : undefined;
|
||||||
let fn = length > 1 ? arrays[length - 1] : undefined;
|
return Array.from(
|
||||||
fn = typeof fn == 'function' ? (arrays.pop(), fn) : undefined;
|
{ length: Math.max(...array.map(a => a.length)) },
|
||||||
const maxLength = Math.max(...arrays.map(x => x.length));
|
(_, i) => (fn ? fn(...array.map(a => a[i])) : array.map(a => a[i]))
|
||||||
const result = Array.from({ length: maxLength }).map((_, i) => {
|
);
|
||||||
return Array.from({ length: arrays.length }, (_, k) => arrays[k][i]);
|
|
||||||
});
|
|
||||||
return fn ? result.map(arr => fn(...arr)) : result;
|
|
||||||
};
|
};
|
||||||
module.exports = zipWith;
|
module.exports = zipWith;
|
||||||
Reference in New Issue
Block a user