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

@vueuse/math

Package Overview
Dependencies
Maintainers
1
Versions
63
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 11.3.0 to 12.0.0-beta.1

4

index.d.ts
import { MaybeRefOrGetter, ReadonlyRefOrGetter, ArgumentsType, Reactified } from '@vueuse/shared';
import { ComputedRef, Ref } from 'vue-demi';
import * as vue from 'vue-demi';
import * as vue from 'vue';
import { ComputedRef, Ref } from 'vue';

@@ -5,0 +5,0 @@ type ProjectorFunction<F, T> = (input: F, from: readonly [F, F], to: readonly [T, T]) => T;

@@ -1,129 +0,2 @@

var _VueDemiGlobal = typeof globalThis !== 'undefined'
? globalThis
: typeof global !== 'undefined'
? global
: typeof self !== 'undefined'
? self
: this
var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
if (VueDemi.install) {
return VueDemi
}
if (!Vue) {
console.error('[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.')
return VueDemi
}
// Vue 2.7
if (Vue.version.slice(0, 4) === '2.7.') {
for (var key in Vue) {
VueDemi[key] = Vue[key]
}
VueDemi.isVue2 = true
VueDemi.isVue3 = false
VueDemi.install = function () {}
VueDemi.Vue = Vue
VueDemi.Vue2 = Vue
VueDemi.version = Vue.version
VueDemi.warn = Vue.util.warn
VueDemi.hasInjectionContext = function() {
return !!VueDemi.getCurrentInstance()
}
function createApp(rootComponent, rootProps) {
var vm
var provide = {}
var app = {
config: Vue.config,
use: Vue.use.bind(Vue),
mixin: Vue.mixin.bind(Vue),
component: Vue.component.bind(Vue),
provide: function (key, value) {
provide[key] = value
return this
},
directive: function (name, dir) {
if (dir) {
Vue.directive(name, dir)
return app
} else {
return Vue.directive(name)
}
},
mount: function (el, hydrating) {
if (!vm) {
vm = new Vue(Object.assign({ propsData: rootProps }, rootComponent, { provide: Object.assign(provide, rootComponent.provide) }))
vm.$mount(el, hydrating)
return vm
} else {
return vm
}
},
unmount: function () {
if (vm) {
vm.$destroy()
vm = undefined
}
},
}
return app
}
VueDemi.createApp = createApp
}
// Vue 2.6.x
else if (Vue.version.slice(0, 2) === '2.') {
if (VueCompositionAPI) {
for (var key in VueCompositionAPI) {
VueDemi[key] = VueCompositionAPI[key]
}
VueDemi.isVue2 = true
VueDemi.isVue3 = false
VueDemi.install = function () {}
VueDemi.Vue = Vue
VueDemi.Vue2 = Vue
VueDemi.version = Vue.version
VueDemi.hasInjectionContext = function() {
return !!VueDemi.getCurrentInstance()
}
} else {
console.error('[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.')
}
}
// Vue 3
else if (Vue.version.slice(0, 2) === '3.') {
for (var key in Vue) {
VueDemi[key] = Vue[key]
}
VueDemi.isVue2 = false
VueDemi.isVue3 = true
VueDemi.install = function () {}
VueDemi.Vue = Vue
VueDemi.Vue2 = undefined
VueDemi.version = Vue.version
VueDemi.set = function (target, key, val) {
if (Array.isArray(target)) {
target.length = Math.max(target.length, key)
target.splice(key, 1, val)
return val
}
target[key] = val
return val
}
VueDemi.del = function (target, key) {
if (Array.isArray(target)) {
target.splice(key, 1)
return
}
delete target[key]
}
} else {
console.error('[vue-demi] Vue version ' + Vue.version + ' is unsupported.')
}
return VueDemi
})(
(_VueDemiGlobal.VueDemi = _VueDemiGlobal.VueDemi || (typeof VueDemi !== 'undefined' ? VueDemi : {})),
_VueDemiGlobal.Vue || (typeof Vue !== 'undefined' ? Vue : undefined),
_VueDemiGlobal.VueCompositionAPI || (typeof VueCompositionAPI !== 'undefined' ? VueCompositionAPI : undefined)
);
;
;(function (exports, shared, vueDemi) {
(function (exports, shared, vue) {
'use strict';

@@ -133,3 +6,3 @@

return (input) => {
return vueDemi.computed(() => projector(shared.toValue(input), shared.toValue(fromDomain), shared.toValue(toDomain)));
return vue.computed(() => projector(shared.toValue(input), shared.toValue(fromDomain), shared.toValue(toDomain)));
};

@@ -146,15 +19,15 @@ }

function logicAnd(...args) {
return vueDemi.computed(() => args.every((i) => shared.toValue(i)));
return vue.computed(() => args.every((i) => shared.toValue(i)));
}
function logicNot(v) {
return vueDemi.computed(() => !shared.toValue(v));
return vue.computed(() => !shared.toValue(v));
}
function logicOr(...args) {
return vueDemi.computed(() => args.some((i) => shared.toValue(i)));
return vue.computed(() => args.some((i) => shared.toValue(i)));
}
function useAbs(value) {
return vueDemi.computed(() => Math.abs(shared.toValue(value)));
return vue.computed(() => Math.abs(shared.toValue(value)));
}

@@ -172,3 +45,3 @@

function useAverage(...args) {
return vueDemi.computed(() => {
return vue.computed(() => {
const array = toValueArgsFlat(args);

@@ -180,10 +53,10 @@ return array.reduce((sum, v) => sum += v, 0) / array.length;

function useCeil(value) {
return vueDemi.computed(() => Math.ceil(shared.toValue(value)));
return vue.computed(() => Math.ceil(shared.toValue(value)));
}
function useClamp(value, min, max) {
if (typeof value === "function" || vueDemi.isReadonly(value))
return vueDemi.computed(() => shared.clamp(shared.toValue(value), shared.toValue(min), shared.toValue(max)));
const _value = vueDemi.ref(value);
return vueDemi.computed({
if (typeof value === "function" || vue.isReadonly(value))
return vue.computed(() => shared.clamp(shared.toValue(value), shared.toValue(min), shared.toValue(max)));
const _value = vue.ref(value);
return vue.computed({
get() {

@@ -199,3 +72,3 @@ return _value.value = shared.clamp(_value.value, shared.toValue(min), shared.toValue(max));

function useFloor(value) {
return vueDemi.computed(() => Math.floor(shared.toValue(value)));
return vue.computed(() => Math.floor(shared.toValue(value)));
}

@@ -208,3 +81,3 @@

function useMax(...args) {
return vueDemi.computed(() => {
return vue.computed(() => {
const array = toValueArgsFlat(args);

@@ -216,3 +89,3 @@ return Math.max(...array);

function useMin(...args) {
return vueDemi.computed(() => {
return vue.computed(() => {
const array = toValueArgsFlat(args);

@@ -234,3 +107,3 @@ return Math.min(...array);

function usePrecision(value, digits, options) {
return vueDemi.computed(() => {
return vue.computed(() => {
var _a;

@@ -249,11 +122,11 @@ const _value = shared.toValue(value);

function useRound(value) {
return vueDemi.computed(() => Math.round(shared.toValue(value)));
return vue.computed(() => Math.round(shared.toValue(value)));
}
function useSum(...args) {
return vueDemi.computed(() => toValueArgsFlat(args).reduce((sum, v) => sum += v, 0));
return vue.computed(() => toValueArgsFlat(args).reduce((sum, v) => sum += v, 0));
}
function useTrunc(value) {
return vueDemi.computed(() => Math.trunc(shared.toValue(value)));
return vue.computed(() => Math.trunc(shared.toValue(value)));
}

@@ -283,2 +156,2 @@

})(this.VueUse = this.VueUse || {}, VueUse, VueDemi);
})(this.VueUse = this.VueUse || {}, VueUse, Vue);

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

var _VueDemiGlobal=typeof globalThis<"u"?globalThis:typeof global<"u"?global:typeof self<"u"?self:this,VueDemi=function(t,n,e){if(t.install)return t;if(!n)return console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`."),t;if(n.version.slice(0,4)==="2.7."){let i=function(l,a){var f,y={},g={config:n.config,use:n.use.bind(n),mixin:n.mixin.bind(n),component:n.component.bind(n),provide:function(d,p){return y[d]=p,this},directive:function(d,p){return p?(n.directive(d,p),g):n.directive(d)},mount:function(d,p){return f||(f=new n(Object.assign({propsData:a},l,{provide:Object.assign(y,l.provide)})),f.$mount(d,p),f)},unmount:function(){f&&(f.$destroy(),f=void 0)}};return g};var M=i;for(var s in n)t[s]=n[s];t.isVue2=!0,t.isVue3=!1,t.install=function(){},t.Vue=n,t.Vue2=n,t.version=n.version,t.warn=n.util.warn,t.hasInjectionContext=function(){return!!t.getCurrentInstance()},t.createApp=i}else if(n.version.slice(0,2)==="2.")if(e){for(var s in e)t[s]=e[s];t.isVue2=!0,t.isVue3=!1,t.install=function(){},t.Vue=n,t.Vue2=n,t.version=n.version,t.hasInjectionContext=function(){return!!t.getCurrentInstance()}}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(n.version.slice(0,2)==="3."){for(var s in n)t[s]=n[s];t.isVue2=!1,t.isVue3=!0,t.install=function(){},t.Vue=n,t.Vue2=void 0,t.version=n.version,t.set=function(i,l,a){return Array.isArray(i)?(i.length=Math.max(i.length,l),i.splice(l,1,a),a):(i[l]=a,a)},t.del=function(i,l){if(Array.isArray(i)){i.splice(l,1);return}delete i[l]}}else console.error("[vue-demi] Vue version "+n.version+" is unsupported.");return t}(_VueDemiGlobal.VueDemi=_VueDemiGlobal.VueDemi||(typeof VueDemi<"u"?VueDemi:{}),_VueDemiGlobal.Vue||(typeof Vue<"u"?Vue:void 0),_VueDemiGlobal.VueCompositionAPI||(typeof VueCompositionAPI<"u"?VueCompositionAPI:void 0));(function(t,n,e){"use strict";function s(o,r,u){return c=>e.computed(()=>u(n.toValue(c),n.toValue(o),n.toValue(r)))}function M(o,r,u){return(o-r[0])/(r[1]-r[0])*(u[1]-u[0])+u[0]}function i(o,r,u=M){return s(o,r,u)}function l(...o){return e.computed(()=>o.every(r=>n.toValue(r)))}function a(o){return e.computed(()=>!n.toValue(o))}function f(...o){return e.computed(()=>o.some(r=>n.toValue(r)))}function y(o){return e.computed(()=>Math.abs(n.toValue(o)))}function g(o){return o.flatMap(r=>{const u=n.toValue(r);return Array.isArray(u)?u.map(c=>n.toValue(c)):[u]})}function d(...o){return e.computed(()=>{const r=g(o);return r.reduce((u,c)=>u+=c,0)/r.length})}function p(o){return e.computed(()=>Math.ceil(n.toValue(o)))}function A(o,r,u){if(typeof o=="function"||e.isReadonly(o))return e.computed(()=>n.clamp(n.toValue(o),n.toValue(r),n.toValue(u)));const c=e.ref(o);return e.computed({get(){return c.value=n.clamp(c.value,n.toValue(r),n.toValue(u))},set(v){c.value=n.clamp(v,n.toValue(r),n.toValue(u))}})}function P(o){return e.computed(()=>Math.floor(n.toValue(o)))}function j(o,...r){return n.reactify(Math[o])(...r)}function C(...o){return e.computed(()=>{const r=g(o);return Math.max(...r)})}function I(...o){return e.computed(()=>{const r=g(o);return Math.min(...r)})}function _(o,r){const u=o.toString();if(o>0&&u.includes(".")){const v=10**u.split(".")[1].length;return o*v*r/v}else return o*r}function O(o,r,u){return e.computed(()=>{var c;const v=n.toValue(o),b=10**n.toValue(r);return Math[((c=n.toValue(u))==null?void 0:c.math)||"round"](_(v,b))/b})}function S(o,r,u,c){return i(r,u,c)(o)}function T(o){return e.computed(()=>Math.round(n.toValue(o)))}function w(...o){return e.computed(()=>g(o).reduce((r,u)=>r+=u,0))}function F(o){return e.computed(()=>Math.trunc(n.toValue(o)))}t.and=l,t.createGenericProjection=s,t.createProjection=i,t.logicAnd=l,t.logicNot=a,t.logicOr=f,t.not=a,t.or=f,t.useAbs=y,t.useAverage=d,t.useCeil=p,t.useClamp=A,t.useFloor=P,t.useMath=j,t.useMax=C,t.useMin=I,t.usePrecision=O,t.useProjection=S,t.useRound=T,t.useSum=w,t.useTrunc=F})(this.VueUse=this.VueUse||{},VueUse,VueDemi);
(function(o,n,c){"use strict";function a(t,u,e){return i=>c.computed(()=>e(n.toValue(i),n.toValue(t),n.toValue(u)))}function s(t,u,e){return(t-u[0])/(u[1]-u[0])*(e[1]-e[0])+e[0]}function f(t,u,e=s){return a(t,u,e)}function V(...t){return c.computed(()=>t.every(u=>n.toValue(u)))}function m(t){return c.computed(()=>!n.toValue(t))}function M(...t){return c.computed(()=>t.some(u=>n.toValue(u)))}function P(t){return c.computed(()=>Math.abs(n.toValue(t)))}function l(t){return t.flatMap(u=>{const e=n.toValue(u);return Array.isArray(e)?e.map(i=>n.toValue(i)):[e]})}function y(...t){return c.computed(()=>{const u=l(t);return u.reduce((e,i)=>e+=i,0)/u.length})}function A(t){return c.computed(()=>Math.ceil(n.toValue(t)))}function d(t,u,e){if(typeof t=="function"||c.isReadonly(t))return c.computed(()=>n.clamp(n.toValue(t),n.toValue(u),n.toValue(e)));const i=c.ref(t);return c.computed({get(){return i.value=n.clamp(i.value,n.toValue(u),n.toValue(e))},set(r){i.value=n.clamp(r,n.toValue(u),n.toValue(e))}})}function j(t){return c.computed(()=>Math.floor(n.toValue(t)))}function p(t,...u){return n.reactify(Math[t])(...u)}function _(...t){return c.computed(()=>{const u=l(t);return Math.max(...u)})}function C(...t){return c.computed(()=>{const u=l(t);return Math.min(...u)})}function S(t,u){const e=t.toString();if(t>0&&e.includes(".")){const r=10**e.split(".")[1].length;return t*r*u/r}else return t*u}function b(t,u,e){return c.computed(()=>{var i;const r=n.toValue(t),g=10**n.toValue(u);return Math[((i=n.toValue(e))==null?void 0:i.math)||"round"](S(r,g))/g})}function F(t,u,e,i){return f(u,e,i)(t)}function N(t){return c.computed(()=>Math.round(n.toValue(t)))}function R(...t){return c.computed(()=>l(t).reduce((u,e)=>u+=e,0))}function U(t){return c.computed(()=>Math.trunc(n.toValue(t)))}o.and=V,o.createGenericProjection=a,o.createProjection=f,o.logicAnd=V,o.logicNot=m,o.logicOr=M,o.not=m,o.or=M,o.useAbs=P,o.useAverage=y,o.useCeil=A,o.useClamp=d,o.useFloor=j,o.useMath=p,o.useMax=_,o.useMin=C,o.usePrecision=b,o.useProjection=F,o.useRound=N,o.useSum=R,o.useTrunc=U})(this.VueUse=this.VueUse||{},VueUse,Vue);
{
"name": "@vueuse/math",
"version": "11.3.0",
"version": "12.0.0-beta.1",
"description": "Math functions for VueUse",

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

"dependencies": {
"@vueuse/shared": "11.3.0",
"vue-demi": ">=0.14.10"
"@vueuse/shared": "12.0.0-beta.1",
"vue": "^3.5.13"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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