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
|
||||
> 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
|
||||
✔ Reorders arguments in invoked function
|
||||
|
||||
Testing recordAnimationFrames
|
||||
|
||||
✔ recordAnimationFrames is a Function
|
||||
|
||||
Testing redirect
|
||||
|
||||
✔ 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
|
||||
|
||||
|
||||
total: 988
|
||||
passing: 986
|
||||
total: 989
|
||||
passing: 987
|
||||
failing: 2
|
||||
duration: 2.6s
|
||||
duration: 2.4s
|
||||
|
||||
|
||||
undefined
|
||||
@ -1,11 +1,8 @@
|
||||
const zipWith = (...arrays) => {
|
||||
const length = arrays.length;
|
||||
let fn = length > 1 ? arrays[length - 1] : undefined;
|
||||
fn = typeof fn == 'function' ? (arrays.pop(), fn) : undefined;
|
||||
const maxLength = Math.max(...arrays.map(x => x.length));
|
||||
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;
|
||||
const zipWith = (...array) => {
|
||||
const fn = typeof array[array.length - 1] === 'function' ? array.pop() : undefined;
|
||||
return Array.from(
|
||||
{ length: Math.max(...array.map(a => a.length)) },
|
||||
(_, i) => (fn ? fn(...array.map(a => a[i])) : array.map(a => a[i]))
|
||||
);
|
||||
};
|
||||
module.exports = zipWith;
|
||||
Reference in New Issue
Block a user