New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

linear-tick

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

linear-tick - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

4

dist/index.js

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

function V(e,t){const{density:i}=t,n=e-t.value;return[n*t.directionX/i+t.anchorX*t.width,n*t.directionY/i+t.anchorY*t.height]}function p(e){if(e.density<e.minDensity)e.density=e.minDensity;else if(e.density>e.maxDensity)e.density=e.maxDensity}function P(e,t,i,n){const a=e.filter(({maxDensityToShow:r})=>r===void 0?!0:r>=t).map((r)=>[r,M(r,i)]).filter(({1:r})=>r<n),o=new Set;for(let r=a.length-1;r>=0;--r){const{0:{shy:d=!1,multiply:l},1:c}=a[r],h=[];if(r)for(let s=c;s<n;s+=l){if(d&&o.has(s))continue;h.push(s),o.add(s)}else for(let s=c+l;s<n;s+=l)if(!d||!o.has(s))h.push(s);a[r][1]=h}return a}function y(e){return Math.abs(e)<=Number.EPSILON}function x(e,t,i,n,a,o){return Math.min(y(i)?1/0:(i>0?a-e:-e)/i,y(n)?1/0:(n>0?o-t:-t)/n)}function X(e,t,i,n){const a=i+e*t;return n===void 0?a:Math.max(n,a)}function Y(e,t,i,n){const a=i+e*t;return n===void 0?a:Math.min(n+1,a)}function M({multiply:e,zeroOffset:t=0},i){return Math.ceil((i-t)/e)*e+t}var C;((n)=>{n[n.DoNothing=0]="DoNothing";n[n.Draw=1]="Draw";n[n.DrawNextFrame=2]="DrawNextFrame"})(C||={});class D{static defaultParams={value:0,redundancy:1,anchorX:0,anchorY:0,directionX:1,directionY:0,density:0.1,minDensity:0.02,maxDensity:100,width:100,height:20};#n;#e;#t=new ResizeObserver(()=>{const e=this.#e;if(!e)return;const t=this.params.pixelRatio??window.devicePixelRatio,{offsetWidth:i,offsetHeight:n}=e,a=this.params.width=i*t,o=this.params.height=n*t,r=this.canvas;if(!r)return;if(r.width=a,r.height=o,r.style.width=`${i}px`,r.style.height=`${n}px`,this.whenResized===1)this.draw();else if(this.whenResized===2)this.drawNextFrame=!0});initStore;initDraw;finalDraw;canvas;params;ticks;whenResized=0;constructor(e,t){const{defaultParams:i}=D;this.params=t?Object.assign({},i,t):{...i},this.ticks=e??[]}get keepSameSizeWith(){return this.#e}set keepSameSizeWith(e){if(this.#e===e)return;if(this.#e)this.#t.unobserve(this.#e);if(this.#e=e,e)this.#t.observe(e)}get drawNextFrame(){return this.#n!==void 0}set drawNextFrame(e){if(e===this.drawNextFrame)return;if(this.#n)cancelAnimationFrame(this.#n),this.#n=void 0;else this.#n=requestAnimationFrame(()=>this.draw())}draw(){this.drawNextFrame=!1;const{params:e,canvas:t}=this;if(p(e),!t)return;const i=t.getContext("2d");if(!i)throw new Error("Failed to get 2d context");const{directionX:n,directionY:a,value:o,redundancy:r,width:d,height:l,density:c}=e,h=e.anchorX*d,s=e.anchorY*l,R=-x(h,s,-n,-a,d,l)-r,S=x(h,s,n,a,d,l)+r,T=X(R,c,o,e.min),w=Y(S,c,o,e.max),m=this.initStore?.()??{},u={x:0,y:0,value:0,firstValue:T,lastValue:w};if(this.initDraw?.(i,m,u,e)===null)return;const v=n/c,E=a/c,{ticks:k}=this;for(let{0:{drawCall:f},1:O}of P(k,c,T,w))for(let{init:g,each:L,final:F}of Array.isArray(f)?f:[f]){if(g?.(i,m,u,e)===null)continue;for(let N of O){const b=(u.value=N)-o;u.x=b*v+h,u.y=b*E+s,L(i,m,u,e)}F?.(i,m,u,e)}this.finalDraw?.(i,m,u,e)}}export{V as valueToCoord,C as WhenResized,D as LinearTick};
var C;((t)=>{t[t.DoNothing=0]="DoNothing";t[t.Draw=1]="Draw";t[t.DrawNextFrame=2]="DrawNextFrame"})(C||={});function V(e,n){let{density:i}=n,t=e-n.value;return[t*n.directionX/i+n.anchorX*n.width,t*n.directionY/i+n.anchorY*n.height]}class S{static defaultParams={value:0,redundancy:1,anchorX:0,anchorY:0,directionX:1,directionY:0,density:0.1,minDensity:0.02,maxDensity:100,width:100,height:20};#n;#e;#t=new ResizeObserver(()=>{let e=this.#e;if(!e)return;let n=this.params.pixelRatio??window.devicePixelRatio,{offsetWidth:i,offsetHeight:t}=e,a=this.params.width=i*n,s=this.params.height=t*n,r=this.canvas;if(!r)return;if(r.width=a,r.height=s,r.style.width=`${i}px`,r.style.height=`${t}px`,this.whenResized===1)this.draw();else if(this.whenResized===2)this.drawNextFrame=!0});initStore;initDraw;finalDraw;canvas;params;ticks;whenResized=0;constructor(e,n){let{defaultParams:i}=S;this.params=n?Object.assign({},i,n):{...i},this.ticks=e??[]}get keepSameSizeWith(){return this.#e}set keepSameSizeWith(e){if(this.#e===e)return;if(this.#e)this.#t.unobserve(this.#e);if(this.#e=e,e)this.#t.observe(e)}get drawNextFrame(){return this.#n!==void 0}set drawNextFrame(e){if(e===this.drawNextFrame)return;if(this.#n)cancelAnimationFrame(this.#n),this.#n=void 0;else this.#n=requestAnimationFrame(()=>this.draw())}draw(){this.drawNextFrame=!1;let{params:e,canvas:n}=this;if(p(e),!n)return;let i=n.getContext("2d");if(!i)throw new Error("Failed to get 2d context");let{directionX:t,directionY:a,value:s,redundancy:r,width:m,height:h,density:o}=e,f=e.anchorX*m,d=e.anchorY*h,c=-R(f,d,-t,-a,m,h)-r,u=R(f,d,t,a,m,h)+r,b=X(c,o,s,e.min),y=Y(u,o,s,e.max),T=this.initStore?.()??{},l={x:0,y:0,value:0,firstValue:b,lastValue:y};if(this.initDraw?.(i,T,l,e)===null)return;let v=t/o,E=a/o,{ticks:k}=this;for(let{0:{drawCall:w},1:O}of P(k,o,b,y))for(let{init:g,each:L,final:F}of Array.isArray(w)?w:[w]){if(g?.(i,T,l,e)===null)continue;for(let N of O){let x=(l.value=N)-s;l.x=x*v+f,l.y=x*E+d,L(i,T,l,e)}F?.(i,T,l,e)}this.finalDraw?.(i,T,l,e)}}function p(e){if(e.density<e.minDensity)e.density=e.minDensity;else if(e.density>e.maxDensity)e.density=e.maxDensity}function P(e,n,i,t){let a=e.filter(({maxDensityToShow:r})=>r===void 0?!0:r>=n).map((r)=>[r,M(r,i)]).filter(({1:r})=>r<=t),s=new Set;for(let r=a.length-1;r>=0;--r){let{0:{shy:m=!1,multiply:h},1:o}=a[r],f=Math.floor((t-o)/h)+1,d=[];if(r)for(let c=0;c<f;++c){let u=o+c*h;if(m&&s.has(u))continue;d.push(u),s.add(u)}else for(let c=0;c<f;++c){let u=o+c*h;if(!m||!s.has(u))d.push(u)}a[r][1]=d}return a}function D(e){return Math.abs(e)<=Number.EPSILON}function R(e,n,i,t,a,s){return Math.min(D(i)?1/0:(i>0?a-e:-e)/i,D(t)?1/0:(t>0?s-n:-n)/t)}function X(e,n,i,t){let a=i+e*n;return t===void 0?a:Math.max(t,a)}function Y(e,n,i,t){let a=i+e*n;return t===void 0?a:Math.min(t,a)}function M({multiply:e,zeroOffset:n=0},i){return Math.ceil((i-n)/e)*e+n}export{V as valueToCoord,C as WhenResized,S as LinearTick};
//# debugId=ECAA05621B30AC2564756E2164756E21
//# debugId=F151A07CE72FC09264756E2164756E21
//# sourceMappingURL=index.js.map
{
"name": "linear-tick",
"version": "0.1.2",
"version": "0.1.3",
"author": "Wzh <wzh@uvwee.com>",

@@ -5,0 +5,0 @@ "repository": {

@@ -175,13 +175,17 @@ export interface LinearTickDrawState {

.map(t => [t, firstTickValue(t, firstValue)] as [LinearTickDefine<STORE>, any])
.filter(({ 1: firstTickValue }) => firstTickValue < lastValue)
.filter(({ 1: firstTickValue }) => firstTickValue <= lastValue)
const valuesDrawn = new Set()
for (let i = result.length - 1; i >= 0; --i) {
const { 0: { shy = false, multiply }, 1: firstTickValue } = result[i]
const steps = Math.floor((lastValue - firstTickValue) / multiply) + 1
const values = []
if (i) for (let v = firstTickValue; v < lastValue; v += multiply) {
if (i) for (let n = 0; n < steps; ++n) {
const v = firstTickValue + n * multiply
if (shy && valuesDrawn.has(v)) continue
values.push(v)
valuesDrawn.add(v)
} else for (let v = firstTickValue + multiply; v < lastValue; v += multiply)
} else for (let n = 0; n < steps; ++n) {
const v = firstTickValue + n * multiply
if (!shy || !valuesDrawn.has(v)) values.push(v)
}
result[i][1] = values

@@ -208,3 +212,3 @@ }

const v = anchorValue + endUnit * density
return max === undefined ? v : Math.min(max + 1, v)
return max === undefined ? v : Math.min(max, v)
}

@@ -211,0 +215,0 @@

Sorry, the diff of this file is not supported yet

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