Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

d3-interpolate

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-interpolate - npm Package Compare versions

Comparing version 0.6.0 to 0.7.0

2

build/bundle.js

@@ -1,1 +0,1 @@

var version = "0.6.0"; export * from "../index"; export {version};
var version = "0.7.0"; export * from "../index"; export {version};

@@ -178,17 +178,10 @@ (function (global, factory) {

var values = [
function(a, b) {
var t = typeof b, c;
return (t === "string" ? ((c = d3Color.color(b)) ? (b = c, rgb$1) : string)
: b instanceof d3Color.color ? rgb$1
: Array.isArray(b) ? array
: t === "object" && isNaN(b) ? object
: number)(a, b);
}
];
function value(a, b) {
var i = values.length, f;
while (--i >= 0 && !(f = values[i](a, b)));
return f;
var t = typeof b, c;
return b == null || t === "boolean" ? constant(b)
: (t === "number" ? number
: t === "string" ? ((c = d3Color.color(b)) ? (b = c, rgb$1) : string)
: b instanceof d3Color.color ? rgb$1
: Array.isArray(b) ? array
: object)(a, b);
}

@@ -245,4 +238,3 @@

cssNode.style.transform = value;
cssRoot.appendChild(cssNode);
value = cssView.getComputedStyle(cssNode, null).getPropertyValue("transform");
value = cssView.getComputedStyle(cssRoot.appendChild(cssNode), null).getPropertyValue("transform");
cssRoot.removeChild(cssNode);

@@ -499,7 +491,6 @@ var m = value.slice(7, -1).split(",");

var version = "0.6.0";
var version = "0.7.0";
exports.version = version;
exports.interpolate = value;
exports.interpolators = values;
exports.interpolateArray = array;

@@ -506,0 +497,0 @@ exports.interpolateNumber = number;

@@ -1,1 +0,1 @@

!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("d3-color")):"function"==typeof define&&define.amd?define(["exports","d3-color"],n):n(t.d3_interpolate=t.d3_interpolate||{},t.d3_color)}(this,function(t,n){"use strict";function r(t){return function(){return t}}function e(t,n){return function(r){return t+r*n}}function o(t,n,r){return t=Math.pow(t,r),n=Math.pow(n,r)-t,r=1/r,function(e){return Math.pow(t+e*n,r)}}function a(t,n){var o=n-t;return o?e(t,o>180||-180>o?o-360*Math.round(o/360):o):r(isNaN(t)?n:t)}function u(t){return 1===(t=+t)?i:function(n,e){return e-n?o(n,e,t):r(isNaN(n)?e:n)}}function i(t,n){var o=n-t;return o?e(t,o):r(isNaN(t)?n:t)}function l(t,n){var r,e=[],o=[],a=t?t.length:0,u=n?n.length:0,i=Math.min(a,u);for(r=0;i>r;++r)e.push(d(t[r],n[r]));for(;a>r;++r)o[r]=t[r];for(;u>r;++r)o[r]=n[r];return function(t){for(r=0;i>r;++r)o[r]=e[r](t);return o}}function c(t,n){return t=+t,n-=t,function(r){return t+n*r}}function s(t,n){var r,e={},o={};null!==t&&"object"==typeof t||(t={}),null!==n&&"object"==typeof n||(n={});for(r in t)r in n?e[r]=d(t[r],n[r]):o[r]=t[r];for(r in n)r in t||(o[r]=n[r]);return function(t){for(r in e)o[r]=e[r](t);return o}}function f(t){return function(){return t}}function p(t){return function(n){return t(n)+""}}function h(t,n){var r,e,o,a=H.lastIndex=L.lastIndex=0,u=-1,i=[],l=[];for(t+="",n+="";(r=H.exec(t))&&(e=L.exec(n));)(o=e.index)>a&&(o=n.slice(a,o),i[u]?i[u]+=o:i[++u]=o),(r=r[0])===(e=e[0])?i[u]?i[u]+=e:i[++u]=e:(i[++u]=null,l.push({i:u,x:c(r,e)})),a=L.lastIndex;return a<n.length&&(o=n.slice(a),i[u]?i[u]+=o:i[++u]=o),i.length<2?l[0]?p(l[0].x):f(n):(n=l.length,function(t){for(var r,e=0;n>e;++e)i[(r=l[e]).i]=r.x(t);return i.join("")})}function d(t,n){for(var r,e=R.length;--e>=0&&!(r=R[e](t,n)););return r}function y(t,n){return t=+t,n-=t,function(r){return Math.round(t+n*r)}}function g(t,n,r,e,o,a){if(t*e===n*r)return null;var u=Math.sqrt(t*t+n*n);t/=u,n/=u;var i=t*r+n*e;r-=t*i,e-=n*i;var l=Math.sqrt(r*r+e*e);return r/=l,e/=l,i/=l,n*r>t*e&&(t=-t,n=-n,i=-i,u=-u),{translateX:o,translateY:a,rotate:Math.atan2(n,t)*V,skewX:Math.atan(i)*V,scaleX:u,scaleY:l}}function v(t){if("none"===t)return T;C||(C=document.createElement("DIV"),E=document.documentElement,I=document.defaultView),C.style.transform=t,E.appendChild(C),t=I.getComputedStyle(C,null).getPropertyValue("transform"),E.removeChild(C);var n=t.slice(7,-1).split(",");return g(+n[0],+n[1],+n[2],+n[3],+n[4],+n[5])}function x(t){S||(S=document.createElementNS("http://www.w3.org/2000/svg","g")),S.setAttribute("transform",null==t?"":t);var n=S.transform.baseVal.consolidate().matrix;return g(n.a,n.b,n.c,n.d,n.e,n.f)}function m(t,n,r,e){function o(t){return t.length?t.pop()+" ":""}function a(t,e,o,a,u,i){if(t!==o||e!==a){var l=u.push("translate(",null,n,null,r);i.push({i:l-4,x:c(t,o)},{i:l-2,x:c(e,a)})}else(o||a)&&u.push("translate("+o+n+a+r)}function u(t,n,r,a){t!==n?(t-n>180?n+=360:n-t>180&&(t+=360),a.push({i:r.push(o(r)+"rotate(",null,e)-2,x:c(t,n)})):n&&r.push(o(r)+"rotate("+n+e)}function i(t,n,r,a){t!==n?a.push({i:r.push(o(r)+"skewX(",null,e)-2,x:c(t,n)}):n&&r.push(o(r)+"skewX("+n+e)}function l(t,n,r,e,a,u){if(t!==r||n!==e){var i=a.push(o(a)+"scale(",null,",",null,")");u.push({i:i-4,x:c(t,r)},{i:i-2,x:c(n,e)})}else 1===r&&1===e||a.push(o(a)+"scale("+r+","+e+")")}return function(n,r){var e=[],o=[];return n=t(n),r=t(r),a(n.translateX,n.translateY,r.translateX,r.translateY,e,o),u(n.rotate,r.rotate,e,o),i(n.skewX,r.skewX,e,o),l(n.scaleX,n.scaleY,r.scaleX,r.scaleY,e,o),n=r=null,function(t){for(var n,r=-1,a=o.length;++r<a;)e[(n=o[r]).i]=n.x(t);return e.join("")}}}function b(t){return((t=Math.exp(t))+1/t)/2}function M(t){return((t=Math.exp(t))-1/t)/2}function w(t){return((t=Math.exp(2*t))-1)/(t+1)}function X(t,n){var r,e,o=t[0],a=t[1],u=t[2],i=n[0],l=n[1],c=n[2],s=i-o,f=l-a,p=s*s+f*f;if(Z>p)e=Math.log(c/u)/D,r=function(t){return[o+t*s,a+t*f,u*Math.exp(D*t*e)]};else{var h=Math.sqrt(p),d=(c*c-u*u+Q*p)/(2*u*O*h),y=(c*c-u*u-Q*p)/(2*c*O*h),g=Math.log(Math.sqrt(d*d+1)-d),v=Math.log(Math.sqrt(y*y+1)-y);e=(v-g)/D,r=function(t){var n=t*e,r=b(g),i=u/(O*h)*(r*w(D*n+g)-M(g));return[o+i*s,a+i*f,u*r/b(D*n+g)]}}return r.duration=1e3*e,r}function N(t,r){var e=a((t=n.hsl(t)).h,(r=n.hsl(r)).h),o=i(t.s,r.s),u=i(t.l,r.l),l=i(t.opacity,r.opacity);return function(n){return t.h=e(n),t.s=o(n),t.l=u(n),t.opacity=l(n),t+""}}function Y(t,r){var e=i((t=n.hsl(t)).h,(r=n.hsl(r)).h),o=i(t.s,r.s),a=i(t.l,r.l),u=i(t.opacity,r.opacity);return function(n){return t.h=e(n),t.s=o(n),t.l=a(n),t.opacity=u(n),t+""}}function j(t,r){var e=i((t=n.lab(t)).l,(r=n.lab(r)).l),o=i(t.a,r.a),a=i(t.b,r.b),u=i(t.opacity,r.opacity);return function(n){return t.l=e(n),t.a=o(n),t.b=a(n),t.opacity=u(n),t+""}}function k(t,r){var e=a((t=n.hcl(t)).h,(r=n.hcl(r)).h),o=i(t.c,r.c),u=i(t.l,r.l),l=i(t.opacity,r.opacity);return function(n){return t.h=e(n),t.c=o(n),t.l=u(n),t.opacity=l(n),t+""}}function q(t,r){var e=i((t=n.hcl(t)).h,(r=n.hcl(r)).h),o=i(t.c,r.c),a=i(t.l,r.l),u=i(t.opacity,r.opacity);return function(n){return t.h=e(n),t.c=o(n),t.l=a(n),t.opacity=u(n),t+""}}var C,E,I,S,A=function G(t){function r(t,r){var o=e((t=n.rgb(t)).r,(r=n.rgb(r)).r),a=e(t.g,r.g),u=e(t.b,r.b),i=e(t.opacity,r.opacity);return function(n){return t.r=o(n),t.g=a(n),t.b=u(n),t.opacity=i(n),t+""}}var e=u(t);return r.gamma=G,r}(1),H=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,L=new RegExp(H.source,"g"),R=[function(t,r){var e,o=typeof r;return("string"===o?(e=n.color(r))?(r=e,A):h:r instanceof n.color?A:Array.isArray(r)?l:"object"===o&&isNaN(r)?s:c)(t,r)}],V=180/Math.PI,T={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1},_=m(v,"px, ","px)","deg)"),P=m(x,", ",")",")"),D=Math.SQRT2,O=2,Q=4,Z=1e-12,z=function J(t){function r(r,e){var o=a((r=n.cubehelix(r)).h,(e=n.cubehelix(e)).h),u=i(r.s,e.s),l=i(r.l,e.l),c=i(r.opacity,e.opacity);return function(n){return r.h=o(n),r.s=u(n),r.l=l(Math.pow(n,t)),r.opacity=c(n),r+""}}return t=+t,r.gamma=J,r}(1),B=function K(t){function r(r,e){var o=i((r=n.cubehelix(r)).h,(e=n.cubehelix(e)).h),a=i(r.s,e.s),u=i(r.l,e.l),l=i(r.opacity,e.opacity);return function(n){return r.h=o(n),r.s=a(n),r.l=u(Math.pow(n,t)),r.opacity=l(n),r+""}}return t=+t,r.gamma=K,r}(1),F="0.6.0";t.version=F,t.interpolate=d,t.interpolators=R,t.interpolateArray=l,t.interpolateNumber=c,t.interpolateObject=s,t.interpolateRound=y,t.interpolateString=h,t.interpolateTransformCss=_,t.interpolateTransformSvg=P,t.interpolateZoom=X,t.interpolateRgb=A,t.interpolateHsl=N,t.interpolateHslLong=Y,t.interpolateLab=j,t.interpolateHcl=k,t.interpolateHclLong=q,t.interpolateCubehelix=z,t.interpolateCubehelixLong=B});
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("d3-color")):"function"==typeof define&&define.amd?define(["exports","d3-color"],n):n(t.d3_interpolate=t.d3_interpolate||{},t.d3_color)}(this,function(t,n){"use strict";function r(t){return function(){return t}}function e(t,n){return function(r){return t+r*n}}function o(t,n,r){return t=Math.pow(t,r),n=Math.pow(n,r)-t,r=1/r,function(e){return Math.pow(t+e*n,r)}}function a(t,n){var o=n-t;return o?e(t,o>180||-180>o?o-360*Math.round(o/360):o):r(isNaN(t)?n:t)}function u(t){return 1===(t=+t)?i:function(n,e){return e-n?o(n,e,t):r(isNaN(n)?e:n)}}function i(t,n){var o=n-t;return o?e(t,o):r(isNaN(t)?n:t)}function l(t,n){var r,e=[],o=[],a=t?t.length:0,u=n?n.length:0,i=Math.min(a,u);for(r=0;i>r;++r)e.push(d(t[r],n[r]));for(;a>r;++r)o[r]=t[r];for(;u>r;++r)o[r]=n[r];return function(t){for(r=0;i>r;++r)o[r]=e[r](t);return o}}function c(t,n){return t=+t,n-=t,function(r){return t+n*r}}function s(t,n){var r,e={},o={};null!==t&&"object"==typeof t||(t={}),null!==n&&"object"==typeof n||(n={});for(r in t)r in n?e[r]=d(t[r],n[r]):o[r]=t[r];for(r in n)r in t||(o[r]=n[r]);return function(t){for(r in e)o[r]=e[r](t);return o}}function f(t){return function(){return t}}function p(t){return function(n){return t(n)+""}}function h(t,n){var r,e,o,a=H.lastIndex=L.lastIndex=0,u=-1,i=[],l=[];for(t+="",n+="";(r=H.exec(t))&&(e=L.exec(n));)(o=e.index)>a&&(o=n.slice(a,o),i[u]?i[u]+=o:i[++u]=o),(r=r[0])===(e=e[0])?i[u]?i[u]+=e:i[++u]=e:(i[++u]=null,l.push({i:u,x:c(r,e)})),a=L.lastIndex;return a<n.length&&(o=n.slice(a),i[u]?i[u]+=o:i[++u]=o),i.length<2?l[0]?p(l[0].x):f(n):(n=l.length,function(t){for(var r,e=0;n>e;++e)i[(r=l[e]).i]=r.x(t);return i.join("")})}function d(t,e){var o,a=typeof e;return null==e||"boolean"===a?r(e):("number"===a?c:"string"===a?(o=n.color(e))?(e=o,A):h:e instanceof n.color?A:Array.isArray(e)?l:s)(t,e)}function y(t,n){return t=+t,n-=t,function(r){return Math.round(t+n*r)}}function g(t,n,r,e,o,a){if(t*e===n*r)return null;var u=Math.sqrt(t*t+n*n);t/=u,n/=u;var i=t*r+n*e;r-=t*i,e-=n*i;var l=Math.sqrt(r*r+e*e);return r/=l,e/=l,i/=l,n*r>t*e&&(t=-t,n=-n,i=-i,u=-u),{translateX:o,translateY:a,rotate:Math.atan2(n,t)*R,skewX:Math.atan(i)*R,scaleX:u,scaleY:l}}function v(t){if("none"===t)return V;C||(C=document.createElement("DIV"),E=document.documentElement,I=document.defaultView),C.style.transform=t,t=I.getComputedStyle(E.appendChild(C),null).getPropertyValue("transform"),E.removeChild(C);var n=t.slice(7,-1).split(",");return g(+n[0],+n[1],+n[2],+n[3],+n[4],+n[5])}function x(t){S||(S=document.createElementNS("http://www.w3.org/2000/svg","g")),S.setAttribute("transform",null==t?"":t);var n=S.transform.baseVal.consolidate().matrix;return g(n.a,n.b,n.c,n.d,n.e,n.f)}function m(t,n,r,e){function o(t){return t.length?t.pop()+" ":""}function a(t,e,o,a,u,i){if(t!==o||e!==a){var l=u.push("translate(",null,n,null,r);i.push({i:l-4,x:c(t,o)},{i:l-2,x:c(e,a)})}else(o||a)&&u.push("translate("+o+n+a+r)}function u(t,n,r,a){t!==n?(t-n>180?n+=360:n-t>180&&(t+=360),a.push({i:r.push(o(r)+"rotate(",null,e)-2,x:c(t,n)})):n&&r.push(o(r)+"rotate("+n+e)}function i(t,n,r,a){t!==n?a.push({i:r.push(o(r)+"skewX(",null,e)-2,x:c(t,n)}):n&&r.push(o(r)+"skewX("+n+e)}function l(t,n,r,e,a,u){if(t!==r||n!==e){var i=a.push(o(a)+"scale(",null,",",null,")");u.push({i:i-4,x:c(t,r)},{i:i-2,x:c(n,e)})}else 1===r&&1===e||a.push(o(a)+"scale("+r+","+e+")")}return function(n,r){var e=[],o=[];return n=t(n),r=t(r),a(n.translateX,n.translateY,r.translateX,r.translateY,e,o),u(n.rotate,r.rotate,e,o),i(n.skewX,r.skewX,e,o),l(n.scaleX,n.scaleY,r.scaleX,r.scaleY,e,o),n=r=null,function(t){for(var n,r=-1,a=o.length;++r<a;)e[(n=o[r]).i]=n.x(t);return e.join("")}}}function b(t){return((t=Math.exp(t))+1/t)/2}function M(t){return((t=Math.exp(t))-1/t)/2}function w(t){return((t=Math.exp(2*t))-1)/(t+1)}function X(t,n){var r,e,o=t[0],a=t[1],u=t[2],i=n[0],l=n[1],c=n[2],s=i-o,f=l-a,p=s*s+f*f;if(Q>p)e=Math.log(c/u)/P,r=function(t){return[o+t*s,a+t*f,u*Math.exp(P*t*e)]};else{var h=Math.sqrt(p),d=(c*c-u*u+O*p)/(2*u*D*h),y=(c*c-u*u-O*p)/(2*c*D*h),g=Math.log(Math.sqrt(d*d+1)-d),v=Math.log(Math.sqrt(y*y+1)-y);e=(v-g)/P,r=function(t){var n=t*e,r=b(g),i=u/(D*h)*(r*w(P*n+g)-M(g));return[o+i*s,a+i*f,u*r/b(P*n+g)]}}return r.duration=1e3*e,r}function N(t,r){var e=a((t=n.hsl(t)).h,(r=n.hsl(r)).h),o=i(t.s,r.s),u=i(t.l,r.l),l=i(t.opacity,r.opacity);return function(n){return t.h=e(n),t.s=o(n),t.l=u(n),t.opacity=l(n),t+""}}function Y(t,r){var e=i((t=n.hsl(t)).h,(r=n.hsl(r)).h),o=i(t.s,r.s),a=i(t.l,r.l),u=i(t.opacity,r.opacity);return function(n){return t.h=e(n),t.s=o(n),t.l=a(n),t.opacity=u(n),t+""}}function j(t,r){var e=i((t=n.lab(t)).l,(r=n.lab(r)).l),o=i(t.a,r.a),a=i(t.b,r.b),u=i(t.opacity,r.opacity);return function(n){return t.l=e(n),t.a=o(n),t.b=a(n),t.opacity=u(n),t+""}}function k(t,r){var e=a((t=n.hcl(t)).h,(r=n.hcl(r)).h),o=i(t.c,r.c),u=i(t.l,r.l),l=i(t.opacity,r.opacity);return function(n){return t.h=e(n),t.c=o(n),t.l=u(n),t.opacity=l(n),t+""}}function q(t,r){var e=i((t=n.hcl(t)).h,(r=n.hcl(r)).h),o=i(t.c,r.c),a=i(t.l,r.l),u=i(t.opacity,r.opacity);return function(n){return t.h=e(n),t.c=o(n),t.l=a(n),t.opacity=u(n),t+""}}var C,E,I,S,A=function F(t){function r(t,r){var o=e((t=n.rgb(t)).r,(r=n.rgb(r)).r),a=e(t.g,r.g),u=e(t.b,r.b),i=e(t.opacity,r.opacity);return function(n){return t.r=o(n),t.g=a(n),t.b=u(n),t.opacity=i(n),t+""}}var e=u(t);return r.gamma=F,r}(1),H=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,L=new RegExp(H.source,"g"),R=180/Math.PI,V={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1},T=m(v,"px, ","px)","deg)"),_=m(x,", ",")",")"),P=Math.SQRT2,D=2,O=4,Q=1e-12,Z=function G(t){function r(r,e){var o=a((r=n.cubehelix(r)).h,(e=n.cubehelix(e)).h),u=i(r.s,e.s),l=i(r.l,e.l),c=i(r.opacity,e.opacity);return function(n){return r.h=o(n),r.s=u(n),r.l=l(Math.pow(n,t)),r.opacity=c(n),r+""}}return t=+t,r.gamma=G,r}(1),z=function J(t){function r(r,e){var o=i((r=n.cubehelix(r)).h,(e=n.cubehelix(e)).h),a=i(r.s,e.s),u=i(r.l,e.l),l=i(r.opacity,e.opacity);return function(n){return r.h=o(n),r.s=a(n),r.l=u(Math.pow(n,t)),r.opacity=l(n),r+""}}return t=+t,r.gamma=J,r}(1),B="0.7.0";t.version=B,t.interpolate=d,t.interpolateArray=l,t.interpolateNumber=c,t.interpolateObject=s,t.interpolateRound=y,t.interpolateString=h,t.interpolateTransformCss=T,t.interpolateTransformSvg=_,t.interpolateZoom=X,t.interpolateRgb=A,t.interpolateHsl=N,t.interpolateHslLong=Y,t.interpolateLab=j,t.interpolateHcl=k,t.interpolateHclLong=q,t.interpolateCubehelix=Z,t.interpolateCubehelixLong=z});
export {default as interpolate} from "./src/value";
export {default as interpolators} from "./src/values";
export {default as interpolateArray} from "./src/array";

@@ -4,0 +3,0 @@ export {default as interpolateNumber} from "./src/number";

{
"name": "d3-interpolate",
"version": "0.6.0",
"version": "0.7.0",
"description": "Interpolate numbers, colors, strings, arrays, objects, whatever!",

@@ -27,3 +27,3 @@ "keywords": [

"prepublish": "npm run test && uglifyjs build/d3-interpolate.js -c -m -o build/d3-interpolate.min.js && rm -f build/d3-interpolate.zip && zip -j build/d3-interpolate.zip -- LICENSE README.md build/d3-interpolate.js build/d3-interpolate.min.js",
"postpublish": "VERSION=`node -e 'console.log(require(\"./package.json\").version)'`; git push && git push --tags && cp build/d3-interpolate.js ../d3.github.com/d3-interpolate.v0.6.js && cp build/d3-interpolate.min.js ../d3.github.com/d3-interpolate.v0.6.min.js && cd ../d3.github.com && git add d3-interpolate.v0.6.js d3-interpolate.v0.6.min.js && git commit -m \"d3-interpolate ${VERSION}\" && git push"
"postpublish": "VERSION=`node -e 'console.log(require(\"./package.json\").version)'`; git push && git push --tags && cp build/d3-interpolate.js ../d3.github.com/d3-interpolate.v0.7.js && cp build/d3-interpolate.min.js ../d3.github.com/d3-interpolate.v0.7.min.js && cd ../d3.github.com && git add d3-interpolate.v0.7.js d3-interpolate.v0.7.min.js && git commit -m \"d3-interpolate ${VERSION}\" && git push"
},

@@ -30,0 +30,0 @@ "dependencies": {

@@ -34,7 +34,7 @@ # d3-interpolate

If you use NPM, `npm install d3-interpolate`. Otherwise, download the [latest release](https://github.com/d3/d3-interpolate/releases/latest). You can also load directly from [d3js.org](https://d3js.org), either as a [standalone library](https://d3js.org/d3-interpolate.v0.6.min.js) or as part of [D3 4.0 alpha](https://github.com/mbostock/d3/tree/4). AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3_interpolate` global is exported:
If you use NPM, `npm install d3-interpolate`. Otherwise, download the [latest release](https://github.com/d3/d3-interpolate/releases/latest). You can also load directly from [d3js.org](https://d3js.org), either as a [standalone library](https://d3js.org/d3-interpolate.v0.7.min.js) or as part of [D3 4.0 alpha](https://github.com/mbostock/d3/tree/4). AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3_interpolate` global is exported:
```html
<script src="https://d3js.org/d3-color.v0.4.min.js"></script>
<script src="https://d3js.org/d3-interpolate.v0.6.min.js"></script>
<script src="https://d3js.org/d3-interpolate.v0.7.min.js"></script>
<script>

@@ -55,9 +55,10 @@

1. If *b* is a [color](https://github.com/d3/d3-color#color), [interpolateRgb](#interpolateRgb) is used.
2. If *b* is a string, [interpolateString](#interpolateString) is used.
3. If *b* is an array, [interpolateArray](#interpolateArray) is used.
4. If *b* is an object and not coercible to a number, [interpolateObject](#interpolateObject) is used.
5. Otherwise, [interpolateNumber](#interpolateNumber) is used.
1. If *b* is null, undefined or a boolean, use the constant *b*.
2. If *b* is a number, use [interpolateNumber](#interpolateNumber).
3. If *b* is a [color](https://github.com/d3/d3-color#color) or a string coercible to a color, use [interpolateRgb](#interpolateRgb).
4. If *b* is a string, use [interpolateString](#interpolateString).
5. If *b* is an [array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray), use [interpolateArray](#interpolateArray).
6. Use [interpolateObject](#interpolateObject).
Based on the chosen interpolator, *a* is coerced to a suitable corresponding type. The behavior of this method may be augmented to support additional types by pushing custom interpolator factories onto the [interpolators](#interpolators) array.
Based on the chosen interpolator, *a* is coerced to the suitable corresponding type.

@@ -76,23 +77,2 @@ <a name="interpolateNumber" href="#interpolateNumber">#</a> d3.<b>interpolateNumber</b>(<i>a</i>, <i>b</i>)

<a name="interpolators" href="#interpolators">#</a> d3.<b>interpolators</b>
The array of built-in interpolator factories, as used by [interpolate](#interpolate). Additional interpolator factories may be pushed onto the end of this array. Each factory should return an interpolator if it supports interpolating the two specified input values; otherwise, the factory should return a falsey value and other interpolators will be tried.
For example, to register a custom interpolator that formats dollars and cents, you might say:
```js
d3.interpolators.push(function(a, b) {
var re = /^\$([0-9,.]+)$/, ma, mb, f = d3.format(",.02f");
if ((ma = re.exec(a)) && (mb = re.exec(b))) {
a = parseFloat(ma[1]);
b = parseFloat(mb[1]) - a;
return function(t) {
return "$" + f(a + b * t);
};
}
});
```
Subsequently, `d3.interpolate("$20", "$10")(1/3)` returns `$16.67`.
<a name="interpolateRound" href="#interpolateRound">#</a> d3.<b>interpolateRound</b>(<i>a</i>, <i>b</i>)

@@ -99,0 +79,0 @@

@@ -12,4 +12,3 @@ import decompose, {identity} from "./decompose";

cssNode.style.transform = value;
cssRoot.appendChild(cssNode);
value = cssView.getComputedStyle(cssNode, null).getPropertyValue("transform");
value = cssView.getComputedStyle(cssRoot.appendChild(cssNode), null).getPropertyValue("transform");
cssRoot.removeChild(cssNode);

@@ -16,0 +15,0 @@ var m = value.slice(7, -1).split(",");

@@ -1,7 +0,17 @@

import values from "./values";
import {color} from "d3-color";
import rgb from "./rgb";
import array from "./array";
import number from "./number";
import object from "./object";
import string from "./string";
import constant from "./constant";
export default function(a, b) {
var i = values.length, f;
while (--i >= 0 && !(f = values[i](a, b)));
return f;
var t = typeof b, c;
return b == null || t === "boolean" ? constant(b)
: (t === "number" ? number
: t === "string" ? ((c = color(b)) ? (b = c, rgb) : string)
: b instanceof color ? rgb
: Array.isArray(b) ? array
: object)(a, b);
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc