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

@vueuse/math

Package Overview
Dependencies
Maintainers
3
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vueuse/math - npm Package Compare versions

Comparing version 9.0.2 to 9.1.0

25

index.d.ts

@@ -82,3 +82,18 @@ import { ComputedRef, Ref } from 'vue-demi';

interface UsePrecisionOptions {
/**
* Method to use for rounding
*
* @default 'round'
*/
math?: 'floor' | 'ceil' | 'round';
}
/**
* Reactively set the precision of a number.
*
* @see https://vueuse.org/usePrecision
*/
declare function usePrecision(value: MaybeComputedRef<number>, digits: MaybeComputedRef<number>, options?: MaybeComputedRef<UsePrecisionOptions>): ComputedRef<number | string>;
/**
* Reactive numeric projection from one domain to another.

@@ -100,7 +115,2 @@ *

/**
* Reactive `toFixed`
*
* @see https://vueuse.org/useToFixed
*/
interface FixedTypes {

@@ -110,2 +120,5 @@ type?: 'string' | 'number';

}
/**
* @deprecated use `usePrecision` instead
*/
declare function useToFixed(value: MaybeComputedRef<number | string>, digits: MaybeComputedRef<number>, options?: MaybeComputedRef<FixedTypes>): ComputedRef<number | string>;

@@ -120,2 +133,2 @@

export { FixedTypes, ProjectorFunction, UseMathKeys, UseProjection, logicAnd as and, createGenericProjection, createProjection, logicAnd, logicNot, logicOr, logicNot as not, logicOr as or, useAbs, useAverage, useCeil, useClamp, useFloor, useMath, useMax, useMin, useProjection, useRound, useSum, useToFixed, useTrunc };
export { FixedTypes, ProjectorFunction, UseMathKeys, UsePrecisionOptions, UseProjection, logicAnd as and, createGenericProjection, createProjection, logicAnd, logicNot, logicOr, logicNot as not, logicOr as or, useAbs, useAverage, useCeil, useClamp, useFloor, useMath, useMax, useMin, usePrecision, useProjection, useRound, useSum, useToFixed, useTrunc };

@@ -160,2 +160,12 @@ ;var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {

function usePrecision(value, digits, options) {
return vueDemi.computed(() => {
var _a;
const _value = shared.resolveUnref(value);
const _digits = shared.resolveUnref(digits);
const power = 10 ** _digits;
return Math[((_a = shared.resolveUnref(options)) == null ? void 0 : _a.math) || "round"](_value * power) / power;
});
}
function useProjection(input, fromDomain, toDomain, projector) {

@@ -202,2 +212,3 @@ return createProjection(fromDomain, toDomain, projector)(input);

exports.useMin = useMin;
exports.usePrecision = usePrecision;
exports.useProjection = useProjection;

@@ -204,0 +215,0 @@ exports.useRound = useRound;

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

var VueDemi=function(n,r,t){if(n.install)return n;if(r)if(r.version.slice(0,4)==="2.7."){for(var l in r)n[l]=r[l];n.isVue2=!0,n.isVue3=!1,n.install=function(){},n.Vue=r,n.Vue2=r,n.version=r.version}else if(r.version.slice(0,2)==="2.")if(t){for(var l in t)n[l]=t[l];n.isVue2=!0,n.isVue3=!1,n.install=function(){},n.Vue=r,n.Vue2=r,n.version=r.version}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(r.version.slice(0,2)==="3."){for(var l in r)n[l]=r[l];n.isVue2=!1,n.isVue3=!0,n.install=function(){},n.Vue=r,n.Vue2=void 0,n.version=r.version,n.set=function(f,i,s){return Array.isArray(f)?(f.length=Math.max(f.length,i),f.splice(i,1,s),s):(f[i]=s,s)},n.del=function(f,i){if(Array.isArray(f)){f.splice(i,1);return}delete f[i]}}else console.error("[vue-demi] Vue version "+r.version+" is unsupported.");else console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.");return n}(this.VueDemi=this.VueDemi||(typeof VueDemi!="undefined"?VueDemi:{}),this.Vue||(typeof Vue!="undefined"?Vue:void 0),this.VueCompositionAPI||(typeof VueCompositionAPI!="undefined"?VueCompositionAPI:void 0));(function(n,r,t){"use strict";function l(e,o,u){return c=>r.computed(()=>u(t.resolveUnref(c),t.resolveUnref(e),t.resolveUnref(o)))}const f=(e,o,u)=>(e-o[0])/(o[1]-o[0])*(u[1]-u[0])+u[0];function i(e,o,u=f){return l(e,o,u)}function s(...e){return r.computed(()=>e.every(o=>t.resolveUnref(o)))}function d(e){return r.computed(()=>!t.resolveUnref(e))}function M(...e){return r.computed(()=>e.some(o=>t.resolveUnref(o)))}function p(e){return r.computed(()=>Math.abs(t.resolveUnref(e)))}function v(e){return e.flatMap(o=>{const u=t.resolveUnref(o);return Array.isArray(u)?u.map(c=>t.resolveUnref(c)):[u]})}function A(...e){return r.computed(()=>{const o=v(e);return o.reduce((u,c)=>u+=c,0)/o.length})}function y(e){return r.computed(()=>Math.ceil(t.resolveUnref(e)))}function P(e,o,u){const c=r.ref(e);return r.computed({get(){return c.value=t.clamp(c.value,t.resolveUnref(o),t.resolveUnref(u))},set(a){c.value=t.clamp(a,t.resolveUnref(o),t.resolveUnref(u))}})}function b(e){return r.computed(()=>Math.floor(t.resolveUnref(e)))}function j(e,...o){return t.reactify(Math[e])(...o)}function F(...e){return r.computed(()=>{const o=v(e);return Math.max(...o)})}function C(...e){return r.computed(()=>{const o=v(e);return Math.min(...o)})}function g(e,o,u,c){return i(o,u,c)(e)}function _(e){return r.computed(()=>Math.round(t.resolveUnref(e)))}function T(...e){return r.computed(()=>v(e).reduce((o,u)=>o+=u,0))}function N(e,o,u){return r.computed(()=>{var c,a;const G=parseFloat(`${t.resolveUnref(e)}`),U=Math[((c=t.resolveUnref(u))==null?void 0:c.math)||"round"](G*10**t.resolveUnref(o))/10**t.resolveUnref(o);return((a=t.resolveUnref(u))==null?void 0:a.type)==="string"?t.resolveUnref(o)>=0?U.toFixed(t.resolveUnref(o)):`${U}`:U})}function O(e){return r.computed(()=>Math.trunc(t.resolveUnref(e)))}n.and=s,n.createGenericProjection=l,n.createProjection=i,n.logicAnd=s,n.logicNot=d,n.logicOr=M,n.not=d,n.or=M,n.useAbs=p,n.useAverage=A,n.useCeil=y,n.useClamp=P,n.useFloor=b,n.useMath=j,n.useMax=F,n.useMin=C,n.useProjection=g,n.useRound=_,n.useSum=T,n.useToFixed=N,n.useTrunc=O,Object.defineProperty(n,"__esModule",{value:!0})})(this.VueUse=this.VueUse||{},VueDemi,VueUse);
var VueDemi=function(n,o,t){if(n.install)return n;if(o)if(o.version.slice(0,4)==="2.7."){for(var l in o)n[l]=o[l];n.isVue2=!0,n.isVue3=!1,n.install=function(){},n.Vue=o,n.Vue2=o,n.version=o.version}else if(o.version.slice(0,2)==="2.")if(t){for(var l in t)n[l]=t[l];n.isVue2=!0,n.isVue3=!1,n.install=function(){},n.Vue=o,n.Vue2=o,n.version=o.version}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(o.version.slice(0,2)==="3."){for(var l in o)n[l]=o[l];n.isVue2=!1,n.isVue3=!0,n.install=function(){},n.Vue=o,n.Vue2=void 0,n.version=o.version,n.set=function(f,i,s){return Array.isArray(f)?(f.length=Math.max(f.length,i),f.splice(i,1,s),s):(f[i]=s,s)},n.del=function(f,i){if(Array.isArray(f)){f.splice(i,1);return}delete f[i]}}else console.error("[vue-demi] Vue version "+o.version+" is unsupported.");else console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.");return n}(this.VueDemi=this.VueDemi||(typeof VueDemi!="undefined"?VueDemi:{}),this.Vue||(typeof Vue!="undefined"?Vue:void 0),this.VueCompositionAPI||(typeof VueCompositionAPI!="undefined"?VueCompositionAPI:void 0));(function(n,o,t){"use strict";function l(e,r,u){return c=>o.computed(()=>u(t.resolveUnref(c),t.resolveUnref(e),t.resolveUnref(r)))}const f=(e,r,u)=>(e-r[0])/(r[1]-r[0])*(u[1]-u[0])+u[0];function i(e,r,u=f){return l(e,r,u)}function s(...e){return o.computed(()=>e.every(r=>t.resolveUnref(r)))}function M(e){return o.computed(()=>!t.resolveUnref(e))}function p(...e){return o.computed(()=>e.some(r=>t.resolveUnref(r)))}function A(e){return o.computed(()=>Math.abs(t.resolveUnref(e)))}function U(e){return e.flatMap(r=>{const u=t.resolveUnref(r);return Array.isArray(u)?u.map(c=>t.resolveUnref(c)):[u]})}function y(...e){return o.computed(()=>{const r=U(e);return r.reduce((u,c)=>u+=c,0)/r.length})}function P(e){return o.computed(()=>Math.ceil(t.resolveUnref(e)))}function b(e,r,u){const c=o.ref(e);return o.computed({get(){return c.value=t.clamp(c.value,t.resolveUnref(r),t.resolveUnref(u))},set(v){c.value=t.clamp(v,t.resolveUnref(r),t.resolveUnref(u))}})}function j(e){return o.computed(()=>Math.floor(t.resolveUnref(e)))}function _(e,...r){return t.reactify(Math[e])(...r)}function F(...e){return o.computed(()=>{const r=U(e);return Math.max(...r)})}function g(...e){return o.computed(()=>{const r=U(e);return Math.min(...r)})}function C(e,r,u){return o.computed(()=>{var c;const v=t.resolveUnref(e),d=t.resolveUnref(r),a=10**d;return Math[((c=t.resolveUnref(u))==null?void 0:c.math)||"round"](v*a)/a})}function T(e,r,u,c){return i(r,u,c)(e)}function N(e){return o.computed(()=>Math.round(t.resolveUnref(e)))}function O(...e){return o.computed(()=>U(e).reduce((r,u)=>r+=u,0))}function G(e,r,u){return o.computed(()=>{var c,v;const d=parseFloat(`${t.resolveUnref(e)}`),a=Math[((c=t.resolveUnref(u))==null?void 0:c.math)||"round"](d*10**t.resolveUnref(r))/10**t.resolveUnref(r);return((v=t.resolveUnref(u))==null?void 0:v.type)==="string"?t.resolveUnref(r)>=0?a.toFixed(t.resolveUnref(r)):`${a}`:a})}function I(e){return o.computed(()=>Math.trunc(t.resolveUnref(e)))}n.and=s,n.createGenericProjection=l,n.createProjection=i,n.logicAnd=s,n.logicNot=M,n.logicOr=p,n.not=M,n.or=p,n.useAbs=A,n.useAverage=y,n.useCeil=P,n.useClamp=b,n.useFloor=j,n.useMath=_,n.useMax=F,n.useMin=g,n.usePrecision=C,n.useProjection=T,n.useRound=N,n.useSum=O,n.useToFixed=G,n.useTrunc=I,Object.defineProperty(n,"__esModule",{value:!0})})(this.VueUse=this.VueUse||{},VueDemi,VueUse);
{
"name": "@vueuse/math",
"version": "9.0.2",
"version": "9.1.0",
"description": "Math functions for VueUse",

@@ -38,5 +38,5 @@ "author": "Anthony Fu <https://github.com/antfu>",

"dependencies": {
"@vueuse/shared": "9.0.2",
"@vueuse/shared": "9.1.0",
"vue-demi": "*"
}
}

Sorry, the diff of this file is not supported yet

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