-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Two
- Loading branch information
Showing
11 changed files
with
193 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1 @@ | ||
export default function(x) { | ||
return function() { | ||
return x; | ||
}; | ||
} | ||
export default x => () => x; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,26 @@ | ||
var tape = require("tape"); | ||
|
||
tape.Test.prototype.inDelta = function(actual, expected) { | ||
this._assert(expected - 1e-6 < actual && actual < expected + 1e-6, { | ||
message: "should be in delta", | ||
tape.Test.prototype.inDelta = function(actual, expected, delta) { | ||
delta = delta || 1e-6; | ||
this._assert(inDelta(actual, expected, delta), { | ||
message: "should be in delta " + delta, | ||
operator: "inDelta", | ||
actual: actual, | ||
expected: expected | ||
}); | ||
}; | ||
|
||
function inDelta(actual, expected, delta) { | ||
return (Array.isArray(expected) ? inDeltaArray : inDeltaNumber)(actual, expected, delta); | ||
} | ||
|
||
function inDeltaArray(actual, expected, delta) { | ||
var n = expected.length, i = -1; | ||
if (actual.length !== n) return false; | ||
while (++i < n) if (!inDelta(actual[i], expected[i], delta)) return false; | ||
return true; | ||
} | ||
|
||
function inDeltaNumber(actual, expected, delta) { | ||
return actual >= expected - delta && actual <= expected + delta; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
var tape = require("tape"), | ||
interpolate = require("../"); | ||
|
||
tape("piecewise(interpolate, values)(t) returns the expected values", function(test) { | ||
var i = interpolate.piecewise(interpolate.interpolate, [0,2,10]); | ||
test.strictEqual(i(-1), -4); | ||
test.strictEqual(i(0), 0); | ||
test.strictEqual(i(0.19), 0.76); | ||
test.strictEqual(i(0.21), 0.84); | ||
test.strictEqual(i(0.5), 2); | ||
test.strictEqual(i(0.75), 6); | ||
test.strictEqual(i(1), 10); | ||
test.end(); | ||
}); | ||
|
||
tape("piecewise(values) uses the default interpolator", function(test) { | ||
var i = interpolate.piecewise([0,2,10]); | ||
test.strictEqual(i(-1), -4); | ||
test.strictEqual(i(0), 0); | ||
test.strictEqual(i(0.19), 0.76); | ||
test.strictEqual(i(0.21), 0.84); | ||
test.strictEqual(i(0.5), 2); | ||
test.strictEqual(i(0.75), 6); | ||
test.strictEqual(i(1), 10); | ||
test.end(); | ||
}); | ||
|
||
tape("piecewise(values) uses the default interpolator/2", function(test) { | ||
var i = interpolate.piecewise(["a0","a2","a10"]); | ||
test.strictEqual(i(-1), "a-4"); | ||
test.strictEqual(i(0), "a0"); | ||
test.strictEqual(i(0.19), "a0.76"); | ||
test.strictEqual(i(0.21), "a0.84"); | ||
test.strictEqual(i(0.5), "a2"); | ||
test.strictEqual(i(0.75), "a6"); | ||
test.strictEqual(i(1), "a10"); | ||
test.end(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
var tape = require("tape"), | ||
interpolate = require("../"); | ||
|
||
/* | ||
// see https://github.com/d3/d3-interpolate/pull/83 | ||
// and https://github.com/Automattic/node-canvas/issues/1313 | ||
global.DOMMatrix = require("Canvas").DOMMatrix; | ||
tape("interpolateTransformCss(a, b) transforms as expected", function(test) { | ||
test.equal(interpolate.interpolateTransformCss( | ||
"translateY(12px) scale(2)", | ||
"translateX(3em) rotate(5deg)" | ||
)(0.5), "translate(24px, 6px) rotate(2.5deg) scale(1.5,1.5)"); | ||
test.deepEqual(interpolate.interpolateTransformCss( | ||
"matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0)", | ||
"translate(3px,90px)" | ||
)(0.5), "translate(4px, 48px) rotate(-58.282525588538995deg) skewX(-39.847576765616985deg) scale(-0.6180339887498949,0.9472135954999579)"); | ||
test.deepEqual(interpolate.interpolateTransformCss( | ||
"skewX(-60)", | ||
"skewX(60) translate(280,0)" | ||
)(0.5), "translate(140, 0) skewX(0)"); | ||
test.end(); | ||
}); | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters