Skip to content

Commit a35bfef

Browse files
committed
Refactor exports in combinatorics.js to improve readability and maintainability
1 parent 7b80ee9 commit a35bfef

3 files changed

Lines changed: 75 additions & 26 deletions

File tree

.gitignore

Lines changed: 61 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ build/Release
4141
node_modules/
4242
jspm_packages/
4343

44-
# TypeScript v1 declaration files
45-
typings/
44+
# Snowpack dependency directory (https://snowpack.dev/)
45+
web_modules/
4646

4747
# TypeScript cache
4848
*.tsbuildinfo
@@ -53,11 +53,8 @@ typings/
5353
# Optional eslint cache
5454
.eslintcache
5555

56-
# Microbundle cache
57-
.rpt2_cache/
58-
.rts2_cache_cjs/
59-
.rts2_cache_es/
60-
.rts2_cache_umd/
56+
# Optional stylelint cache
57+
.stylelintcache
6158

6259
# Optional REPL history
6360
.node_repl_history
@@ -68,29 +65,48 @@ typings/
6865
# Yarn Integrity file
6966
.yarn-integrity
7067

71-
# dotenv environment variables file
68+
# dotenv environment variable files
7269
.env
73-
.env.test
70+
.env.*
71+
!.env.example
7472

7573
# parcel-bundler cache (https://parceljs.org/)
7674
.cache
75+
.parcel-cache
7776

7877
# Next.js build output
7978
.next
79+
out
8080

8181
# Nuxt.js build / generate output
8282
.nuxt
8383
dist
84+
.output
8485

8586
# Gatsby files
8687
.cache/
87-
# Comment in the public line in if your project uses Gatsby and *not* Next.js
88+
# Comment in the public line in if your project uses Gatsby and not Next.js
8889
# https://nextjs.org/blog/next-9-1#public-directory-support
8990
# public
9091

9192
# vuepress build output
9293
.vuepress/dist
9394

95+
# vuepress v2.x temp directory
96+
.temp
97+
98+
# Sveltekit cache directory
99+
.svelte-kit/
100+
101+
# vitepress build output
102+
**/.vitepress/dist
103+
104+
# vitepress cache directory
105+
**/.vitepress/cache
106+
107+
# Docusaurus cache and generated files
108+
.docusaurus
109+
94110
# Serverless directories
95111
.serverless/
96112

@@ -100,8 +116,41 @@ dist
100116
# DynamoDB Local files
101117
.dynamodb/
102118

119+
# Firebase cache directory
120+
.firebase/
121+
103122
# TernJS port file
104123
.tern-port
105124

106-
# ignore all . folders but include . files
107-
.*/
125+
# Stores VSCode versions used for testing VSCode extensions
126+
.vscode-test
127+
128+
# pnpm
129+
.pnpm-store
130+
131+
# yarn v3
132+
.pnp.*
133+
.yarn/*
134+
!.yarn/patches
135+
!.yarn/plugins
136+
!.yarn/releases
137+
!.yarn/sdks
138+
!.yarn/versions
139+
140+
# Vite files
141+
vite.config.js.timestamp-*
142+
vite.config.ts.timestamp-*
143+
.vite/
144+
145+
# Good Old File Extensions
146+
*,v
147+
*.bak
148+
149+
# VSCode
150+
.vscode/
151+
152+
# Claude Code
153+
.claude/
154+
155+
# Anything out of the sight of git
156+
.attic/

commonjs/combinatorics.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3-
exports.CartesianProduct = exports.PowerSet = exports.BaseN = exports.Combination = exports.Permutation = exports.randomInteger = exports.combinadic = exports.factoradic = exports.factorial = exports.combination = exports.permutation = exports.version = void 0;
3+
exports.CartesianProduct = exports.PowerSet = exports.BaseN = exports.Combination = exports.Permutation = exports.version = void 0;
4+
exports.permutation = permutation;
5+
exports.combination = combination;
6+
exports.factorial = factorial;
7+
exports.factoradic = factoradic;
8+
exports.combinadic = combinadic;
9+
exports.randomInteger = randomInteger;
410
/**
511
* combinatorics.js
612
*
@@ -35,7 +41,6 @@ function permutation(n, k) {
3541
bp *= bn--;
3642
return bp;
3743
}
38-
exports.permutation = permutation;
3944
/**
4045
* calculates `C(n, k)`.
4146
*
@@ -50,7 +55,6 @@ function combination(n, k) {
5055
return 0n;
5156
return permutation(n, k) / permutation(k, k);
5257
}
53-
exports.combination = combination;
5458
/**
5559
* calculates `n!` === `P(n, n)`.
5660
*
@@ -59,7 +63,6 @@ exports.combination = combination;
5963
function factorial(n) {
6064
return permutation(n, n);
6165
}
62-
exports.factorial = factorial;
6366
/**
6467
* returns the factoradic representation of `n`, least significant order.
6568
*
@@ -86,7 +89,6 @@ function factoradic(n, l = 0) {
8689
}
8790
return digits;
8891
}
89-
exports.factoradic = factoradic;
9092
/**
9193
* `combinadic(n, k)` returns a function
9294
* that takes `m` as an argument and
@@ -114,7 +116,6 @@ function combinadic(n, k) {
114116
return digits;
115117
};
116118
}
117-
exports.combinadic = combinadic;
118119
/**
119120
*
120121
*/
@@ -150,7 +151,6 @@ function randomInteger(min = 0, max = Math.pow(2, 53)) {
150151
const rnd = u8s.reduce((a, v) => ((a << ctor(8)) + ctor(v)), ctor(0));
151152
return ((ctor(rnd) * mag) >> ctor(len * 8)) + ctor(min);
152153
}
153-
exports.randomInteger = randomInteger;
154154
;
155155
/**
156156
* Base Class of `js-combinatorics`

umd/combinatorics.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@
99
})(function (require, exports) {
1010
"use strict";
1111
Object.defineProperty(exports, "__esModule", { value: true });
12-
exports.CartesianProduct = exports.PowerSet = exports.BaseN = exports.Combination = exports.Permutation = exports.randomInteger = exports.combinadic = exports.factoradic = exports.factorial = exports.combination = exports.permutation = exports.version = void 0;
12+
exports.CartesianProduct = exports.PowerSet = exports.BaseN = exports.Combination = exports.Permutation = exports.version = void 0;
13+
exports.permutation = permutation;
14+
exports.combination = combination;
15+
exports.factorial = factorial;
16+
exports.factoradic = factoradic;
17+
exports.combinadic = combinadic;
18+
exports.randomInteger = randomInteger;
1319
/**
1420
* combinatorics.js
1521
*
@@ -44,7 +50,6 @@
4450
bp *= bn--;
4551
return bp;
4652
}
47-
exports.permutation = permutation;
4853
/**
4954
* calculates `C(n, k)`.
5055
*
@@ -59,7 +64,6 @@
5964
return 0n;
6065
return permutation(n, k) / permutation(k, k);
6166
}
62-
exports.combination = combination;
6367
/**
6468
* calculates `n!` === `P(n, n)`.
6569
*
@@ -68,7 +72,6 @@
6872
function factorial(n) {
6973
return permutation(n, n);
7074
}
71-
exports.factorial = factorial;
7275
/**
7376
* returns the factoradic representation of `n`, least significant order.
7477
*
@@ -95,7 +98,6 @@
9598
}
9699
return digits;
97100
}
98-
exports.factoradic = factoradic;
99101
/**
100102
* `combinadic(n, k)` returns a function
101103
* that takes `m` as an argument and
@@ -123,7 +125,6 @@
123125
return digits;
124126
};
125127
}
126-
exports.combinadic = combinadic;
127128
/**
128129
*
129130
*/
@@ -159,7 +160,6 @@
159160
const rnd = u8s.reduce((a, v) => ((a << ctor(8)) + ctor(v)), ctor(0));
160161
return ((ctor(rnd) * mag) >> ctor(len * 8)) + ctor(min);
161162
}
162-
exports.randomInteger = randomInteger;
163163
;
164164
/**
165165
* Base Class of `js-combinatorics`

0 commit comments

Comments
 (0)