From df8daefcabbadddaa76fb3a884932308df231655 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Rivi=C3=A8re?= Date: Tue, 19 Nov 2019 21:55:31 +0100 Subject: [PATCH] style --- src/array.js | 2 +- src/value.js | 2 +- test/numberArray-test.js | 23 +++++++++++++++-------- test/value-test.js | 16 ++++++++-------- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/array.js b/src/array.js index 719b360..08e35d9 100644 --- a/src/array.js +++ b/src/array.js @@ -1,5 +1,5 @@ import value from "./value.js"; -import {default as numberArray, isNumberArray} from "./numberArray.js"; +import numberArray, {isNumberArray} from "./numberArray.js"; export default function(a, b) { if (isNumberArray(b)) return numberArray(a, b); diff --git a/src/value.js b/src/value.js index 79327ff..4a3ccee 100644 --- a/src/value.js +++ b/src/value.js @@ -6,7 +6,7 @@ import number from "./number.js"; import object from "./object.js"; import string from "./string.js"; import constant from "./constant.js"; -import {default as numberArray, isNumberArray} from "./numberArray.js"; +import numberArray, {isNumberArray} from "./numberArray.js"; export default function(a, b) { var t = typeof b, c; diff --git a/test/numberArray-test.js b/test/numberArray-test.js index ffa51a1..b749c0b 100644 --- a/test/numberArray-test.js +++ b/test/numberArray-test.js @@ -2,17 +2,17 @@ var tape = require("tape"), interpolate = require("../"); tape("interpolateNumberArray(a, b) interpolates defined elements in a and b", function(test) { - test.deepEqual(interpolate.interpolateNumberArray(Float64Array.from([2, 12]), Float64Array.from([4, 24]))(0.5), Float64Array.from([3, 18])); + test.deepEqual(interpolate.interpolateNumberArray(Float64Array.of(2, 12), Float64Array.of(4, 24))(0.5), Float64Array.of(3, 18)); test.end(); }); tape("interpolateNumberArray(a, b) ignores elements in a that are not in b", function(test) { - test.deepEqual(interpolate.interpolateNumberArray(Float64Array.from([2, 12, 12]), Float64Array.from([4, 24]))(0.5), Float64Array.from([3, 18])); + test.deepEqual(interpolate.interpolateNumberArray(Float64Array.of(2, 12, 12), Float64Array.of(4, 24))(0.5), Float64Array.of(3, 18)); test.end(); }); tape("interpolateNumberArray(a, b) uses constant elements in b that are not in a", function(test) { - test.deepEqual(interpolate.interpolateNumberArray(Float64Array.from([2, 12]), Float64Array.from([4, 24, 12]))(0.5), Float64Array.from([3, 18, 12])); + test.deepEqual(interpolate.interpolateNumberArray(Float64Array.of(2, 12), Float64Array.of(4, 24, 12))(0.5), Float64Array.of(3, 18, 12)); test.end(); }); @@ -24,14 +24,21 @@ tape("interpolateNumberArray(a, b) treats undefined as an empty array", function }); tape("interpolateNumberArray(a, b) uses b’s array type", function(test) { - test.ok(interpolate.interpolateNumberArray(Float64Array.from([2, 12]), Float64Array.from([4, 24, 12]))(0.5) instanceof Float64Array); - test.ok(interpolate.interpolateNumberArray(Float64Array.from([2, 12]), Float32Array.from([4, 24, 12]))(0.5) instanceof Float32Array); - test.ok(interpolate.interpolateNumberArray(Float64Array.from([2, 12]), Uint8Array.from([4, 24, 12]))(0.5) instanceof Uint8Array); - test.ok(interpolate.interpolateNumberArray(Float64Array.from([2, 12]), Uint16Array.from([4, 24, 12]))(0.5) instanceof Uint16Array); + test.ok(interpolate.interpolateNumberArray(Float64Array.of(2, 12), Float64Array.of(4, 24, 12))(0.5) instanceof Float64Array); + test.ok(interpolate.interpolateNumberArray(Float64Array.of(2, 12), Float32Array.of(4, 24, 12))(0.5) instanceof Float32Array); + test.ok(interpolate.interpolateNumberArray(Float64Array.of(2, 12), Uint8Array.of(4, 24, 12))(0.5) instanceof Uint8Array); + test.ok(interpolate.interpolateNumberArray(Float64Array.of(2, 12), Uint16Array.of(4, 24, 12))(0.5) instanceof Uint16Array); test.end(); }); tape("interpolateNumberArray(a, b) works with unsigned data", function(test) { - test.deepEqual(interpolate.interpolateNumberArray(Uint8Array.from([1, 12]), Uint8Array.from([255, 0]))(0.5), Uint8Array.from([128, 6])); + test.deepEqual(interpolate.interpolateNumberArray(Uint8Array.of(1, 12), Uint8Array.of(255, 0))(0.5), Uint8Array.of(128, 6)); + test.end(); +}); + +tape("interpolateNumberArray(a, b) gives exact ends", function(test) { + var i = interpolate.interpolateNumberArray(Float64Array.of(2e42), Float64Array.of(355)); + test.deepEqual(i(0), Float64Array.of(2e42)); + test.deepEqual(i(1), Float64Array.of(355)); test.end(); }); \ No newline at end of file diff --git a/test/value-test.js b/test/value-test.js index d23e649..752b054 100644 --- a/test/value-test.js +++ b/test/value-test.js @@ -116,14 +116,14 @@ tape("interpolate(a, b) interpolates objects with toString as objects if toStrin }); tape("interpolate(a, b) interpolates number arrays if b is a typed array", function(test) { - test.deepEqual(interpolate.interpolate([0, 0], Float64Array.from([-1, 1]))(0.5), Float64Array.from([-0.5, 0.5])); - test.assert(interpolate.interpolate([0, 0], Float64Array.from([-1, 1]))(0.5) instanceof Float64Array); - test.deepEqual(interpolate.interpolate([0, 0], Float32Array.from([-1, 1]))(0.5), Float32Array.from([-0.5, 0.5])); - test.assert(interpolate.interpolate([0, 0], Float32Array.from([-1, 1]))(0.5) instanceof Float32Array); - test.deepEqual(interpolate.interpolate([0, 0], Uint32Array.from([-2, 2]))(0.5), Uint32Array.from([Math.pow(2, 31) - 1, 1])); - test.assert(interpolate.interpolate([0, 0], Uint32Array.from([-1, 1]))(0.5) instanceof Uint32Array); - test.deepEqual(interpolate.interpolate([0, 0], Uint8Array.from([-2, 2]))(0.5), Uint8Array.from([Math.pow(2, 7) - 1, 1])); - test.assert(interpolate.interpolate([0, 0], Uint8Array.from([-1, 1]))(0.5) instanceof Uint8Array); + test.deepEqual(interpolate.interpolate([0, 0], Float64Array.of(-1, 1))(0.5), Float64Array.of(-0.5, 0.5)); + test.assert(interpolate.interpolate([0, 0], Float64Array.of(-1, 1))(0.5) instanceof Float64Array); + test.deepEqual(interpolate.interpolate([0, 0], Float32Array.of(-1, 1))(0.5), Float32Array.of(-0.5, 0.5)); + test.assert(interpolate.interpolate([0, 0], Float32Array.of(-1, 1))(0.5) instanceof Float32Array); + test.deepEqual(interpolate.interpolate([0, 0], Uint32Array.of(-2, 2))(0.5), Uint32Array.of(Math.pow(2, 31) - 1, 1)); + test.assert(interpolate.interpolate([0, 0], Uint32Array.of(-1, 1))(0.5) instanceof Uint32Array); + test.deepEqual(interpolate.interpolate([0, 0], Uint8Array.of(-2, 2))(0.5), Uint8Array.of(Math.pow(2, 7) - 1, 1)); + test.assert(interpolate.interpolate([0, 0], Uint8Array.of(-1, 1))(0.5) instanceof Uint8Array); test.end(); });