3.0.2
This commit is contained in:
parent
41c8b15552
commit
e29be711a7
|
@ -0,0 +1,134 @@
|
||||||
|
|
||||||
|
# Contributor Covenant Code of Conduct
|
||||||
|
|
||||||
|
## Our Pledge
|
||||||
|
|
||||||
|
We as members, contributors, and leaders pledge to make participation in our
|
||||||
|
community a harassment-free experience for everyone, regardless of age, body
|
||||||
|
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||||
|
identity and expression, level of experience, education, socio-economic status,
|
||||||
|
nationality, personal appearance, race, caste, color, religion, or sexual
|
||||||
|
identity and orientation.
|
||||||
|
|
||||||
|
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||||
|
diverse, inclusive, and healthy community.
|
||||||
|
|
||||||
|
## Our Standards
|
||||||
|
|
||||||
|
Examples of behavior that contributes to a positive environment for our
|
||||||
|
community include:
|
||||||
|
|
||||||
|
* Demonstrating empathy and kindness toward other people
|
||||||
|
* Being respectful of differing opinions, viewpoints, and experiences
|
||||||
|
* Giving and gracefully accepting constructive feedback
|
||||||
|
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||||
|
and learning from the experience
|
||||||
|
* Focusing on what is best not just for us as individuals, but for the overall
|
||||||
|
community
|
||||||
|
|
||||||
|
Examples of unacceptable behavior include:
|
||||||
|
|
||||||
|
* The use of sexualized language or imagery, and sexual attention or advances of
|
||||||
|
any kind
|
||||||
|
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||||
|
* Public or private harassment
|
||||||
|
* Publishing others' private information, such as a physical or email address,
|
||||||
|
without their explicit permission
|
||||||
|
* Other conduct which could reasonably be considered inappropriate in a
|
||||||
|
professional setting
|
||||||
|
|
||||||
|
## Enforcement Responsibilities
|
||||||
|
|
||||||
|
Community leaders are responsible for clarifying and enforcing our standards of
|
||||||
|
acceptable behavior and will take appropriate and fair corrective action in
|
||||||
|
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||||
|
or harmful.
|
||||||
|
|
||||||
|
Community leaders have the right and responsibility to remove, edit, or reject
|
||||||
|
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||||
|
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||||
|
decisions when appropriate.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This Code of Conduct applies within all community spaces, and also applies when
|
||||||
|
an individual is officially representing the community in public spaces.
|
||||||
|
Examples of representing our community include using an official e-mail address,
|
||||||
|
posting via an official social media account, or acting as an appointed
|
||||||
|
representative at an online or offline event.
|
||||||
|
|
||||||
|
## Enforcement
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||||
|
reported to the community leaders responsible for enforcement at
|
||||||
|
[INSERT CONTACT METHOD].
|
||||||
|
All complaints will be reviewed and investigated promptly and fairly.
|
||||||
|
|
||||||
|
All community leaders are obligated to respect the privacy and security of the
|
||||||
|
reporter of any incident.
|
||||||
|
|
||||||
|
## Enforcement Guidelines
|
||||||
|
|
||||||
|
Community leaders will follow these Community Impact Guidelines in determining
|
||||||
|
the consequences for any action they deem in violation of this Code of Conduct:
|
||||||
|
|
||||||
|
### 1. Correction
|
||||||
|
|
||||||
|
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||||
|
unprofessional or unwelcome in the community.
|
||||||
|
|
||||||
|
**Consequence**: A private, written warning from community leaders, providing
|
||||||
|
clarity around the nature of the violation and an explanation of why the
|
||||||
|
behavior was inappropriate. A public apology may be requested.
|
||||||
|
|
||||||
|
### 2. Warning
|
||||||
|
|
||||||
|
**Community Impact**: A violation through a single incident or series of
|
||||||
|
actions.
|
||||||
|
|
||||||
|
**Consequence**: A warning with consequences for continued behavior. No
|
||||||
|
interaction with the people involved, including unsolicited interaction with
|
||||||
|
those enforcing the Code of Conduct, for a specified period of time. This
|
||||||
|
includes avoiding interactions in community spaces as well as external channels
|
||||||
|
like social media. Violating these terms may lead to a temporary or permanent
|
||||||
|
ban.
|
||||||
|
|
||||||
|
### 3. Temporary Ban
|
||||||
|
|
||||||
|
**Community Impact**: A serious violation of community standards, including
|
||||||
|
sustained inappropriate behavior.
|
||||||
|
|
||||||
|
**Consequence**: A temporary ban from any sort of interaction or public
|
||||||
|
communication with the community for a specified period of time. No public or
|
||||||
|
private interaction with the people involved, including unsolicited interaction
|
||||||
|
with those enforcing the Code of Conduct, is allowed during this period.
|
||||||
|
Violating these terms may lead to a permanent ban.
|
||||||
|
|
||||||
|
### 4. Permanent Ban
|
||||||
|
|
||||||
|
**Community Impact**: Demonstrating a pattern of violation of community
|
||||||
|
standards, including sustained inappropriate behavior, harassment of an
|
||||||
|
individual, or aggression toward or disparagement of classes of individuals.
|
||||||
|
|
||||||
|
**Consequence**: A permanent ban from any sort of public interaction within the
|
||||||
|
community.
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||||
|
version 2.1, available at
|
||||||
|
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
||||||
|
|
||||||
|
Community Impact Guidelines were inspired by
|
||||||
|
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
||||||
|
|
||||||
|
For answers to common questions about this code of conduct, see the FAQ at
|
||||||
|
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
||||||
|
[https://www.contributor-covenant.org/translations][translations].
|
||||||
|
|
||||||
|
[homepage]: https://www.contributor-covenant.org
|
||||||
|
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
||||||
|
[Mozilla CoC]: https://github.com/mozilla/diversity
|
||||||
|
[FAQ]: https://www.contributor-covenant.org/faq
|
||||||
|
[translations]: https://www.contributor-covenant.org/translations
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
import { mkdirSync, readFileSync, writeFileSync } from 'fs'
|
||||||
|
import ts from 'typescript'
|
||||||
|
import { join, dirname } from 'path'
|
||||||
|
import { sync } from 'rimraf'
|
||||||
|
|
||||||
|
const { readJsonConfigFile, sys, parseJsonSourceFileConfigFileContent, createCompilerHost, createProgram } = ts
|
||||||
|
|
||||||
|
const rootDir = join(__dirname, '..')
|
||||||
|
const pkgJson = JSON.parse(readFileSync(join(rootDir, 'package.json')))
|
||||||
|
const srcFile = join(rootDir, 'src/ts/index.ts')
|
||||||
|
const outDir = dirname(join(rootDir, pkgJson.types))
|
||||||
|
|
||||||
|
const tsConfigPath = join(rootDir, 'tsconfig.json')
|
||||||
|
|
||||||
|
const configFile = readJsonConfigFile(tsConfigPath, (file) => {
|
||||||
|
return sys.readFile(file)
|
||||||
|
})
|
||||||
|
|
||||||
|
const tsConfig = parseJsonSourceFileConfigFileContent(configFile, sys, dirname(tsConfigPath))
|
||||||
|
|
||||||
|
const compilerOptions = {
|
||||||
|
...tsConfig.options,
|
||||||
|
declaration: true,
|
||||||
|
declarationMap: true,
|
||||||
|
emitDeclarationOnly: true,
|
||||||
|
outDir
|
||||||
|
}
|
||||||
|
|
||||||
|
const host = createCompilerHost(compilerOptions)
|
||||||
|
|
||||||
|
host.writeFile = (fileName, contents) => {
|
||||||
|
mkdirSync(dirname(fileName), { recursive: true })
|
||||||
|
writeFileSync(fileName, contents)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const compile = () => {
|
||||||
|
// Clear the types dir
|
||||||
|
sync(outDir)
|
||||||
|
// Prepare and emit the d.ts files
|
||||||
|
const program = createProgram([srcFile], compilerOptions, host)
|
||||||
|
program.emit()
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
function n(n){return n>=0?n:-n}function t(n){if("number"==typeof n&&(n=BigInt(n)),1n===n)return 1;let t=1;do{t++}while((n>>=1n)>1n);return t}function r(n,t){if("number"==typeof n&&(n=BigInt(n)),"number"==typeof t&&(t=BigInt(t)),n<=0n||t<=0n)throw new RangeError("a and b MUST be > 0");let r=0n,e=1n,o=1n,u=0n;for(;0n!==n;){const i=t/n,f=t%n,g=r-o*i,b=e-u*i;t=n,n=f,r=o,e=u,o=g,u=b}return{g:t,x:r,y:e}}function e(t,r){let e="number"==typeof t?BigInt(n(t)):n(t),o="number"==typeof r?BigInt(n(r)):n(r);if(0n===e)return o;if(0n===o)return e;let u=0n;for(;0n===(1n&(e|o));)e>>=1n,o>>=1n,u++;for(;0n===(1n&e);)e>>=1n;do{for(;0n===(1n&o);)o>>=1n;if(e>o){const n=e;e=o,o=n}o-=e}while(0n!==o);return e<<u}function o(t,r){return"number"==typeof t&&(t=BigInt(t)),"number"==typeof r&&(r=BigInt(r)),0n===t&&0n===r?BigInt(0):n(t/e(t,r)*r)}function u(n,t){return n>=t?n:t}function i(n,t){return n>=t?t:n}function f(n,t){if("number"==typeof n&&(n=BigInt(n)),"number"==typeof t&&(t=BigInt(t)),t<=0n)throw new RangeError("n must be > 0");const r=n%t;return r<0n?r+t:r}function g(n,t){const e=r(f(n,t),t);if(1n!==e.g)throw new RangeError(`${n.toString()} does not have inverse modulo ${t.toString()}`);return f(e.x,t)}function b(t,r,e){if("number"==typeof t&&(t=BigInt(t)),"number"==typeof r&&(r=BigInt(r)),"number"==typeof e&&(e=BigInt(e)),e<=0n)throw new RangeError("n must be > 0");if(1n===e)return 0n;if(t=f(t,e),r<0n)return g(b(t,n(r),e),e);let o=1n;for(;r>0;)r%2n===1n&&(o=o*t%e),r/=2n,t=t**2n%e;return o}export{n as abs,t as bitLength,r as eGcd,e as gcd,o as lcm,u as max,i as min,g as modInv,b as modPow,f as toZn};
|
|
@ -0,0 +1 @@
|
||||||
|
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.
|
22
docs/API.md
22
docs/API.md
|
@ -1,4 +1,4 @@
|
||||||
# bigint-mod-arith - v3.0.1
|
# bigint-mod-arith - v3.0.2
|
||||||
|
|
||||||
Some common functions for modular arithmetic using native JS implementation of BigInt
|
Some common functions for modular arithmetic using native JS implementation of BigInt
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ The absolute value of a
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[abs.ts:8](https://github.com/juanelas/bigint-mod-arith/blob/09f1243/src/ts/abs.ts#L8)
|
[abs.ts:8](https://github.com/juanelas/bigint-mod-arith/blob/41c8b15/src/ts/abs.ts#L8)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ The bit length
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[bitLength.ts:7](https://github.com/juanelas/bigint-mod-arith/blob/09f1243/src/ts/bitLength.ts#L7)
|
[bitLength.ts:7](https://github.com/juanelas/bigint-mod-arith/blob/41c8b15/src/ts/bitLength.ts#L7)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ A triple (g, x, y), such that ax + by = g = gcd(a, b).
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[egcd.ts:18](https://github.com/juanelas/bigint-mod-arith/blob/09f1243/src/ts/egcd.ts#L18)
|
[egcd.ts:18](https://github.com/juanelas/bigint-mod-arith/blob/41c8b15/src/ts/egcd.ts#L18)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ The greatest common divisor of a and b
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[gcd.ts:10](https://github.com/juanelas/bigint-mod-arith/blob/09f1243/src/ts/gcd.ts#L10)
|
[gcd.ts:10](https://github.com/juanelas/bigint-mod-arith/blob/41c8b15/src/ts/gcd.ts#L10)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ The least common multiple of a and b
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[lcm.ts:10](https://github.com/juanelas/bigint-mod-arith/blob/09f1243/src/ts/lcm.ts#L10)
|
[lcm.ts:10](https://github.com/juanelas/bigint-mod-arith/blob/41c8b15/src/ts/lcm.ts#L10)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ Maximum of numbers a and b
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[max.ts:9](https://github.com/juanelas/bigint-mod-arith/blob/09f1243/src/ts/max.ts#L9)
|
[max.ts:9](https://github.com/juanelas/bigint-mod-arith/blob/41c8b15/src/ts/max.ts#L9)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ Minimum of numbers a and b
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[min.ts:9](https://github.com/juanelas/bigint-mod-arith/blob/09f1243/src/ts/min.ts#L9)
|
[min.ts:9](https://github.com/juanelas/bigint-mod-arith/blob/41c8b15/src/ts/min.ts#L9)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ The inverse modulo n
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[modInv.ts:14](https://github.com/juanelas/bigint-mod-arith/blob/09f1243/src/ts/modInv.ts#L14)
|
[modInv.ts:14](https://github.com/juanelas/bigint-mod-arith/blob/41c8b15/src/ts/modInv.ts#L14)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ b**e mod n
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[modPow.ts:16](https://github.com/juanelas/bigint-mod-arith/blob/09f1243/src/ts/modPow.ts#L16)
|
[modPow.ts:16](https://github.com/juanelas/bigint-mod-arith/blob/41c8b15/src/ts/modPow.ts#L16)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
@ -284,4 +284,4 @@ A bigint with the smallest positive representation of a modulo n
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[toZn.ts:15](https://github.com/juanelas/bigint-mod-arith/blob/09f1243/src/ts/toZn.ts#L15)
|
[toZn.ts:15](https://github.com/juanelas/bigint-mod-arith/blob/41c8b15/src/ts/toZn.ts#L15)
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[egcd.ts:2](https://github.com/juanelas/bigint-mod-arith/blob/09f1243/src/ts/egcd.ts#L2)
|
[egcd.ts:2](https://github.com/juanelas/bigint-mod-arith/blob/41c8b15/src/ts/egcd.ts#L2)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ ___
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[egcd.ts:3](https://github.com/juanelas/bigint-mod-arith/blob/09f1243/src/ts/egcd.ts#L3)
|
[egcd.ts:3](https://github.com/juanelas/bigint-mod-arith/blob/41c8b15/src/ts/egcd.ts#L3)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
@ -36,4 +36,4 @@ ___
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[egcd.ts:4](https://github.com/juanelas/bigint-mod-arith/blob/09f1243/src/ts/egcd.ts#L4)
|
[egcd.ts:4](https://github.com/juanelas/bigint-mod-arith/blob/41c8b15/src/ts/egcd.ts#L4)
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "bigint-mod-arith",
|
"name": "bigint-mod-arith",
|
||||||
"version": "3.0.1",
|
"version": "3.0.2",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "bigint-mod-arith",
|
"name": "bigint-mod-arith",
|
||||||
"version": "3.0.1",
|
"version": "3.0.2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rollup/plugin-commonjs": "^21.0.0",
|
"@rollup/plugin-commonjs": "^21.0.0",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "bigint-mod-arith",
|
"name": "bigint-mod-arith",
|
||||||
"version": "3.0.1",
|
"version": "3.0.2",
|
||||||
"description": "Some common functions for modular arithmetic using native JS implementation of BigInt",
|
"description": "Some common functions for modular arithmetic using native JS implementation of BigInt",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"modular arithmetics",
|
"modular arithmetics",
|
||||||
|
@ -110,4 +110,4 @@
|
||||||
"typedoc-plugin-markdown": "^3.11.0",
|
"typedoc-plugin-markdown": "^3.11.0",
|
||||||
"typescript": "^4.4.3"
|
"typescript": "^4.4.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue