@interactjs/utils
Advanced tools
Comparing version 1.9.2 to 1.9.3
12
arr.d.ts
declare type Filter<T> = (element: T, index: number, array: T[]) => boolean; | ||
export declare function contains<T>(array: T[], target: T): boolean; | ||
export declare function remove<T>(array: T[], target: T): T[]; | ||
export declare function merge<T, U>(target: Array<T | U>, source: U[]): (T | U)[]; | ||
export declare function from<T = any>(source: ArrayLike<T>): T[]; | ||
export declare function findIndex<T>(array: T[], func: Filter<T>): number; | ||
export declare function find<T = any>(array: T[], func: Filter<T>): T; | ||
export declare const contains: <T>(array: T[], target: T) => boolean; | ||
export declare const remove: <T>(array: T[], target: T) => T[]; | ||
export declare const merge: <T, U>(target: (T | U)[], source: U[]) => (T | U)[]; | ||
export declare const from: <T = any>(source: ArrayLike<T>) => T[]; | ||
export declare const findIndex: <T>(array: T[], func: Filter<T>) => number; | ||
export declare const find: <T = any>(array: T[], func: Filter<T>) => T; | ||
export {}; |
24
arr.js
@@ -1,8 +0,4 @@ | ||
export function contains(array, target) { | ||
return array.indexOf(target) !== -1; | ||
} | ||
export function remove(array, target) { | ||
return array.splice(array.indexOf(target), 1); | ||
} | ||
export function merge(target, source) { | ||
export const contains = (array, target) => array.indexOf(target) !== -1; | ||
export const remove = (array, target) => array.splice(array.indexOf(target), 1); | ||
export const merge = (target, source) => { | ||
for (const item of source) { | ||
@@ -13,7 +9,5 @@ target.push(item); | ||
return target; | ||
} | ||
export function from(source) { | ||
return merge([], source); | ||
} | ||
export function findIndex(array, func) { | ||
}; | ||
export const from = source => merge([], source); | ||
export const findIndex = (array, func) => { | ||
for (let i = 0; i < array.length; i++) { | ||
@@ -26,6 +20,4 @@ if (func(array[i], i, array)) { | ||
return -1; | ||
} | ||
export function find(array, func) { | ||
return array[findIndex(array, func)]; | ||
} | ||
}; | ||
export const find = (array, func) => array[findIndex(array, func)]; | ||
//# sourceMappingURL=arr.js.map |
@@ -1,2 +0,2 @@ | ||
export function contains(n,e){return-1!==n.indexOf(e)}export function remove(n,e){return n.splice(n.indexOf(e),1)}export function merge(n,e){for(const r of e)n.push(r);return n}export function from(n){return merge([],n)}export function findIndex(n,e){for(let r=0;r<n.length;r++)if(e(n[r],r,n))return r;return-1}export function find(n,e){return n[findIndex(n,e)]} | ||
export const contains=(e,n)=>-1!==e.indexOf(n);export const remove=(e,n)=>e.splice(e.indexOf(n),1);export const merge=(e,n)=>{for(const o of n)e.push(o);return e};export const from=e=>merge([],e);export const findIndex=(e,n)=>{for(let o=0;o<e.length;o++)if(n(e[o],o,e))return o;return-1};export const find=(e,n)=>e[findIndex(e,n)]; | ||
//# sourceMappingURL=arr.min.js.map |
@@ -1,2 +0,2 @@ | ||
import e from"./domObjects.min.js";import*as t from"./is.min.js";import o from"./window.min.js";const n={init:function(r){const s=e.Element,i=o.window.navigator;n.supportsTouch="ontouchstart"in r||t.func(r.DocumentTouch)&&e.document instanceof r.DocumentTouch,n.supportsPointerEvent=!1!==i.pointerEnabled&&!!e.PointerEvent,n.isIOS=/iP(hone|od|ad)/.test(i.platform),n.isIOS7=/iP(hone|od|ad)/.test(i.platform)&&/OS 7[^\d]/.test(i.appVersion),n.isIe9=/MSIE 9/.test(i.userAgent),n.isOperaMobile="Opera"===i.appName&&n.supportsTouch&&/Presto/.test(i.userAgent),n.prefixedMatchesSelector="matches"in s.prototype?"matches":"webkitMatchesSelector"in s.prototype?"webkitMatchesSelector":"mozMatchesSelector"in s.prototype?"mozMatchesSelector":"oMatchesSelector"in s.prototype?"oMatchesSelector":"msMatchesSelector",n.pEventTypes=n.supportsPointerEvent?e.PointerEvent===r.MSPointerEvent?{up:"MSPointerUp",down:"MSPointerDown",over:"mouseover",out:"mouseout",move:"MSPointerMove",cancel:"MSPointerCancel"}:{up:"pointerup",down:"pointerdown",over:"pointerover",out:"pointerout",move:"pointermove",cancel:"pointercancel"}:null,n.wheelEvent="onmousewheel"in e.document?"mousewheel":"wheel"},supportsTouch:null,supportsPointerEvent:null,isIOS7:null,isIOS:null,isIe9:null,isOperaMobile:null,prefixedMatchesSelector:null,pEventTypes:null,wheelEvent:null};export default n; | ||
import e from"./domObjects.min.js";import*as t from"./is.min.js";import o from"./window.min.js";const n={init(r){const s=e.Element,i=o.window.navigator;n.supportsTouch="ontouchstart"in r||t.func(r.DocumentTouch)&&e.document instanceof r.DocumentTouch,n.supportsPointerEvent=!1!==i.pointerEnabled&&!!e.PointerEvent,n.isIOS=/iP(hone|od|ad)/.test(i.platform),n.isIOS7=/iP(hone|od|ad)/.test(i.platform)&&/OS 7[^\d]/.test(i.appVersion),n.isIe9=/MSIE 9/.test(i.userAgent),n.isOperaMobile="Opera"===i.appName&&n.supportsTouch&&/Presto/.test(i.userAgent),n.prefixedMatchesSelector="matches"in s.prototype?"matches":"webkitMatchesSelector"in s.prototype?"webkitMatchesSelector":"mozMatchesSelector"in s.prototype?"mozMatchesSelector":"oMatchesSelector"in s.prototype?"oMatchesSelector":"msMatchesSelector",n.pEventTypes=n.supportsPointerEvent?e.PointerEvent===r.MSPointerEvent?{up:"MSPointerUp",down:"MSPointerDown",over:"mouseover",out:"mouseout",move:"MSPointerMove",cancel:"MSPointerCancel"}:{up:"pointerup",down:"pointerdown",over:"pointerover",out:"pointerout",move:"pointermove",cancel:"pointercancel"}:null,n.wheelEvent="onmousewheel"in e.document?"mousewheel":"wheel"},supportsTouch:null,supportsPointerEvent:null,isIOS7:null,isIOS:null,isIe9:null,isOperaMobile:null,prefixedMatchesSelector:null,pEventTypes:null,wheelEvent:null};export default n; | ||
//# sourceMappingURL=browser.min.js.map |
@@ -1,2 +0,2 @@ | ||
const n={init:function(t){const l=t;n.document=l.document,n.DocumentFragment=l.DocumentFragment||e,n.SVGElement=l.SVGElement||e,n.SVGSVGElement=l.SVGSVGElement||e,n.SVGElementInstance=l.SVGElementInstance||e,n.Element=l.Element||e,n.HTMLElement=l.HTMLElement||n.Element,n.Event=l.Event,n.Touch=l.Touch||e,n.PointerEvent=l.PointerEvent||l.MSPointerEvent},document:null,DocumentFragment:null,SVGElement:null,SVGSVGElement:null,SVGElementInstance:null,Element:null,HTMLElement:null,Event:null,Touch:null,PointerEvent:null};function e(){}export default n; | ||
const e={init(t){const l=t;e.document=l.document,e.DocumentFragment=l.DocumentFragment||n,e.SVGElement=l.SVGElement||n,e.SVGSVGElement=l.SVGSVGElement||n,e.SVGElementInstance=l.SVGElementInstance||n,e.Element=l.Element||n,e.HTMLElement=l.HTMLElement||e.Element,e.Event=l.Event,e.Touch=l.Touch||n,e.PointerEvent=l.PointerEvent||l.MSPointerEvent},document:null,DocumentFragment:null,SVGElement:null,SVGSVGElement:null,SVGElementInstance:null,Element:null,HTMLElement:null,Event:null,Touch:null,PointerEvent:null};function n(){}export default e; | ||
//# sourceMappingURL=domObjects.min.js.map |
@@ -1,2 +0,2 @@ | ||
import{contains as e}from"./arr.min.js";import*as t from"./domUtils.min.js";import*as s from"./is.min.js";import n from"./pointerExtend.min.js";import*as o from"./pointerUtils.min.js";const r=[],i=[],l={},p=[];function a(t,s,n,o){const l=f(o);let p=r.indexOf(t),a=i[p];a||(a={events:{},typeCount:0},p=r.push(t)-1,i.push(a)),a.events[s]||(a.events[s]=[],a.typeCount++),t.removeEventListener&&!e(a.events[s],n)&&(t.addEventListener(s,n,m.supportsOptions?l:!!l.capture),a.events[s].push(n))}function c(e,t,s,n){const o=f(n),l=r.indexOf(e),p=i[l];if(p&&p.events)if("all"!==t){if(p.events[t]){const n=p.events[t].length;if("all"===s){for(let s=0;s<n;s++)c(e,t,p.events[t][s],o);return}for(let r=0;r<n;r++)if(e.removeEventListener&&p.events[t][r]===s){e.removeEventListener(t,s,m.supportsOptions?o:!!o.capture),p.events[t].splice(r,1);break}p.events[t]&&0===p.events[t].length&&(p.events[t]=null,p.typeCount--)}p.typeCount||(i.splice(l,1),r.splice(l,1))}else for(t in p.events)p.events.hasOwnProperty(t)&&c(e,t,"all")}function u(e,n){const r=f(n),i=new FakeEvent(e),p=l[e.type],[a]=o.getEventTargets(e);let c=a;for(;s.element(c);){for(let e=0;e<p.selectors.length;e++){const s=p.selectors[e],n=p.contexts[e];if(t.matchesSelector(c,s)&&t.nodeContains(n,a)&&t.nodeContains(n,c)){const t=p.listeners[e];i.currentTarget=c;for(const[e,s,n]of t)s===!!r.capture&&n===r.passive&&e(i)}}c=t.parentNode(c)}}function v(e){return u.call(this,e,!0)}function f(e){return s.object(e)?e:{capture:e}}export class FakeEvent{constructor(e){this.originalEvent=e,this.currentTarget=void 0,n(this,e)}preventOriginalDefault(){this.originalEvent.preventDefault()}stopPropagation(){this.originalEvent.stopPropagation()}stopImmediatePropagation(){this.originalEvent.stopImmediatePropagation()}}const m={add:a,remove:c,addDelegate:function(e,t,s,n,o){const r=f(o);if(!l[s]){l[s]={contexts:[],listeners:[],selectors:[]};for(const e of p)a(e,s,u),a(e,s,v,!0)}const i=l[s];let c;for(c=i.selectors.length-1;c>=0&&(i.selectors[c]!==e||i.contexts[c]!==t);c--);-1===c&&(c=i.selectors.length,i.selectors.push(e),i.contexts.push(t),i.listeners.push([])),i.listeners[c].push([n,!!r.capture,r.passive])},removeDelegate:function(e,t,s,n,o){const r=f(o),i=l[s];let p,a=!1;if(i)for(p=i.selectors.length-1;p>=0;p--)if(i.selectors[p]===e&&i.contexts[p]===t){const e=i.listeners[p];for(let o=e.length-1;o>=0;o--){const[f,m,g]=e[o];if(f===n&&m===!!r.capture&&g===r.passive){e.splice(o,1),e.length||(i.selectors.splice(p,1),i.contexts.splice(p,1),i.listeners.splice(p,1),c(t,s,u),c(t,s,v,!0),i.selectors.length||(l[s]=null)),a=!0;break}}if(a)break}},delegateListener:u,delegateUseCapture:v,delegatedEvents:l,documents:p,supportsOptions:!1,supportsPassive:!1,_elements:r,_targets:i,init(e){e.document.createElement("div").addEventListener("test",null,{get capture(){return m.supportsOptions=!0},get passive(){return m.supportsPassive=!0}})}};export default m; | ||
import{contains as e}from"./arr.min.js";import*as t from"./domUtils.min.js";import*as s from"./is.min.js";import n from"./pointerExtend.min.js";import*as o from"./pointerUtils.min.js";const r=[],i=[],l={},p=[];function a(t,s,n,o){const l=f(o);let p=r.indexOf(t),a=i[p];a||(a={events:{},typeCount:0},p=r.push(t)-1,i.push(a)),a.events[s]||(a.events[s]=[],a.typeCount++),t.removeEventListener&&!e(a.events[s],n)&&(t.addEventListener(s,n,m.supportsOptions?l:!!l.capture),a.events[s].push(n))}function c(e,t,s,n){const o=f(n),l=r.indexOf(e),p=i[l];if(p&&p.events)if("all"!==t){if(p.events[t]){const n=p.events[t].length;if("all"===s){for(let s=0;s<n;s++)c(e,t,p.events[t][s],o);return}for(let r=0;r<n;r++)if(e.removeEventListener&&p.events[t][r]===s){e.removeEventListener(t,s,m.supportsOptions?o:!!o.capture),p.events[t].splice(r,1);break}p.events[t]&&0===p.events[t].length&&(p.events[t]=null,p.typeCount--)}p.typeCount||(i.splice(l,1),r.splice(l,1))}else for(t in p.events)p.events.hasOwnProperty(t)&&c(e,t,"all")}function u(e,n){const r=f(n),i=new FakeEvent(e),p=l[e.type],[a]=o.getEventTargets(e);let c=a;for(;s.element(c);){for(let e=0;e<p.selectors.length;e++){const s=p.selectors[e],n=p.contexts[e];if(t.matchesSelector(c,s)&&t.nodeContains(n,a)&&t.nodeContains(n,c)){const t=p.listeners[e];i.currentTarget=c;for(const[e,s,n]of t)s===!!r.capture&&n===r.passive&&e(i)}}c=t.parentNode(c)}}function v(e){return u(e,!0)}function f(e){return s.object(e)?e:{capture:e}}export class FakeEvent{constructor(e){this.originalEvent=e,this.currentTarget=void 0,n(this,e)}preventOriginalDefault(){this.originalEvent.preventDefault()}stopPropagation(){this.originalEvent.stopPropagation()}stopImmediatePropagation(){this.originalEvent.stopImmediatePropagation()}}const m={add:a,remove:c,addDelegate(e,t,s,n,o){const r=f(o);if(!l[s]){l[s]={contexts:[],listeners:[],selectors:[]};for(const e of p)a(e,s,u),a(e,s,v,!0)}const i=l[s];let c;for(c=i.selectors.length-1;c>=0&&(i.selectors[c]!==e||i.contexts[c]!==t);c--);-1===c&&(c=i.selectors.length,i.selectors.push(e),i.contexts.push(t),i.listeners.push([])),i.listeners[c].push([n,!!r.capture,r.passive])},removeDelegate(e,t,s,n,o){const r=f(o),i=l[s];let p,a=!1;if(i)for(p=i.selectors.length-1;p>=0;p--)if(i.selectors[p]===e&&i.contexts[p]===t){const e=i.listeners[p];for(let o=e.length-1;o>=0;o--){const[f,m,g]=e[o];if(f===n&&m===!!r.capture&&g===r.passive){e.splice(o,1),e.length||(i.selectors.splice(p,1),i.contexts.splice(p,1),i.listeners.splice(p,1),c(t,s,u),c(t,s,v,!0),i.selectors.length||(l[s]=null)),a=!0;break}}if(a)break}},delegateListener:u,delegateUseCapture:v,delegatedEvents:l,documents:p,supportsOptions:!1,supportsPassive:!1,_elements:r,_targets:i,init(e){e.document.createElement("div").addEventListener("test",null,{get capture(){return m.supportsOptions=!0},get passive(){return m.supportsPassive=!0}})}};export default m; | ||
//# sourceMappingURL=events.min.js.map |
@@ -1,2 +0,2 @@ | ||
import{rectToXY as o,resolveRectLike as i}from"./rect.min.js";export default function(n,t,r){const e=n.options[r],p=e&&e.origin||n.options.origin,s=i(p,n,t,[n&&t]);return o(s)||{x:0,y:0}} | ||
import{rectToXY as o,resolveRectLike as i}from"./rect.min.js";export default(r,t,n)=>{const e=r.options[n],p=e&&e.origin||r.options.origin,s=i(p,r,t,[r&&t]);return o(s)||{x:0,y:0}}; | ||
//# sourceMappingURL=getOriginXY.min.js.map |
{ | ||
"name": "@interactjs/utils", | ||
"version": "1.9.2", | ||
"version": "1.9.3", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@interactjs/_dev": "1.9.2" | ||
"@interactjs/_dev": "1.9.3" | ||
}, | ||
@@ -11,3 +11,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "77b581be" | ||
"gitHead": "2032dde4" | ||
} |
@@ -1,2 +0,2 @@ | ||
let e,t,n=0;export default{request:t=>e(t),cancel:e=>t(e),init:function(a){if(e=a.requestAnimationFrame,t=a.cancelAnimationFrame,!e){const n=["ms","moz","webkit","o"];for(const i of n)e=a[`${i}RequestAnimationFrame`],t=a[`${i}CancelAnimationFrame`]||a[`${i}CancelRequestAnimationFrame`]}e||(e=e=>{const t=Date.now(),a=Math.max(0,16-(t-n)),i=setTimeout(()=>{e(t+a)},a);return n=t+a,i},t=e=>clearTimeout(e))}}; | ||
let e,t,n=0;export default{request(t){return e(t)},cancel(e){return t(e)},init(a){if(e=a.requestAnimationFrame,t=a.cancelAnimationFrame,!e){const n=["ms","moz","webkit","o"];for(const i of n)e=a[`${i}RequestAnimationFrame`],t=a[`${i}CancelAnimationFrame`]||a[`${i}CancelRequestAnimationFrame`]}e||(e=e=>{const t=Date.now(),a=Math.max(0,16-(t-n)),i=setTimeout(()=>{e(t+a)},a);return n=t+a,i},t=e=>clearTimeout(e))}}; | ||
//# sourceMappingURL=raf.min.js.map |
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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
229186
1728