From e29be711a78e69831f4a586160491d8ea98a83e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Hern=C3=A1ndez=20Serrano?= Date: Mon, 17 Jan 2022 11:05:33 +0100 Subject: [PATCH] 3.0.2 --- CODE_OF_CONDUCT.md | 134 +++++++++++++++++++++++++++++++++++++ build/rollup-plugin-dts.js | 42 ++++++++++++ dist/bundles/esm.min.js | 1 + docs/.nojekyll | 1 + docs/API.md | 22 +++--- docs/interfaces/Egcd.md | 6 +- package-lock.json | 4 +- package.json | 4 +- 8 files changed, 196 insertions(+), 18 deletions(-) create mode 100644 CODE_OF_CONDUCT.md create mode 100644 build/rollup-plugin-dts.js create mode 100644 dist/bundles/esm.min.js create mode 100644 docs/.nojekyll diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..d33878e --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -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 + diff --git a/build/rollup-plugin-dts.js b/build/rollup-plugin-dts.js new file mode 100644 index 0000000..e9583cf --- /dev/null +++ b/build/rollup-plugin-dts.js @@ -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() +} diff --git a/dist/bundles/esm.min.js b/dist/bundles/esm.min.js new file mode 100644 index 0000000..1e96a87 --- /dev/null +++ b/dist/bundles/esm.min.js @@ -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<=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}; diff --git a/docs/.nojekyll b/docs/.nojekyll new file mode 100644 index 0000000..e2ac661 --- /dev/null +++ b/docs/.nojekyll @@ -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. \ No newline at end of file diff --git a/docs/API.md b/docs/API.md index d75174b..662aec5 100644 --- a/docs/API.md +++ b/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 @@ -43,7 +43,7 @@ The absolute value of a #### 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 -[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 -[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 -[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 -[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 -[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 -[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 -[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 -[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 -[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) diff --git a/docs/interfaces/Egcd.md b/docs/interfaces/Egcd.md index a9e2a79..67af55f 100644 --- a/docs/interfaces/Egcd.md +++ b/docs/interfaces/Egcd.md @@ -16,7 +16,7 @@ #### 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 -[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 -[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) diff --git a/package-lock.json b/package-lock.json index 67436e6..8064c51 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bigint-mod-arith", - "version": "3.0.1", + "version": "3.0.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "bigint-mod-arith", - "version": "3.0.1", + "version": "3.0.2", "license": "MIT", "devDependencies": { "@rollup/plugin-commonjs": "^21.0.0", diff --git a/package.json b/package.json index b21d5bd..7f24424 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "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", "keywords": [ "modular arithmetics", @@ -110,4 +110,4 @@ "typedoc-plugin-markdown": "^3.11.0", "typescript": "^4.4.3" } -} \ No newline at end of file +}