dgeoutils 2.3.6 → 2.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,4 +7,4 @@ export * from './FastSearch';
7
7
  export * from './TraceMatrix';
8
8
  export * from './DPolygonLoop';
9
9
  export * from './DPlane';
10
- export { gaussianElimination, createCanvas, createArray, createMatrix, isDefAndNotNull, cartesianProduct, DGeo } from './utils';
10
+ export { gaussianElimination, createCanvas, createArray, createMatrix, isDefAndNotNull, cartesianProduct, getCombinations, DGeo } from './utils';
package/dist/cjs/index.js CHANGED
@@ -10,7 +10,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.DGeo = exports.cartesianProduct = exports.isDefAndNotNull = exports.createMatrix = exports.createArray = exports.createCanvas = exports.gaussianElimination = void 0;
13
+ exports.DGeo = exports.getCombinations = exports.cartesianProduct = exports.isDefAndNotNull = exports.createMatrix = exports.createArray = exports.createCanvas = exports.gaussianElimination = void 0;
14
14
  __exportStar(require("./DCircle"), exports);
15
15
  __exportStar(require("./DLine"), exports);
16
16
  __exportStar(require("./DNumbers"), exports);
@@ -27,4 +27,5 @@ Object.defineProperty(exports, "createArray", { enumerable: true, get: function
27
27
  Object.defineProperty(exports, "createMatrix", { enumerable: true, get: function () { return utils_1.createMatrix; } });
28
28
  Object.defineProperty(exports, "isDefAndNotNull", { enumerable: true, get: function () { return utils_1.isDefAndNotNull; } });
29
29
  Object.defineProperty(exports, "cartesianProduct", { enumerable: true, get: function () { return utils_1.cartesianProduct; } });
30
+ Object.defineProperty(exports, "getCombinations", { enumerable: true, get: function () { return utils_1.getCombinations; } });
30
31
  Object.defineProperty(exports, "DGeo", { enumerable: true, get: function () { return utils_1.DGeo; } });
@@ -36,6 +36,7 @@ export declare const createCanvas: {
36
36
  document?: Document;
37
37
  };
38
38
  export declare const cartesianProduct: {
39
- <T>(...a: T[][]): T[][];
39
+ <T>(a: T[], ...b: T[][]): T[][];
40
40
  };
41
+ export declare const getCombinations: <T>(arr: T[][]) => T[][];
41
42
  export {};
package/dist/cjs/utils.js CHANGED
@@ -25,7 +25,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
25
25
  return to.concat(ar || Array.prototype.slice.call(from));
26
26
  };
27
27
  Object.defineProperty(exports, "__esModule", { value: true });
28
- exports.cartesianProduct = exports.createCanvas = exports.gaussianElimination = exports.createMatrix = exports.createArray = exports.checkFunction = exports.isDefAndNotNull = exports.warn = exports.DGeo = void 0;
28
+ exports.getCombinations = exports.cartesianProduct = exports.createCanvas = exports.gaussianElimination = exports.createMatrix = exports.createArray = exports.checkFunction = exports.isDefAndNotNull = exports.warn = exports.DGeo = void 0;
29
29
  var DPoint_1 = require("./DPoint");
30
30
  exports.DGeo = {
31
31
  DEBUG: false
@@ -200,3 +200,17 @@ var cartesianProduct = function (a, b) {
200
200
  return b ? exports.cartesianProduct.apply(void 0, __spreadArray([f(a, b)], __read(c), false)) : a;
201
201
  };
202
202
  exports.cartesianProduct = cartesianProduct;
203
+ var getCombinations = function (arr) {
204
+ if (arr.length === 1) {
205
+ return arr[0];
206
+ }
207
+ var ans = [];
208
+ var otherCases = (0, exports.getCombinations)(arr.slice(1));
209
+ for (var i = 0; i < otherCases.length; i++) {
210
+ for (var j = 0; j < arr[0].length; j++) {
211
+ ans.push(__spreadArray([arr[0][j]], __read(otherCases[i]), false));
212
+ }
213
+ }
214
+ return ans;
215
+ };
216
+ exports.getCombinations = getCombinations;
@@ -7,4 +7,4 @@ export * from './FastSearch';
7
7
  export * from './TraceMatrix';
8
8
  export * from './DPolygonLoop';
9
9
  export * from './DPlane';
10
- export { gaussianElimination, createCanvas, createArray, createMatrix, isDefAndNotNull, cartesianProduct, DGeo } from './utils';
10
+ export { gaussianElimination, createCanvas, createArray, createMatrix, isDefAndNotNull, cartesianProduct, getCombinations, DGeo } from './utils';
@@ -147,3 +147,16 @@ export const createCanvas = (a, b, c) => {
147
147
  };
148
148
  const f = (a, b) => [].concat(...a.map((c) => b.map((d) => [].concat(c, d))));
149
149
  export const cartesianProduct = (a, b, ...c) => b ? cartesianProduct(f(a, b), ...c) : a;
150
+ export const getCombinations = (arr) => {
151
+ if (arr.length === 1) {
152
+ return arr[0];
153
+ }
154
+ const ans = [];
155
+ const otherCases = getCombinations(arr.slice(1));
156
+ for (let i = 0; i < otherCases.length; i++) {
157
+ for (let j = 0; j < arr[0].length; j++) {
158
+ ans.push([arr[0][j], ...otherCases[i]]);
159
+ }
160
+ }
161
+ return ans;
162
+ };
package/dist/esm/index.js CHANGED
@@ -7,4 +7,4 @@ export * from './FastSearch';
7
7
  export * from './TraceMatrix';
8
8
  export * from './DPolygonLoop';
9
9
  export * from './DPlane';
10
- export { gaussianElimination, createCanvas, createArray, createMatrix, isDefAndNotNull, cartesianProduct, DGeo } from './utils';
10
+ export { gaussianElimination, createCanvas, createArray, createMatrix, isDefAndNotNull, cartesianProduct, getCombinations, DGeo } from './utils';
package/dist/esm/utils.js CHANGED
@@ -189,3 +189,16 @@ export var cartesianProduct = function (a, b) {
189
189
  }
190
190
  return b ? cartesianProduct.apply(void 0, __spreadArray([f(a, b)], __read(c), false)) : a;
191
191
  };
192
+ export var getCombinations = function (arr) {
193
+ if (arr.length === 1) {
194
+ return arr[0];
195
+ }
196
+ var ans = [];
197
+ var otherCases = getCombinations(arr.slice(1));
198
+ for (var i = 0; i < otherCases.length; i++) {
199
+ for (var j = 0; j < arr[0].length; j++) {
200
+ ans.push(__spreadArray([arr[0][j]], __read(otherCases[i]), false));
201
+ }
202
+ }
203
+ return ans;
204
+ };