js-combinatorics
Advanced tools
Comparing version 1.4.3 to 1.4.4
@@ -14,3 +14,3 @@ /** | ||
*/ | ||
export declare const version = "1.4.3"; | ||
export declare const version = "1.4.4"; | ||
/** | ||
@@ -17,0 +17,0 @@ * BigInt Workaround |
@@ -14,3 +14,3 @@ /** | ||
*/ | ||
export const version = '1.4.3'; | ||
export const version = '1.4.4'; | ||
const _BI = typeof BigInt == 'function' ? BigInt : Number; | ||
@@ -27,2 +27,6 @@ /** | ||
export function permutation(n, k) { | ||
if (n < 0) | ||
throw new RangeError(`negative n is not acceptable`); | ||
if (k < 0) | ||
throw new RangeError(`negative k is not acceptable`); | ||
if (0 == k) | ||
@@ -241,3 +245,3 @@ return 1; | ||
this.seed = [...seed]; | ||
this.size = 0 < size && size <= this.seed.length ? size : this.seed.length; | ||
this.size = 0 < size ? size : this.seed.length; | ||
this.length = permutation(this.seed.length, this.size); | ||
@@ -268,3 +272,4 @@ Object.freeze(this); | ||
this.seed = [...seed]; | ||
this.size = 0 < size && size <= this.seed.length ? size : this.seed.length; | ||
this.size = 0 < size ? size : this.seed.length; | ||
this.size = size; | ||
this.length = combination(this.seed.length, this.size); | ||
@@ -271,0 +276,0 @@ this.comb = combinadic(this.seed.length, this.size); |
@@ -17,3 +17,3 @@ "use strict"; | ||
*/ | ||
exports.version = '1.4.3'; | ||
exports.version = '1.4.4'; | ||
const _BI = typeof BigInt == 'function' ? BigInt : Number; | ||
@@ -30,2 +30,6 @@ /** | ||
function permutation(n, k) { | ||
if (n < 0) | ||
throw new RangeError(`negative n is not acceptable`); | ||
if (k < 0) | ||
throw new RangeError(`negative k is not acceptable`); | ||
if (0 == k) | ||
@@ -250,3 +254,3 @@ return 1; | ||
this.seed = [...seed]; | ||
this.size = 0 < size && size <= this.seed.length ? size : this.seed.length; | ||
this.size = 0 < size ? size : this.seed.length; | ||
this.length = permutation(this.seed.length, this.size); | ||
@@ -278,3 +282,4 @@ Object.freeze(this); | ||
this.seed = [...seed]; | ||
this.size = 0 < size && size <= this.seed.length ? size : this.seed.length; | ||
this.size = 0 < size ? size : this.seed.length; | ||
this.size = size; | ||
this.length = combination(this.seed.length, this.size); | ||
@@ -281,0 +286,0 @@ this.comb = combinadic(this.seed.length, this.size); |
{ | ||
"name": "js-combinatorics", | ||
"version": "1.4.3", | ||
"version": "1.4.4", | ||
"description": "Simple combinatorics like power set, combination, and permutation in JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "combinatorics.js", |
@@ -29,3 +29,3 @@ [![build status](https://secure.travis-ci.org/dankogai/js-combinatorics.png)](http://travis-ci.org/dankogai/js-combinatorics) | ||
```javascript | ||
import * as $C from 'js-combinatorics'; | ||
import * as $C from './combinatorics.js'; | ||
let it = new $C.Combination('abcdefgh', 4); | ||
@@ -42,3 +42,3 @@ for (const elem of it) { | ||
```javascript | ||
import * as Combinatorics from 'js-combinatorics'; | ||
import * as Combinatorics from './combinatorics.js'; | ||
``` | ||
@@ -49,3 +49,3 @@ | ||
```javascript | ||
import { Combination, Permutation} from 'js-combinatorics'; | ||
import { Combination, Permutation } from './combinatorics.js'; | ||
``` | ||
@@ -56,3 +56,3 @@ | ||
```javascript | ||
import * as $C from 'https://cdn.jsdelivr.net/npm/js-combinatorics@1.4.3/combinatorics.min.js'; | ||
import * as $C from 'https://cdn.jsdelivr.net/npm/js-combinatorics@1.4.4/combinatorics.min.js'; | ||
``` | ||
@@ -124,5 +124,6 @@ | ||
> | ||
``` | ||
`./combinatorics.js` is an ECMAScript module but if you still need a UMD or commonjs version, they are available as `./umd/combinatorics.js` and `./commonjs/combinatorics.js` respectively. | ||
## Description | ||
@@ -135,3 +136,3 @@ | ||
```javascript | ||
import { permutation, combination, factorial, randomInteger } from 'js-combinatorics'; | ||
import { permutation, combination, factorial, randomInteger } from './combinatorics.js'; | ||
@@ -158,3 +159,3 @@ permutation(24, 12); // 1295295050649600 | ||
```javascript | ||
import { factoradic, combinadic } from 'js-combinatorics'; | ||
import { factoradic, combinadic } from './combinatorics.js'; | ||
@@ -352,3 +353,3 @@ factoradic(6402373705727999); // [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17] | ||
````javascript | ||
import {Permutation} from 'js-combinatorics'; | ||
import {Permutation} from './combinatorics.js'; | ||
@@ -404,3 +405,3 @@ let it = new Permutation('abcd'); // size 4 is assumed4 | ||
````javascript | ||
import {Combination} from 'js-combinatorics'; | ||
import {Combination} from './combinatorics.js'; | ||
@@ -439,3 +440,3 @@ let it = new Combination('abcd', 2); | ||
````javascript | ||
import {PowerSet} from 'js-combinatorics'; | ||
import {PowerSet} from './combinatorics.js'; | ||
@@ -481,3 +482,3 @@ let it = new PowerSet('abc'); | ||
```javascript | ||
import {BaseN} from 'js-combinatorics'; | ||
import {BaseN} from './combinatorics.js'; | ||
@@ -524,3 +525,3 @@ let it = new BaseN('abc', 3); | ||
```javascript | ||
import {CartesianProduct} from 'js-combinatorics'; | ||
import {CartesianProduct} from './combinatorics.js'; | ||
@@ -527,0 +528,0 @@ let it = new CartesianProduct('012','abc','xyz'); |
@@ -26,3 +26,3 @@ (function (factory) { | ||
*/ | ||
exports.version = '1.4.3'; | ||
exports.version = '1.4.4'; | ||
const _BI = typeof BigInt == 'function' ? BigInt : Number; | ||
@@ -39,2 +39,6 @@ /** | ||
function permutation(n, k) { | ||
if (n < 0) | ||
throw new RangeError(`negative n is not acceptable`); | ||
if (k < 0) | ||
throw new RangeError(`negative k is not acceptable`); | ||
if (0 == k) | ||
@@ -259,3 +263,3 @@ return 1; | ||
this.seed = [...seed]; | ||
this.size = 0 < size && size <= this.seed.length ? size : this.seed.length; | ||
this.size = 0 < size ? size : this.seed.length; | ||
this.length = permutation(this.seed.length, this.size); | ||
@@ -287,3 +291,4 @@ Object.freeze(this); | ||
this.seed = [...seed]; | ||
this.size = 0 < size && size <= this.seed.length ? size : this.seed.length; | ||
this.size = 0 < size ? size : this.seed.length; | ||
this.size = size; | ||
this.length = combination(this.seed.length, this.size); | ||
@@ -290,0 +295,0 @@ this.comb = combinadic(this.seed.length, this.size); |
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
60085
1390
594