interval-operations
Advanced tools
Comparing version 1.0.6 to 1.0.7
import { Interval } from "./types"; | ||
export declare function contains( | ||
outerInterval: Interval, | ||
innerInterval: Interval | ||
): boolean; | ||
export declare function arrayContains( | ||
outerIntervals: Interval[], | ||
innerIntervals: Interval[] | ||
): boolean; | ||
export declare function contains(outerInterval: Interval, innerInterval: Interval): boolean; | ||
export declare function arrayContains(outerIntervals: Interval[], innerIntervals: Interval[]): boolean; |
import { Interval } from "./types"; | ||
export declare function difference(a: Interval, b: Interval): Interval[] | null; | ||
export declare function arrayDifference( | ||
inputIntervals: Interval[], | ||
inputDiffIntervals: Interval[] | ||
): Interval[]; | ||
export declare function arrayDifference(inputIntervals: Interval[], inputDiffIntervals: Interval[]): Interval[]; |
@@ -0,0 +0,0 @@ import { Interval } from "./types"; |
import { Interval } from "./types"; | ||
export declare function intersection(...intervals: Interval[]): Interval | null; | ||
export declare function arrayIntersection(...arrays: Interval[][]): Interval[]; |
@@ -0,0 +0,0 @@ export { union, arrayUnion } from "./union"; |
@@ -16,2 +16,2 @@ "use strict"; | ||
***************************************************************************** */ | ||
function r(){for(var r=0,n=0,t=arguments.length;n<t;n++)r+=arguments[n].length;var e=Array(r),o=0;for(n=0;n<t;n++)for(var f=arguments[n],a=0,u=f.length;a<u;a++,o++)e[o]=f[a];return e}function n(r,n){return r[0]<n[0]?-1:r[0]>n[0]?1:0}function t(r,n){return r[1]<n[1]?-1:r[1]>n[1]?1:0}function e(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(!t.length)return[];for(var o=[],f=(t=t.sort(n))[0],a=f[0],u=f[1],i=1,l=t.length;i<l;i++){var h=t[i],v=h[0],g=h[1];u<v&&(o.push([a,u]),a=v),u<g&&(u=g)}return r(o,[[a,u]])}function o(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];if(!r.length)return[];for(var t=[],o=0,f=r.length;o<f;o++)t=t.concat(r[o]);return e.apply(void 0,t)}function f(r,n){return function(r,n){return n[1]>r[0]&&n[0]<r[1]}(r,n)?n[0]>r[0]&&n[1]<r[1]?[[r[0],n[0]],[n[1],r[1]]]:n[0]<=r[0]&&n[1]>=r[1]?null:n[0]>r[0]?[[r[0],n[0]]]:[[n[1],r[1]]]:[r]}function a(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];r.sort(n);for(var o=[r[r.length-1][0],r.sort(t)[0][1]],f=o[0],a=o[1],u=0,i=r.length;u<i-1;u++){var l=r[u+1],h=l[0],v=l[1];if(h>a||v<f)return null}return[f,a]}function u(r,n){return n[0]>=r[0]&&n[1]<=r[1]}Object.defineProperty(exports,"__esModule",{value:!0}),exports.arrayContains=function(r,n){r=o(r);for(var t=0,e=(n=o(n)).length;t<e;t++){for(var f=!1,a=0,i=r.length;a<i;a++)if(u(r[a],n[t])){f=!0;break}if(!f)return!1}return!0},exports.arrayDifference=function(r,n){var t,o=e.apply(void 0,r),a=e.apply(void 0,n);if(!o.length)return[];if(!a.length)return o;for(var u=[],i=0,l=o.length;i<l;i++){for(var h=o[i],v=h[0],g=h[1],s=!0,c=0,p=a.length;c<p;c++){var x=a[c];if(!(x[1]<=v)){if(x[0]>=g)break;var y=f([v,g],x);if(!y){s=!1;break}v=(t=y[y.length-1])[0],g=t[1],y.length>1&&u.push(y[0])}}s&&u.push([v,g])}return u},exports.arrayIntersection=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];for(var e=r[0],o=1,f=r.length;o<f;o++){var u=r[o];u.sort(n);for(var i=[],l=0,h=e.length;l<h;l++)for(var v=e[l],g=0,s=u.length;g<s;g++){var c=u[g];if(!(c[1]<=v[0])){if(c[0]>=v[1])break;i.push(a(v,c))}}e=i}return e.length?e:[]},exports.arrayUnion=o,exports.contains=u,exports.difference=f,exports.intersection=a,exports.union=e; | ||
function r(r,n){for(var t=0,e=n.length,o=r.length;t<e;t++,o++)r[o]=n[t];return r}function n(r,n){return r[0]<n[0]?-1:r[0]>n[0]?1:0}function t(r,n){return r[1]<n[1]?-1:r[1]>n[1]?1:0}function e(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(!t.length)return[];for(var o=[],f=(t=t.sort(n))[0],a=f[0],u=f[1],i=1,l=t.length;i<l;i++){var h=t[i],v=h[0],g=h[1];u<v&&(o.push([a,u]),a=v),u<g&&(u=g)}return r(r([],o),[[a,u]])}function o(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];if(!r.length)return[];for(var t=[],o=0,f=r.length;o<f;o++)t=t.concat(r[o]);return e.apply(void 0,t)}function f(r,n){return function(r,n){return n[1]>r[0]&&n[0]<r[1]}(r,n)?n[0]>r[0]&&n[1]<r[1]?[[r[0],n[0]],[n[1],r[1]]]:n[0]<=r[0]&&n[1]>=r[1]?null:n[0]>r[0]?[[r[0],n[0]]]:[[n[1],r[1]]]:[r]}function a(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];r.sort(n);for(var o=[r[r.length-1][0],r.sort(t)[0][1]],f=o[0],a=o[1],u=0,i=r.length;u<i-1;u++){var l=r[u+1],h=l[0],v=l[1];if(h>a||v<f)return null}return[f,a]}function u(r,n){return n[0]>=r[0]&&n[1]<=r[1]}Object.defineProperty(exports,"__esModule",{value:!0}),exports.arrayContains=function(r,n){r=o(r);for(var t=0,e=(n=o(n)).length;t<e;t++){for(var f=!1,a=0,i=r.length;a<i;a++)if(u(r[a],n[t])){f=!0;break}if(!f)return!1}return!0},exports.arrayDifference=function(r,n){var t,o=e.apply(void 0,r),a=e.apply(void 0,n);if(!o.length)return[];if(!a.length)return o;for(var u=[],i=0,l=o.length;i<l;i++){for(var h=o[i],v=h[0],g=h[1],s=!0,c=0,p=a.length;c<p;c++){var x=a[c];if(!(x[1]<=v)){if(x[0]>=g)break;var y=f([v,g],x);if(!y){s=!1;break}v=(t=y[y.length-1])[0],g=t[1],y.length>1&&u.push(y[0])}}s&&u.push([v,g])}return u},exports.arrayIntersection=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];for(var e=r[0],o=1,f=r.length;o<f;o++){var u=r[o];u.sort(n);for(var i=[],l=0,h=e.length;l<h;l++)for(var v=e[l],g=0,s=u.length;g<s;g++){var c=u[g];if(!(c[1]<=v[0])){if(c[0]>=v[1])break;i.push(a(v,c))}}e=i}return e.length?e:[]},exports.arrayUnion=o,exports.contains=u,exports.difference=f,exports.intersection=a,exports.union=e; |
@@ -15,2 +15,2 @@ /*! ***************************************************************************** | ||
***************************************************************************** */ | ||
function r(){for(var r=0,n=0,t=arguments.length;n<t;n++)r+=arguments[n].length;var e=Array(r),f=0;for(n=0;n<t;n++)for(var o=arguments[n],u=0,a=o.length;u<a;u++,f++)e[f]=o[u];return e}function n(r,n){return r[0]<n[0]?-1:r[0]>n[0]?1:0}function t(r,n){return r[1]<n[1]?-1:r[1]>n[1]?1:0}function e(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(!t.length)return[];for(var f=[],o=(t=t.sort(n))[0],u=o[0],a=o[1],l=1,h=t.length;l<h;l++){var i=t[l],v=i[0],g=i[1];a<v&&(f.push([u,a]),u=v),a<g&&(a=g)}return r(f,[[u,a]])}function f(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];if(!r.length)return[];for(var t=[],f=0,o=r.length;f<o;f++)t=t.concat(r[f]);return e.apply(void 0,t)}function o(r,n){return function(r,n){return n[1]>r[0]&&n[0]<r[1]}(r,n)?n[0]>r[0]&&n[1]<r[1]?[[r[0],n[0]],[n[1],r[1]]]:n[0]<=r[0]&&n[1]>=r[1]?null:n[0]>r[0]?[[r[0],n[0]]]:[[n[1],r[1]]]:[r]}function u(r,n){var t,f=e.apply(void 0,r),u=e.apply(void 0,n);if(!f.length)return[];if(!u.length)return f;for(var a=[],l=0,h=f.length;l<h;l++){for(var i=f[l],v=i[0],g=i[1],c=!0,p=0,s=u.length;p<s;p++){var b=u[p];if(!(b[1]<=v)){if(b[0]>=g)break;var k=o([v,g],b);if(!k){c=!1;break}v=(t=k[k.length-1])[0],g=t[1],k.length>1&&a.push(k[0])}}c&&a.push([v,g])}return a}function a(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];r.sort(n);for(var f=[r[r.length-1][0],r.sort(t)[0][1]],o=f[0],u=f[1],a=0,l=r.length;a<l-1;a++){var h=r[a+1],i=h[0],v=h[1];if(i>u||v<o)return null}return[o,u]}function l(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];for(var e=r[0],f=1,o=r.length;f<o;f++){var u=r[f];u.sort(n);for(var l=[],h=0,i=e.length;h<i;h++)for(var v=e[h],g=0,c=u.length;g<c;g++){var p=u[g];if(!(p[1]<=v[0])){if(p[0]>=v[1])break;l.push(a(v,p))}}e=l}return e.length?e:[]}function h(r,n){return n[0]>=r[0]&&n[1]<=r[1]}function i(r,n){r=f(r);for(var t=0,e=(n=f(n)).length;t<e;t++){for(var o=!1,u=0,a=r.length;u<a;u++)if(h(r[u],n[t])){o=!0;break}if(!o)return!1}return!0}export{i as arrayContains,u as arrayDifference,l as arrayIntersection,f as arrayUnion,h as contains,o as difference,a as intersection,e as union}; | ||
function r(r,n){for(var t=0,e=n.length,f=r.length;t<e;t++,f++)r[f]=n[t];return r}function n(r,n){return r[0]<n[0]?-1:r[0]>n[0]?1:0}function t(r,n){return r[1]<n[1]?-1:r[1]>n[1]?1:0}function e(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(!t.length)return[];for(var f=[],o=(t=t.sort(n))[0],u=o[0],l=o[1],a=1,h=t.length;a<h;a++){var i=t[a],v=i[0],g=i[1];l<v&&(f.push([u,l]),u=v),l<g&&(l=g)}return r(r([],f),[[u,l]])}function f(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];if(!r.length)return[];for(var t=[],f=0,o=r.length;f<o;f++)t=t.concat(r[f]);return e.apply(void 0,t)}function o(r,n){return function(r,n){return n[1]>r[0]&&n[0]<r[1]}(r,n)?n[0]>r[0]&&n[1]<r[1]?[[r[0],n[0]],[n[1],r[1]]]:n[0]<=r[0]&&n[1]>=r[1]?null:n[0]>r[0]?[[r[0],n[0]]]:[[n[1],r[1]]]:[r]}function u(r,n){var t,f=e.apply(void 0,r),u=e.apply(void 0,n);if(!f.length)return[];if(!u.length)return f;for(var l=[],a=0,h=f.length;a<h;a++){for(var i=f[a],v=i[0],g=i[1],c=!0,p=0,s=u.length;p<s;p++){var b=u[p];if(!(b[1]<=v)){if(b[0]>=g)break;var k=o([v,g],b);if(!k){c=!1;break}v=(t=k[k.length-1])[0],g=t[1],k.length>1&&l.push(k[0])}}c&&l.push([v,g])}return l}function l(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];r.sort(n);for(var f=[r[r.length-1][0],r.sort(t)[0][1]],o=f[0],u=f[1],l=0,a=r.length;l<a-1;l++){var h=r[l+1],i=h[0],v=h[1];if(i>u||v<o)return null}return[o,u]}function a(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];for(var e=r[0],f=1,o=r.length;f<o;f++){var u=r[f];u.sort(n);for(var a=[],h=0,i=e.length;h<i;h++)for(var v=e[h],g=0,c=u.length;g<c;g++){var p=u[g];if(!(p[1]<=v[0])){if(p[0]>=v[1])break;a.push(l(v,p))}}e=a}return e.length?e:[]}function h(r,n){return n[0]>=r[0]&&n[1]<=r[1]}function i(r,n){r=f(r);for(var t=0,e=(n=f(n)).length;t<e;t++){for(var o=!1,u=0,l=r.length;u<l;u++)if(h(r[u],n[t])){o=!0;break}if(!o)return!1}return!0}export{i as arrayContains,u as arrayDifference,a as arrayIntersection,f as arrayUnion,h as contains,o as difference,l as intersection,e as union}; |
export declare type IntervalPoint = number | Date; | ||
export declare type Interval = [IntervalPoint, IntervalPoint]; |
import { Interval } from "./types"; | ||
export declare function union(...intervals: Interval[]): Interval[]; | ||
export declare function arrayUnion(...arrays: Interval[][]): Interval[]; |
{ | ||
"name": "interval-operations", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "Utilities for performing mathematical set operations on intervals and arrays of intervals", | ||
@@ -35,17 +35,17 @@ "keywords": [ | ||
"devDependencies": { | ||
"@types/jest": "^25.2.3", | ||
"@types/node": "^14.0.5", | ||
"@typescript-eslint/eslint-plugin": "^3.0.2", | ||
"@typescript-eslint/parser": "^3.0.2", | ||
"eslint": "^7.1.0", | ||
"eslint-config-prettier": "^6.11.0", | ||
"eslint-plugin-jest": "^23.13.2", | ||
"eslint-plugin-prettier": "^3.1.3", | ||
"jest": "^26.0.1", | ||
"prettier": "^2.0.5", | ||
"rollup": "^2.11.2", | ||
"rollup-plugin-terser": "^6.1.0", | ||
"rollup-plugin-typescript2": "^0.27.1", | ||
"ts-jest": "^26.0.0", | ||
"typescript": "^3.9.3" | ||
"@types/jest": "^26.0.20", | ||
"@types/node": "^14.14.32", | ||
"@typescript-eslint/eslint-plugin": "^4.16.1", | ||
"@typescript-eslint/parser": "^4.16.1", | ||
"eslint": "^7.21.0", | ||
"eslint-config-prettier": "^8.1.0", | ||
"eslint-plugin-jest": "^24.1.8", | ||
"eslint-plugin-prettier": "^3.3.1", | ||
"jest": "^26.6.3", | ||
"prettier": "^2.2.1", | ||
"rollup": "^2.40.0", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"rollup-plugin-typescript2": "^0.30.0", | ||
"ts-jest": "^26.5.3", | ||
"typescript": "^4.2.3" | ||
}, | ||
@@ -52,0 +52,0 @@ "jest": { |
@@ -0,0 +0,0 @@ # Interval operations |
@@ -0,0 +0,0 @@ import typescript from "rollup-plugin-typescript2"; |
@@ -0,0 +0,0 @@ import { contains, arrayContains } from "./contains"; |
@@ -0,0 +0,0 @@ import { Interval } from "./types"; |
@@ -0,0 +0,0 @@ import { difference, arrayDifference } from "./difference"; |
@@ -0,0 +0,0 @@ import { Interval } from "./types"; |
@@ -0,0 +0,0 @@ import { sortByStart, sortByEnd, hasOverlap } from "./helpers"; |
@@ -0,0 +0,0 @@ import { Interval } from "./types"; |
@@ -0,0 +0,0 @@ import { intersection, arrayIntersection } from "./intersection"; |
@@ -0,0 +0,0 @@ import { Interval } from "./types"; |
@@ -0,0 +0,0 @@ export { union, arrayUnion } from "./union"; |
export type IntervalPoint = number | Date; | ||
export type Interval = [IntervalPoint, IntervalPoint]; |
@@ -0,0 +0,0 @@ import { union, arrayUnion } from "./union"; |
@@ -0,0 +0,0 @@ import { Interval } from "./types"; |
@@ -0,0 +0,0 @@ { |
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
22239
475