support for node 10. New builder scripts

This commit is contained in:
Juan Hernández Serrano 2021-08-07 00:14:30 +02:00
parent 12186fd951
commit 5b2686bbc9
56 changed files with 2479 additions and 1800 deletions

View File

@ -23,6 +23,12 @@ Then either require (Node.js CJS):
const bigintModArith = require('bigint-mod-arith') const bigintModArith = require('bigint-mod-arith')
``` ```
> **Node >=10.4 <11**. `bigint-mod-arith` uses workers to speed up some operations. Workers are enabled by default with Node.js from version 11. In order to use them with Node >=10.4 and <11, you need to execute node with the flag `--experimental-worker`, and require the .js file manually (otherwise .cjs is required by default and would not be supported by the workers)
>
> ```javascript
> const bigintCryptoUtils = require('bigint-crypto-utils/dist/cjs/index.node') // ONLY FOR node >=10.4 <11 !
> ```
or import (JavaScript ES module): or import (JavaScript ES module):
```javascript ```javascript
@ -31,7 +37,7 @@ import * as bigintModArith from 'bigint-mod-arith'
The appropriate version for browser or node is automatically exported. The appropriate version for browser or node is automatically exported.
You can also download the [IIFE bundle](https://raw.githubusercontent.com/juanelas/bigint-mod-arith/master/dist/bundles/bigint-mod-arith.iife.js), the [ESM bundle](https://raw.githubusercontent.com/juanelas/bigint-mod-arith/master/dist/bundles/bigint-mod-arith.esm.js) or the [UMD bundle](https://raw.githubusercontent.com/juanelas/bigint-mod-arith/master/dist/bundles/bigint-mod-arith.umd.js) and manually add it to your project, or, if you have already imported `bigint-mod-arith` to your project, just get the bundles from `node_modules/bigint-mod-arith/dist/bundles/`. You can also download the [IIFE bundle](https://raw.githubusercontent.com/juanelas/bigint-mod-arith/master/dist/bundles/iife.js), the [ESM bundle](https://raw.githubusercontent.com/juanelas/bigint-mod-arith/master/dist/bundles/esm.js) or the [UMD bundle](https://raw.githubusercontent.com/juanelas/bigint-mod-arith/master/dist/bundles/umd.js) and manually add it to your project, or, if you have already imported `bigint-mod-arith` to your project, just get the bundles from `node_modules/bigint-mod-arith/dist/bundles/`.
An example of usage could be: An example of usage could be:

View File

@ -23,11 +23,12 @@ async function typedoc () {
app.bootstrap({ app.bootstrap({
// typedoc options here // typedoc options here
entryPoints: ['src/index.ts'], entryPoints: ['src/ts/index.ts'],
plugin: ['typedoc-plugin-markdown'], plugin: ['typedoc-plugin-markdown'],
includeVersion: true, includeVersion: true,
entryDocument: 'API.md', entryDocument: 'API.md',
readme: 'none' readme: 'none',
hideBreadcrumbs: true
}) })
const project = app.convert() const project = app.convert()
@ -49,7 +50,7 @@ function getRepositoryData () {
return { return {
repoProvider, repoProvider,
repoUsername: repodata[1], repoUsername: repodata[1],
repoName: repodata[2] repoName: repodata.slice(2).join('/')
} }
} else return null } else return null
} }
@ -61,21 +62,25 @@ const regex = /^(?:(?<scope>@.*?)\/)?(?<name>.*)/ // We are going to take only t
const { name } = pkgJson.name.match(regex).groups const { name } = pkgJson.name.match(regex).groups
const camelCaseName = camelise(name) const camelCaseName = camelise(name)
const iifeBundlePath = path.relative('.', pkgJson.exports['./iife-browser-bundle'])
const esmBundlePath = path.relative('.', pkgJson.exports['./esm-browser-bundle'])
const umdBundlePath = path.relative('.', pkgJson.exports['./umd-browser-bundle'])
let iifeBundle, esmBundle, umdBundle, workflowBadget, coverallsBadge let iifeBundle, esmBundle, umdBundle, workflowBadget, coverallsBadge
if (repoProvider) { if (repoProvider) {
switch (repoProvider) { switch (repoProvider) {
case 'github': case 'github':
iifeBundle = `[IIFE bundle](https://raw.githubusercontent.com/${repoUsername}/${repoName}/master/dist/bundles/${name}.iife.js)` iifeBundle = `[IIFE bundle](https://raw.githubusercontent.com/${repoUsername}/${repoName}/master/${iifeBundlePath})`
esmBundle = `[ESM bundle](https://raw.githubusercontent.com/${repoUsername}/${repoName}/master/dist/bundles/${name}.esm.js)` esmBundle = `[ESM bundle](https://raw.githubusercontent.com/${repoUsername}/${repoName}/master/${esmBundlePath})`
umdBundle = `[UMD bundle](https://raw.githubusercontent.com/${repoUsername}/${repoName}/master/dist/bundles/${name}.umd.js)` umdBundle = `[UMD bundle](https://raw.githubusercontent.com/${repoUsername}/${repoName}/master/${umdBundlePath})`
workflowBadget = `[![Node CI](https://github.com/${repoUsername}/${repoName}/workflows/Node%20CI/badge.svg)](https://github.com/${repoUsername}/${repoName}/actions?query=workflow%3A%22Node+CI%22)` workflowBadget = `[![Node CI](https://github.com/${repoUsername}/${repoName}/workflows/Node%20CI/badge.svg)](https://github.com/${repoUsername}/${repoName}/actions?query=workflow%3A%22Node+CI%22)`
coverallsBadge = `[![Coverage Status](https://coveralls.io/repos/github/${repoUsername}/${repoName}/badge.svg?branch=master)](https://coveralls.io/github/${repoUsername}/${repoName}?branch=master)` coverallsBadge = `[![Coverage Status](https://coveralls.io/repos/github/${repoUsername}/${repoName}/badge.svg?branch=master)](https://coveralls.io/github/${repoUsername}/${repoName}?branch=master)`
break break
case 'gitlab': case 'gitlab':
iifeBundle = `[IIFE bundle](https://gitlab.com/${repoUsername}/${repoName}/-/raw/master/dist/bundles/${name}.iife.js?inline=false)` iifeBundle = `[IIFE bundle](https://gitlab.com/${repoUsername}/${repoName}/-/raw/master/dist/${iifeBundlePath}?inline=false)`
esmBundle = `[ESM bundle](https://gitlab.com/${repoUsername}/${repoName}/-/raw/master/dist/bundles/${name}.esm.js?inline=false)` esmBundle = `[ESM bundle](https://gitlab.com/${repoUsername}/${repoName}/-/raw/master/dist/${esmBundlePath}?inline=false)`
umdBundle = `[IIFE bundle](https://gitlab.com/${repoUsername}/${repoName}/-/raw/master/dist/bundles/${name}.umd.js?inline=false)` umdBundle = `[UMD bundle](https://gitlab.com/${repoUsername}/${repoName}/-/raw/master/dist/${umdBundlePath}?inline=false)`
break break
default: default:
@ -93,6 +98,8 @@ let template = fs.readFileSync(templateFile, { encoding: 'UTF-8' })
if (repoProvider && repoProvider === 'github') { if (repoProvider && repoProvider === 'github') {
template = template.replace(/\{\{GITHUB_ACTIONS_BADGES\}\}/g, workflowBadget + '\n' + coverallsBadge) template = template.replace(/\{\{GITHUB_ACTIONS_BADGES\}\}/g, workflowBadget + '\n' + coverallsBadge)
} else {
template = template.replace(/\{\{GITHUB_ACTIONS_BADGES\}\}/g, '')
} }
const readmeFile = path.join(rootDir, 'README.md') const readmeFile = path.join(rootDir, 'README.md')

View File

@ -1,18 +1,18 @@
'use strict' 'use strict'
const resolve = require('@rollup/plugin-node-resolve').nodeResolve import { nodeResolve as resolve } from '@rollup/plugin-node-resolve'
const replace = require('@rollup/plugin-replace') import replace from '@rollup/plugin-replace'
const { terser } = require('rollup-plugin-terser') import { terser } from 'rollup-plugin-terser'
const typescriptPlugin = require('@rollup/plugin-typescript') import typescriptPlugin from '@rollup/plugin-typescript'
const commonjs = require('@rollup/plugin-commonjs') import commonjs from '@rollup/plugin-commonjs'
const path = require('path') import { dirname, join } from 'path'
const fs = require('fs') import { existsSync, moveSync, removeSync } from 'fs-extra'
const pkgJson = require('../package.json') import { directories, name as _name, dependencies, peerDependencies, exports, types } from '../package.json'
const rootDir = path.join(__dirname, '..') const rootDir = join(__dirname, '..')
const dstDir = path.join(rootDir, pkgJson.directories.dist) const dstDir = join(rootDir, directories.dist)
const srcDir = path.join(rootDir, 'src') const srcDir = join(rootDir, 'src', 'ts')
function camelise (str) { function camelise (str) {
return str.replace(/-([a-z])/g, return str.replace(/-([a-z])/g,
@ -22,29 +22,41 @@ function camelise (str) {
} }
const regex = /^(?:(?<scope>@.*?)\/)?(?<name>.*)/ // We are going to take only the package name part if there is a scope, e.g. @my-org/package-name const regex = /^(?:(?<scope>@.*?)\/)?(?<name>.*)/ // We are going to take only the package name part if there is a scope, e.g. @my-org/package-name
const { name } = pkgJson.name.match(regex).groups const { name } = _name.match(regex).groups
const pkgCamelisedName = camelise(name) const pkgCamelisedName = camelise(name)
const input = path.join(srcDir, 'index.ts') const input = join(srcDir, 'index.ts')
if (fs.existsSync(input) !== true) throw new Error('The entry point should be index.ts') if (existsSync(input) !== true) throw new Error('The entry point should be index.ts')
const tsBundleOptions = { const tsBundleOptions = {
tsconfig: join(rootDir, 'tsconfig.json'),
outDir: undefined, // ignore outDir in tsconfig.json
exclude: ['test/**/*', 'src/**/*.spec.ts', './build/typings/global-this-pkg.d.ts'] exclude: ['test/**/*', 'src/**/*.spec.ts', './build/typings/global-this-pkg.d.ts']
} }
const external = [...Object.keys(pkgJson.dependencies || {}), ...Object.keys(pkgJson.peerDependencies || {})] const external = [...Object.keys(dependencies || {}), ...Object.keys(peerDependencies || {})]
const sourcemapOutputOptions = { const sourcemapOutputOptions = {
sourcemap: 'inline', sourcemap: 'inline',
sourcemapExcludeSources: true sourcemapExcludeSources: true
} }
module.exports = [ function moveDirPlugin (srcDir, dstDir) {
return {
name: 'move-dir',
closeBundle () {
removeSync(dstDir)
moveSync(srcDir, dstDir, { overwrite: true })
}
}
}
export default [
{ // ESM for browsers { // ESM for browsers
input: input, input: input,
output: [ output: [
{ {
file: path.join(rootDir, pkgJson.exports['.'].default), file: join(rootDir, exports['.'].default),
...sourcemapOutputOptions, ...sourcemapOutputOptions,
format: 'es' format: 'es'
} }
@ -62,16 +74,16 @@ module.exports = [
input: input, input: input,
output: [ output: [
{ {
file: path.join(dstDir, `bundles/${name}.iife.js`), file: join(dstDir, 'bundles/iife.js'),
format: 'iife', format: 'iife',
name: pkgCamelisedName name: pkgCamelisedName
}, },
{ {
file: path.join(dstDir, `bundles/${name}.esm.js`), file: join(dstDir, 'bundles/esm.js'),
format: 'es' format: 'es'
}, },
{ {
file: path.join(dstDir, `bundles/${name}.umd.js`), file: join(dstDir, 'bundles/umd.js'),
format: 'umd', format: 'umd',
name: pkgCamelisedName name: pkgCamelisedName
} }
@ -89,11 +101,10 @@ module.exports = [
terser() terser()
] ]
}, },
{ // Node ESM { // Node ESM with declaration files
input: input, input: input,
output: { output: {
dir: path.join(rootDir, path.dirname(pkgJson.exports['.'].node.import)), file: join(rootDir, exports['.'].node.import),
entryFileNames: path.basename(pkgJson.exports['.'].node.import),
...sourcemapOutputOptions, ...sourcemapOutputOptions,
format: 'es' format: 'es'
}, },
@ -104,30 +115,37 @@ module.exports = [
}), }),
typescriptPlugin({ typescriptPlugin({
...tsBundleOptions, ...tsBundleOptions,
// outDir: path.join(rootDir, path.dirname(pkgJson.exports['.'].node.import)),
declaration: true, declaration: true,
outDir: path.join(rootDir, path.dirname(pkgJson.exports['.'].node.import)), declarationDir: 'types',
declarationDir: path.join(rootDir, path.dirname(pkgJson.exports['.'].node.import), 'types'),
declarationMap: true declarationMap: true
}), }),
commonjs({ extensions: ['.js', '.ts'] }) // the ".ts" extension is required commonjs({ extensions: ['.js', '.cjs', '.ts'] }), // the ".ts" extension is required
moveDirPlugin(join(rootDir, dirname(exports['.'].node.import), 'types'), join(rootDir, dirname(types)))
], ],
external external
}, },
{ // Node CJS with declaration files { // Node CJS
input: input, input: input,
output: { output: [
dir: path.join(rootDir, path.dirname(pkgJson.exports['.'].node.require)), {
entryFileNames: path.basename(pkgJson.exports['.'].node.require), file: join(rootDir, exports['.'].node.require),
...sourcemapOutputOptions, ...sourcemapOutputOptions,
format: 'cjs' format: 'cjs'
}, },
{
file: join(rootDir, exports['.'].node.require).slice(0, -4) + '.js', // .js extension instead of .cjs for Node 10 support
...sourcemapOutputOptions,
format: 'cjs'
}
],
plugins: [ plugins: [
replace({ replace({
IS_BROWSER: false, IS_BROWSER: false,
preventAssignment: true preventAssignment: true
}), }),
typescriptPlugin(tsBundleOptions), typescriptPlugin(tsBundleOptions),
commonjs({ extensions: ['.js', '.ts'] }) // the ".ts" extension is required commonjs({ extensions: ['.js', '.cjs', '.ts'] }) // the ".ts" extension is required
] ]
} }
] ]

View File

@ -42,7 +42,7 @@ const browserTests = async ({ logWarnings = false, serverPort = 38000, keepServe
page.on('error', function (err) { page.emit(new Error(err)) }) page.on('error', function (err) { page.emit(new Error(err)) })
await page.goto('http://localhost:38000/') await page.goto('http://localhost:38000/')
const watchDog = page.waitForFunction('_mocha.state === \'stopped\'') const watchDog = page.waitForFunction('_mocha.state === \'stopped\'', { timeout: 0 })
await watchDog await watchDog
if (keepServerRunning === false) { if (keepServerRunning === false) {

View File

@ -62,7 +62,8 @@ async function buildTests () {
exportConditions: ['browser', 'module', 'import', 'default'] exportConditions: ['browser', 'module', 'import', 'default']
}), }),
commonjs() commonjs()
] ],
external: [pkgJson.name]
} }
const bundle = await rollup.rollup(inputOptions) const bundle = await rollup.rollup(inputOptions)
const { output } = await bundle.generate({ format: 'esm' }) const { output } = await bundle.generate({ format: 'esm' })
@ -79,7 +80,7 @@ class TestServer {
const tests = await buildTests() const tests = await buildTests()
this.server.on('request', function (req, res) { this.server.on('request', function (req, res) {
if (req.url === `/${name}.esm.js`) { if (req.url === `/${name}.esm.js`) {
fs.readFile(path.join(rootDir, pkgJson.directories.dist, `bundles/${name}.esm.js`), function (err, data) { fs.readFile(path.join(rootDir, pkgJson.directories.dist, 'bundles/esm.js'), function (err, data) {
if (err) { if (err) {
res.writeHead(404) res.writeHead(404)
res.end(JSON.stringify(err)) res.end(JSON.stringify(err))

View File

@ -28,7 +28,8 @@ module.exports = class TestsBuilder extends Builder {
const fileStr = fs.readFileSync(path, 'utf8') const fileStr = fs.readFileSync(path, 'utf8')
const config = JSON5.parse(fileStr) const config = JSON5.parse(fileStr)
if (config.file) delete config.file if (config.file) delete config.file
config.include = ['build/typings/**/*.ts', 'test/**/*.ts', 'src/**/*.spec.ts'] config.include.push('node_modules/**/*.d.ts')
config.compilerOptions.module = 'commonjs'
return JSON.stringify(config) return JSON.stringify(config)
} }
const configFile = ts.readJsonConfigFile(configPath, readFileAndMangle) const configFile = ts.readJsonConfigFile(configPath, readFileAndMangle)
@ -68,7 +69,6 @@ module.exports = class TestsBuilder extends Builder {
...parsedTsConfig.options, ...parsedTsConfig.options,
rootDir, rootDir,
outDir: this.tempDir, outDir: this.tempDir,
module: 'commonjs',
noEmit: false, noEmit: false,
noResolve: true, noResolve: true,
sourceMap: true sourceMap: true

View File

@ -25,13 +25,21 @@ testBuilder.start() // This should be in exports.mochaGlobalSetup but mocha fail
exports.mochaHooks = { exports.mochaHooks = {
beforeAll: [ beforeAll: [
async function () { async function () {
this.timeout('120000')
await Promise.all([rollupBuilder.ready(), testBuilder.ready()])
// Just in case our module had been modified. Reload it when the tests are repeated (for mocha watch mode). // Just in case our module had been modified. Reload it when the tests are repeated (for mocha watch mode).
delete require.cache[require.resolve(rootDir)] delete require.cache[require.resolve(rootDir)]
global._pkg = require(rootDir) global._pkg = require(rootDir)
},
async function () { // And now reset any other transpiled module (just delete the cache so it is fully reloaded)
this.timeout('120000') for (const key in require.cache) {
await Promise.all([rollupBuilder.ready(), testBuilder.ready()]) const relativePath = path.relative(rootDir, key)
if (relativePath.startsWith(`.mocha-ts${path.sep}`)) {
delete require.cache[key]
}
}
} }
] ]
} }

View File

@ -1,5 +1,7 @@
import * as _pkgModule from '../..' import * as _pkgModule from '../..'
export as namespace _pkg declare global {
const _pkg: typeof _pkgModule
}
export as namespace _pkgTypes
export = _pkgModule export = _pkgModule

254
dist/cjs/index.node.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,16 +0,0 @@
/**
* Some common functions for modular arithmetic using native JS implementation of BigInt
*
* @packageDocumentation
*/
export { abs } from './ts/abs';
export { bitLength } from './ts/bitLength';
export { Egcd, eGcd } from './ts/egcd';
export { gcd } from './ts/gcd';
export { lcm } from './ts/lcm';
export { max } from './ts/max';
export { min } from './ts/min';
export { modInv } from './ts/modInv';
export { modPow } from './ts/modPow';
export { toZn } from './ts/toZn';
//# sourceMappingURL=index.d.ts.map

View File

@ -1 +0,0 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA"}

View File

@ -1 +0,0 @@
{"version":3,"file":"abs.d.ts","sourceRoot":"","sources":["../../../../src/ts/abs.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,GAAG,CAAE,CAAC,EAAE,MAAM,GAAC,MAAM,GAAG,MAAM,GAAC,MAAM,CAEpD"}

View File

@ -1 +0,0 @@
{"version":3,"file":"bitLength.d.ts","sourceRoot":"","sources":["../../../../src/ts/bitLength.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,SAAS,CAAE,CAAC,EAAE,MAAM,GAAC,MAAM,GAAG,MAAM,CASnD"}

View File

@ -1 +0,0 @@
{"version":3,"file":"egcd.d.ts","sourceRoot":"","sources":["../../../../src/ts/egcd.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,IAAI;IACnB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AACD;;;;;;;;;;;GAWG;AACH,wBAAgB,IAAI,CAAE,CAAC,EAAE,MAAM,GAAC,MAAM,EAAE,CAAC,EAAE,MAAM,GAAC,MAAM,GAAG,IAAI,CA4B9D"}

View File

@ -1 +0,0 @@
{"version":3,"file":"gcd.d.ts","sourceRoot":"","sources":["../../../../src/ts/gcd.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AACH,wBAAgB,GAAG,CAAE,CAAC,EAAE,MAAM,GAAC,MAAM,EAAE,CAAC,EAAE,MAAM,GAAC,MAAM,GAAG,MAAM,CA6B/D"}

View File

@ -1 +0,0 @@
{"version":3,"file":"lcm.d.ts","sourceRoot":"","sources":["../../../../src/ts/lcm.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,GAAG,CAAE,CAAC,EAAE,MAAM,GAAC,MAAM,EAAE,CAAC,EAAE,MAAM,GAAC,MAAM,GAAG,MAAM,CAM/D"}

View File

@ -1 +0,0 @@
{"version":3,"file":"max.d.ts","sourceRoot":"","sources":["../../../../src/ts/max.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,GAAG,CAAE,CAAC,EAAE,MAAM,GAAC,MAAM,EAAE,CAAC,EAAE,MAAM,GAAC,MAAM,GAAG,MAAM,GAAC,MAAM,CAEtE"}

View File

@ -1 +0,0 @@
{"version":3,"file":"min.d.ts","sourceRoot":"","sources":["../../../../src/ts/min.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,GAAG,CAAE,CAAC,EAAE,MAAM,GAAC,MAAM,EAAE,CAAC,EAAE,MAAM,GAAC,MAAM,GAAG,MAAM,GAAC,MAAM,CAEtE"}

View File

@ -1 +0,0 @@
{"version":3,"file":"modInv.d.ts","sourceRoot":"","sources":["../../../../src/ts/modInv.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAE,CAAC,EAAE,MAAM,GAAC,MAAM,EAAE,CAAC,EAAE,MAAM,GAAC,MAAM,GAAG,MAAM,CAOlE"}

View File

@ -1 +0,0 @@
{"version":3,"file":"modPow.d.ts","sourceRoot":"","sources":["../../../../src/ts/modPow.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CAAE,CAAC,EAAE,MAAM,GAAC,MAAM,EAAE,CAAC,EAAE,MAAM,GAAC,MAAM,EAAE,CAAC,EAAE,MAAM,GAAC,MAAM,GAAG,MAAM,CA0BpF"}

View File

@ -1 +0,0 @@
{"version":3,"file":"toZn.d.ts","sourceRoot":"","sources":["../../../../src/ts/toZn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,IAAI,CAAE,CAAC,EAAE,MAAM,GAAC,MAAM,EAAE,CAAC,EAAE,MAAM,GAAC,MAAM,GAAG,MAAM,CAUhE"}

View File

@ -1,5 +1,3 @@
bigint-mod-arith - v3.0.0
# bigint-mod-arith - v3.0.0 # bigint-mod-arith - v3.0.0
Some common functions for modular arithmetic using native JS implementation of BigInt Some common functions for modular arithmetic using native JS implementation of BigInt
@ -8,7 +6,7 @@ Some common functions for modular arithmetic using native JS implementation of B
### Interfaces ### Interfaces
- [Egcd](interfaces/egcd.md) - [Egcd](interfaces/Egcd.md)
### Functions ### Functions
@ -27,47 +25,55 @@ Some common functions for modular arithmetic using native JS implementation of B
### abs ### abs
**abs**(`a`: *number* \| *bigint*): *number* \| *bigint* **abs**(`a`): `number` \| `bigint`
Absolute value. abs(a)==a if a>=0. abs(a)==-a if a<0 Absolute value. abs(a)==a if a>=0. abs(a)==-a if a<0
#### Parameters: #### Parameters
Name | Type | | Name | Type |
:------ | :------ | | :------ | :------ |
`a` | *number* \| *bigint* | | `a` | `number` \| `bigint` |
**Returns:** *number* \| *bigint* #### Returns
`number` \| `bigint`
The absolute value of a The absolute value of a
Defined in: [ts/abs.ts:8](https://github.com/juanelas/bigint-mod-arith/blob/d947979/src/ts/abs.ts#L8) #### Defined in
[abs.ts:8](https://github.com/juanelas/bigint-mod-arith/blob/12186fd/src/ts/abs.ts#L8)
___ ___
### bitLength ### bitLength
**bitLength**(`a`: *number* \| *bigint*): *number* **bitLength**(`a`): `number`
Returns the bitlength of a number Returns the bitlength of a number
#### Parameters: #### Parameters
Name | Type | | Name | Type |
:------ | :------ | | :------ | :------ |
`a` | *number* \| *bigint* | | `a` | `number` \| `bigint` |
**Returns:** *number* #### Returns
`number`
The bit length The bit length
Defined in: [ts/bitLength.ts:7](https://github.com/juanelas/bigint-mod-arith/blob/d947979/src/ts/bitLength.ts#L7) #### Defined in
[bitLength.ts:7](https://github.com/juanelas/bigint-mod-arith/blob/12186fd/src/ts/bitLength.ts#L7)
___ ___
### eGcd ### eGcd
**eGcd**(`a`: *number* \| *bigint*, `b`: *number* \| *bigint*): [*Egcd*](interfaces/egcd.md) **eGcd**(`a`, `b`): [`Egcd`](interfaces/Egcd.md)
An iterative implementation of the extended euclidean algorithm or extended greatest common divisor algorithm. An iterative implementation of the extended euclidean algorithm or extended greatest common divisor algorithm.
Take positive integers a, b as input, and return a triple (g, x, y), such that ax + by = g = gcd(a, b). Take positive integers a, b as input, and return a triple (g, x, y), such that ax + by = g = gcd(a, b).
@ -75,175 +81,207 @@ Take positive integers a, b as input, and return a triple (g, x, y), such that a
**`throws`** {RangeError} **`throws`** {RangeError}
This excepction is thrown if a or b are less than 0 This excepction is thrown if a or b are less than 0
#### Parameters: #### Parameters
Name | Type | | Name | Type |
:------ | :------ | | :------ | :------ |
`a` | *number* \| *bigint* | | `a` | `number` \| `bigint` |
`b` | *number* \| *bigint* | | `b` | `number` \| `bigint` |
**Returns:** [*Egcd*](interfaces/egcd.md) #### Returns
[`Egcd`](interfaces/Egcd.md)
A triple (g, x, y), such that ax + by = g = gcd(a, b). A triple (g, x, y), such that ax + by = g = gcd(a, b).
Defined in: [ts/egcd.ts:18](https://github.com/juanelas/bigint-mod-arith/blob/d947979/src/ts/egcd.ts#L18) #### Defined in
[egcd.ts:18](https://github.com/juanelas/bigint-mod-arith/blob/12186fd/src/ts/egcd.ts#L18)
___ ___
### gcd ### gcd
**gcd**(`a`: *number* \| *bigint*, `b`: *number* \| *bigint*): *bigint* **gcd**(`a`, `b`): `bigint`
Greatest-common divisor of two integers based on the iterative binary algorithm. Greatest-common divisor of two integers based on the iterative binary algorithm.
#### Parameters: #### Parameters
Name | Type | | Name | Type |
:------ | :------ | | :------ | :------ |
`a` | *number* \| *bigint* | | `a` | `number` \| `bigint` |
`b` | *number* \| *bigint* | | `b` | `number` \| `bigint` |
**Returns:** *bigint* #### Returns
`bigint`
The greatest common divisor of a and b The greatest common divisor of a and b
Defined in: [ts/gcd.ts:10](https://github.com/juanelas/bigint-mod-arith/blob/d947979/src/ts/gcd.ts#L10) #### Defined in
[gcd.ts:10](https://github.com/juanelas/bigint-mod-arith/blob/12186fd/src/ts/gcd.ts#L10)
___ ___
### lcm ### lcm
**lcm**(`a`: *number* \| *bigint*, `b`: *number* \| *bigint*): *bigint* **lcm**(`a`, `b`): `bigint`
The least common multiple computed as abs(a*b)/gcd(a,b) The least common multiple computed as abs(a*b)/gcd(a,b)
#### Parameters: #### Parameters
Name | Type | | Name | Type |
:------ | :------ | | :------ | :------ |
`a` | *number* \| *bigint* | | `a` | `number` \| `bigint` |
`b` | *number* \| *bigint* | | `b` | `number` \| `bigint` |
**Returns:** *bigint* #### Returns
`bigint`
The least common multiple of a and b The least common multiple of a and b
Defined in: [ts/lcm.ts:10](https://github.com/juanelas/bigint-mod-arith/blob/d947979/src/ts/lcm.ts#L10) #### Defined in
[lcm.ts:10](https://github.com/juanelas/bigint-mod-arith/blob/12186fd/src/ts/lcm.ts#L10)
___ ___
### max ### max
**max**(`a`: *number* \| *bigint*, `b`: *number* \| *bigint*): *number* \| *bigint* **max**(`a`, `b`): `number` \| `bigint`
Maximum. max(a,b)==a if a>=b. max(a,b)==b if a<=b Maximum. max(a,b)==a if a>=b. max(a,b)==b if a<=b
#### Parameters: #### Parameters
Name | Type | | Name | Type |
:------ | :------ | | :------ | :------ |
`a` | *number* \| *bigint* | | `a` | `number` \| `bigint` |
`b` | *number* \| *bigint* | | `b` | `number` \| `bigint` |
**Returns:** *number* \| *bigint* #### Returns
`number` \| `bigint`
Maximum of numbers a and b Maximum of numbers a and b
Defined in: [ts/max.ts:9](https://github.com/juanelas/bigint-mod-arith/blob/d947979/src/ts/max.ts#L9) #### Defined in
[max.ts:9](https://github.com/juanelas/bigint-mod-arith/blob/12186fd/src/ts/max.ts#L9)
___ ___
### min ### min
**min**(`a`: *number* \| *bigint*, `b`: *number* \| *bigint*): *number* \| *bigint* **min**(`a`, `b`): `number` \| `bigint`
Minimum. min(a,b)==b if a>=b. min(a,b)==a if a<=b Minimum. min(a,b)==b if a>=b. min(a,b)==a if a<=b
#### Parameters: #### Parameters
Name | Type | | Name | Type |
:------ | :------ | | :------ | :------ |
`a` | *number* \| *bigint* | | `a` | `number` \| `bigint` |
`b` | *number* \| *bigint* | | `b` | `number` \| `bigint` |
**Returns:** *number* \| *bigint* #### Returns
`number` \| `bigint`
Minimum of numbers a and b Minimum of numbers a and b
Defined in: [ts/min.ts:9](https://github.com/juanelas/bigint-mod-arith/blob/d947979/src/ts/min.ts#L9) #### Defined in
[min.ts:9](https://github.com/juanelas/bigint-mod-arith/blob/12186fd/src/ts/min.ts#L9)
___ ___
### modInv ### modInv
**modInv**(`a`: *number* \| *bigint*, `n`: *number* \| *bigint*): *bigint* **modInv**(`a`, `n`): `bigint`
Modular inverse. Modular inverse.
**`throws`** {RangeError} **`throws`** {RangeError}
Excpeption thorwn when a does not have inverse modulo n Excpeption thorwn when a does not have inverse modulo n
#### Parameters: #### Parameters
Name | Type | Description | | Name | Type | Description |
:------ | :------ | :------ | | :------ | :------ | :------ |
`a` | *number* \| *bigint* | The number to find an inverse for | | `a` | `number` \| `bigint` | The number to find an inverse for |
`n` | *number* \| *bigint* | The modulo | | `n` | `number` \| `bigint` | The modulo |
**Returns:** *bigint* #### Returns
`bigint`
The inverse modulo n The inverse modulo n
Defined in: [ts/modInv.ts:14](https://github.com/juanelas/bigint-mod-arith/blob/d947979/src/ts/modInv.ts#L14) #### Defined in
[modInv.ts:14](https://github.com/juanelas/bigint-mod-arith/blob/12186fd/src/ts/modInv.ts#L14)
___ ___
### modPow ### modPow
**modPow**(`b`: *number* \| *bigint*, `e`: *number* \| *bigint*, `n`: *number* \| *bigint*): *bigint* **modPow**(`b`, `e`, `n`): `bigint`
Modular exponentiation b**e mod n. Currently using the right-to-left binary method Modular exponentiation b**e mod n. Currently using the right-to-left binary method
**`throws`** {RangeError} **`throws`** {RangeError}
Excpeption thrown when n is not > 0 Excpeption thrown when n is not > 0
#### Parameters: #### Parameters
Name | Type | Description | | Name | Type | Description |
:------ | :------ | :------ | | :------ | :------ | :------ |
`b` | *number* \| *bigint* | base | | `b` | `number` \| `bigint` | base |
`e` | *number* \| *bigint* | exponent | | `e` | `number` \| `bigint` | exponent |
`n` | *number* \| *bigint* | modulo | | `n` | `number` \| `bigint` | modulo |
**Returns:** *bigint* #### Returns
`bigint`
b**e mod n b**e mod n
Defined in: [ts/modPow.ts:16](https://github.com/juanelas/bigint-mod-arith/blob/d947979/src/ts/modPow.ts#L16) #### Defined in
[modPow.ts:16](https://github.com/juanelas/bigint-mod-arith/blob/12186fd/src/ts/modPow.ts#L16)
___ ___
### toZn ### toZn
**toZn**(`a`: *number* \| *bigint*, `n`: *number* \| *bigint*): *bigint* **toZn**(`a`, `n`): `bigint`
Finds the smallest positive element that is congruent to a in modulo n Finds the smallest positive element that is congruent to a in modulo n
**`remarks`** **`remarks`**
a and b must be the same type, either number or bigint a and b must be the same type, either number or bigint
**`throws`** {RangeError} **`throws`** {RangeError}
Excpeption thrown when n is not > 0 Excpeption thrown when n is not > 0
#### Parameters: #### Parameters
Name | Type | Description | | Name | Type | Description |
:------ | :------ | :------ | | :------ | :------ | :------ |
`a` | *number* \| *bigint* | An integer | | `a` | `number` \| `bigint` | An integer |
`n` | *number* \| *bigint* | The modulo | | `n` | `number` \| `bigint` | The modulo |
**Returns:** *bigint* #### Returns
`bigint`
A bigint with the smallest positive representation of a modulo n A bigint with the smallest positive representation of a modulo n
Defined in: [ts/toZn.ts:15](https://github.com/juanelas/bigint-mod-arith/blob/d947979/src/ts/toZn.ts#L15) #### Defined in
[toZn.ts:15](https://github.com/juanelas/bigint-mod-arith/blob/12186fd/src/ts/toZn.ts#L15)

39
docs/interfaces/Egcd.md Normal file
View File

@ -0,0 +1,39 @@
# Interface: Egcd
## Table of contents
### Properties
- [g](Egcd.md#g)
- [x](Egcd.md#x)
- [y](Egcd.md#y)
## Properties
### g
**g**: `bigint`
#### Defined in
[egcd.ts:2](https://github.com/juanelas/bigint-mod-arith/blob/12186fd/src/ts/egcd.ts#L2)
___
### x
**x**: `bigint`
#### Defined in
[egcd.ts:3](https://github.com/juanelas/bigint-mod-arith/blob/12186fd/src/ts/egcd.ts#L3)
___
### y
**y**: `bigint`
#### Defined in
[egcd.ts:4](https://github.com/juanelas/bigint-mod-arith/blob/12186fd/src/ts/egcd.ts#L4)

View File

@ -1,35 +0,0 @@
[bigint-mod-arith - v3.0.0](../API.md) / Egcd
# Interface: Egcd
## Table of contents
### Properties
- [g](egcd.md#g)
- [x](egcd.md#x)
- [y](egcd.md#y)
## Properties
### g
**g**: *bigint*
Defined in: [ts/egcd.ts:2](https://github.com/juanelas/bigint-mod-arith/blob/d947979/src/ts/egcd.ts#L2)
___
### x
**x**: *bigint*
Defined in: [ts/egcd.ts:3](https://github.com/juanelas/bigint-mod-arith/blob/d947979/src/ts/egcd.ts#L3)
___
### y
**y**: *bigint*
Defined in: [ts/egcd.ts:4](https://github.com/juanelas/bigint-mod-arith/blob/d947979/src/ts/egcd.ts#L4)

3456
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -23,7 +23,7 @@
"engines": { "engines": {
"node": ">=10.4.0" "node": ">=10.4.0"
}, },
"types": "./dist/esm/types/index.d.ts", "types": "./types/index.d.ts",
"main": "./dist/cjs/index.node.cjs", "main": "./dist/cjs/index.node.cjs",
"browser": "./dist/esm/index.browser.js", "browser": "./dist/esm/index.browser.js",
"module": "./dist/esm/index.node.js", "module": "./dist/esm/index.node.js",
@ -35,8 +35,10 @@
}, },
"default": "./dist/esm/index.browser.js" "default": "./dist/esm/index.browser.js"
}, },
"./bundles/": "./dist/bundles/", "./esm-browser-bundle": "./dist/bundles/esm.js",
"./types/": "./dist/esm/types/" "./iife-browser-bundle": "./dist/bundles/iife.js",
"./umd-browser-bundle": "./dist/bundles/umd.js",
"./types": "./types/index.d.ts"
}, },
"directories": { "directories": {
"build": "./build", "build": "./build",
@ -49,16 +51,17 @@
"build": "run-s lint build:js docs test:browser coverage", "build": "run-s lint build:js docs test:browser coverage",
"build:js": "rollup -c build/rollup.config.js", "build:js": "rollup -c build/rollup.config.js",
"clean": "rimraf .nyc_output .mocha-ts coverage dist docs", "clean": "rimraf .nyc_output .mocha-ts coverage dist docs",
"coverage": "nyc --check-coverage --exclude build --exclude '{src/**/*.spec.ts,test/**/*.ts}' --reporter=text --reporter=lcov node ./build/bin/mocha-ts.js --require build/testing/mocha/mocha-init.js '{src/**/*.spec.ts,test/**/*.ts}'", "coverage": "nyc --check-coverage --exclude build --exclude '{src/ts/**/*.spec.ts,test/**/*.ts}' --reporter=text --reporter=lcov node ./build/bin/mocha-ts.js --require build/testing/mocha/mocha-init.js '{src/ts/**/*.spec.ts,test/**/*.ts}'",
"docs": "node build/build.docs.js", "docs": "node build/build.docs.js",
"git:add": "git add -A",
"lint": "ts-standard --fix", "lint": "ts-standard --fix",
"mocha": "node ./build/bin/mocha-ts.js --require build/testing/mocha/mocha-init.js ", "mocha": "node ./build/bin/mocha-ts.js --require build/testing/mocha/mocha-init.js ",
"preversion": "run-s lint build:js test:browser coverage", "version": "run-s build git:add",
"postversion": "npm run docs", "postversion": "git push --follow-tags",
"test": "run-s test:browser test:node", "test": "run-s test:browser test:node",
"test:browser": "node build/testing/browser/index.js", "test:browser": "node build/testing/browser/index.js",
"test:node": "npm run mocha -- '{src/**/*.spec.ts,test/**/*.ts}'", "test:node": "npm run mocha -- '{src/ts/**/*.spec.ts,test/**/*.ts}'",
"watch": "npm run mocha -- --watch '{src/**/*.spec.ts,test/**/*.ts}'" "watch": "npm run mocha -- --watch '{src/ts/**/*.spec.ts,test/**/*.ts}'"
}, },
"ts-standard": { "ts-standard": {
"env": [ "env": [
@ -77,28 +80,29 @@
] ]
}, },
"devDependencies": { "devDependencies": {
"@rollup/plugin-commonjs": "^17.0.0", "@rollup/plugin-commonjs": "^20.0.0",
"@rollup/plugin-multi-entry": "^4.0.0", "@rollup/plugin-multi-entry": "^4.0.0",
"@rollup/plugin-node-resolve": "^11.2.0", "@rollup/plugin-node-resolve": "^13.0.4",
"@rollup/plugin-replace": "^2.4.1", "@rollup/plugin-replace": "^3.0.0",
"@rollup/plugin-typescript": "^8.2.0", "@rollup/plugin-typescript": "^8.2.0",
"@types/chai": "^4.2.14", "@types/chai": "^4.2.14",
"@types/mocha": "^8.2.1", "@types/mocha": "^9.0.0",
"chai": "^4.3.3", "chai": "^4.3.3",
"fs-extra": "^10.0.0",
"glob": "^7.1.6", "glob": "^7.1.6",
"json5": "^2.2.0", "json5": "^2.2.0",
"minimatch": "^3.0.4", "minimatch": "^3.0.4",
"mocha": "^8.3.0", "mocha": "^9.0.3",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"nyc": "^15.1.0", "nyc": "^15.1.0",
"pirates": "^4.0.1", "pirates": "^4.0.1",
"puppeteer": "^8.0.0", "puppeteer": "^10.1.0",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"rollup": "^2.40.0", "rollup": "^2.40.0",
"rollup-plugin-terser": "^7.0.2", "rollup-plugin-terser": "^7.0.2",
"ts-standard": "^10.0.0", "ts-standard": "^10.0.0",
"tslib": "^2.1.0", "tslib": "^2.1.0",
"typedoc": "^0.20.29", "typedoc": "^0.21.5",
"typedoc-plugin-markdown": "^3.6.0", "typedoc-plugin-markdown": "^3.6.0",
"typescript": "^4.2.2" "typescript": "^4.2.2"
} }

View File

@ -22,6 +22,12 @@ Then either require (Node.js CJS):
const {{PKG_CAMELCASE}} = require('{{PKG_NAME}}') const {{PKG_CAMELCASE}} = require('{{PKG_NAME}}')
``` ```
> **Node >=10.4 <11**. `{{PKG_NAME}}` uses workers to speed up some operations. Workers are enabled by default with Node.js from version 11. In order to use them with Node >=10.4 and <11, you need to execute node with the flag `--experimental-worker`, and require the .js file manually (otherwise .cjs is required by default and would not be supported by the workers)
>
> ```javascript
> const bigintCryptoUtils = require('bigint-crypto-utils/dist/cjs/index.node') // ONLY FOR node >=10.4 <11 !
> ```
or import (JavaScript ES module): or import (JavaScript ES module):
```javascript ```javascript

View File

@ -1,16 +0,0 @@
/**
* Some common functions for modular arithmetic using native JS implementation of BigInt
*
* @packageDocumentation
*/
export { abs } from './ts/abs'
export { bitLength } from './ts/bitLength'
export { Egcd, eGcd } from './ts/egcd'
export { gcd } from './ts/gcd'
export { lcm } from './ts/lcm'
export { max } from './ts/max'
export { min } from './ts/min'
export { modInv } from './ts/modInv'
export { modPow } from './ts/modPow'
export { toZn } from './ts/toZn'

16
src/ts/index.ts Normal file
View File

@ -0,0 +1,16 @@
/**
* Some common functions for modular arithmetic using native JS implementation of BigInt
*
* @packageDocumentation
*/
export { abs } from './abs'
export { bitLength } from './bitLength'
export { Egcd, eGcd } from './egcd'
export { gcd } from './gcd'
export { lcm } from './lcm'
export { max } from './max'
export { min } from './min'
export { modInv } from './modInv'
export { modPow } from './modPow'
export { toZn } from './toZn'

View File

@ -1,10 +1,11 @@
{ {
"$schema": "https://json.schemastore.org/tsconfig", "$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": { "compilerOptions": {
"target": "ES2020", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ "target": "ES2020", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"lib": [ "es2020" ], /* Specify library files to be included in the compilation. */ // "lib": [ "es2020" ], /* Specify library files to be included in the compilation. */
"allowJs": true, /* Allow javascript files to be compiled. */ "allowJs": true, /* Allow javascript files to be compiled. */
"checkJs": true, /* Report errors in .js files. */ "outDir": ".dst", /* If not set we cannot import .js files without a warning that is going to be overwritten. outDir is not going to be used in any case */
"checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'react', 'react-jsx', 'react-jsxdev', 'preserve' or 'react-native'. */ // "jsx": "preserve", /* Specify JSX code generation: 'react', 'react-jsx', 'react-jsxdev', 'preserve' or 'react-native'. */
"strict": true, /* Enable all strict type-checking options. */ "strict": true, /* Enable all strict type-checking options. */
@ -35,5 +36,5 @@
"skipLibCheck": true, /* Skip type checking of declaration files. */ "skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}, },
"include": ["src/**/*", "build/typings/**/*", "test/**/*"] "include": ["src/ts/**/*", "build/typings/**/*", "test/**/*"]
} }

1
types/abs.d.ts.map Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"abs.d.ts","sourceRoot":"","sources":["../src/ts/abs.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,GAAG,CAAE,CAAC,EAAE,MAAM,GAAC,MAAM,GAAG,MAAM,GAAC,MAAM,CAEpD"}

1
types/bitLength.d.ts.map Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"bitLength.d.ts","sourceRoot":"","sources":["../src/ts/bitLength.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,SAAS,CAAE,CAAC,EAAE,MAAM,GAAC,MAAM,GAAG,MAAM,CASnD"}

1
types/egcd.d.ts.map Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"egcd.d.ts","sourceRoot":"","sources":["../src/ts/egcd.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,IAAI;IACnB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AACD;;;;;;;;;;;GAWG;AACH,wBAAgB,IAAI,CAAE,CAAC,EAAE,MAAM,GAAC,MAAM,EAAE,CAAC,EAAE,MAAM,GAAC,MAAM,GAAG,IAAI,CA4B9D"}

1
types/gcd.d.ts.map Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"gcd.d.ts","sourceRoot":"","sources":["../src/ts/gcd.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AACH,wBAAgB,GAAG,CAAE,CAAC,EAAE,MAAM,GAAC,MAAM,EAAE,CAAC,EAAE,MAAM,GAAC,MAAM,GAAG,MAAM,CA6B/D"}

16
types/index.d.ts vendored Normal file
View File

@ -0,0 +1,16 @@
/**
* Some common functions for modular arithmetic using native JS implementation of BigInt
*
* @packageDocumentation
*/
export { abs } from './abs';
export { bitLength } from './bitLength';
export { Egcd, eGcd } from './egcd';
export { gcd } from './gcd';
export { lcm } from './lcm';
export { max } from './max';
export { min } from './min';
export { modInv } from './modInv';
export { modPow } from './modPow';
export { toZn } from './toZn';
//# sourceMappingURL=index.d.ts.map

1
types/index.d.ts.map Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/ts/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AACnC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA"}

1
types/lcm.d.ts.map Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"lcm.d.ts","sourceRoot":"","sources":["../src/ts/lcm.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,GAAG,CAAE,CAAC,EAAE,MAAM,GAAC,MAAM,EAAE,CAAC,EAAE,MAAM,GAAC,MAAM,GAAG,MAAM,CAM/D"}

1
types/max.d.ts.map Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"max.d.ts","sourceRoot":"","sources":["../src/ts/max.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,GAAG,CAAE,CAAC,EAAE,MAAM,GAAC,MAAM,EAAE,CAAC,EAAE,MAAM,GAAC,MAAM,GAAG,MAAM,GAAC,MAAM,CAEtE"}

1
types/min.d.ts.map Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"min.d.ts","sourceRoot":"","sources":["../src/ts/min.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,GAAG,CAAE,CAAC,EAAE,MAAM,GAAC,MAAM,EAAE,CAAC,EAAE,MAAM,GAAC,MAAM,GAAG,MAAM,GAAC,MAAM,CAEtE"}

1
types/modInv.d.ts.map Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"modInv.d.ts","sourceRoot":"","sources":["../src/ts/modInv.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAE,CAAC,EAAE,MAAM,GAAC,MAAM,EAAE,CAAC,EAAE,MAAM,GAAC,MAAM,GAAG,MAAM,CAOlE"}

1
types/modPow.d.ts.map Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"modPow.d.ts","sourceRoot":"","sources":["../src/ts/modPow.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CAAE,CAAC,EAAE,MAAM,GAAC,MAAM,EAAE,CAAC,EAAE,MAAM,GAAC,MAAM,EAAE,CAAC,EAAE,MAAM,GAAC,MAAM,GAAG,MAAM,CA0BpF"}

1
types/toZn.d.ts.map Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"toZn.d.ts","sourceRoot":"","sources":["../src/ts/toZn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,IAAI,CAAE,CAAC,EAAE,MAAM,GAAC,MAAM,EAAE,CAAC,EAAE,MAAM,GAAC,MAAM,GAAG,MAAM,CAUhE"}