support for node 10. New builder scripts
This commit is contained in:
parent
12186fd951
commit
5b2686bbc9
|
@ -23,6 +23,12 @@ Then either require (Node.js CJS):
|
|||
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):
|
||||
|
||||
```javascript
|
||||
|
@ -31,7 +37,7 @@ import * as bigintModArith from 'bigint-mod-arith'
|
|||
|
||||
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:
|
||||
|
||||
|
|
|
@ -23,11 +23,12 @@ async function typedoc () {
|
|||
|
||||
app.bootstrap({
|
||||
// typedoc options here
|
||||
entryPoints: ['src/index.ts'],
|
||||
entryPoints: ['src/ts/index.ts'],
|
||||
plugin: ['typedoc-plugin-markdown'],
|
||||
includeVersion: true,
|
||||
entryDocument: 'API.md',
|
||||
readme: 'none'
|
||||
readme: 'none',
|
||||
hideBreadcrumbs: true
|
||||
})
|
||||
|
||||
const project = app.convert()
|
||||
|
@ -49,7 +50,7 @@ function getRepositoryData () {
|
|||
return {
|
||||
repoProvider,
|
||||
repoUsername: repodata[1],
|
||||
repoName: repodata[2]
|
||||
repoName: repodata.slice(2).join('/')
|
||||
}
|
||||
} 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 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
|
||||
if (repoProvider) {
|
||||
switch (repoProvider) {
|
||||
case 'github':
|
||||
iifeBundle = `[IIFE bundle](https://raw.githubusercontent.com/${repoUsername}/${repoName}/master/dist/bundles/${name}.iife.js)`
|
||||
esmBundle = `[ESM bundle](https://raw.githubusercontent.com/${repoUsername}/${repoName}/master/dist/bundles/${name}.esm.js)`
|
||||
umdBundle = `[UMD bundle](https://raw.githubusercontent.com/${repoUsername}/${repoName}/master/dist/bundles/${name}.umd.js)`
|
||||
iifeBundle = `[IIFE bundle](https://raw.githubusercontent.com/${repoUsername}/${repoName}/master/${iifeBundlePath})`
|
||||
esmBundle = `[ESM bundle](https://raw.githubusercontent.com/${repoUsername}/${repoName}/master/${esmBundlePath})`
|
||||
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)`
|
||||
coverallsBadge = `[![Coverage Status](https://coveralls.io/repos/github/${repoUsername}/${repoName}/badge.svg?branch=master)](https://coveralls.io/github/${repoUsername}/${repoName}?branch=master)`
|
||||
break
|
||||
|
||||
case 'gitlab':
|
||||
iifeBundle = `[IIFE bundle](https://gitlab.com/${repoUsername}/${repoName}/-/raw/master/dist/bundles/${name}.iife.js?inline=false)`
|
||||
esmBundle = `[ESM bundle](https://gitlab.com/${repoUsername}/${repoName}/-/raw/master/dist/bundles/${name}.esm.js?inline=false)`
|
||||
umdBundle = `[IIFE bundle](https://gitlab.com/${repoUsername}/${repoName}/-/raw/master/dist/bundles/${name}.umd.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/${esmBundlePath}?inline=false)`
|
||||
umdBundle = `[UMD bundle](https://gitlab.com/${repoUsername}/${repoName}/-/raw/master/dist/${umdBundlePath}?inline=false)`
|
||||
break
|
||||
|
||||
default:
|
||||
|
@ -93,6 +98,8 @@ let template = fs.readFileSync(templateFile, { encoding: 'UTF-8' })
|
|||
|
||||
if (repoProvider && repoProvider === 'github') {
|
||||
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')
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
'use strict'
|
||||
|
||||
const resolve = require('@rollup/plugin-node-resolve').nodeResolve
|
||||
const replace = require('@rollup/plugin-replace')
|
||||
const { terser } = require('rollup-plugin-terser')
|
||||
const typescriptPlugin = require('@rollup/plugin-typescript')
|
||||
const commonjs = require('@rollup/plugin-commonjs')
|
||||
import { nodeResolve as resolve } from '@rollup/plugin-node-resolve'
|
||||
import replace from '@rollup/plugin-replace'
|
||||
import { terser } from 'rollup-plugin-terser'
|
||||
import typescriptPlugin from '@rollup/plugin-typescript'
|
||||
import commonjs from '@rollup/plugin-commonjs'
|
||||
|
||||
const path = require('path')
|
||||
const fs = require('fs')
|
||||
const pkgJson = require('../package.json')
|
||||
import { dirname, join } from 'path'
|
||||
import { existsSync, moveSync, removeSync } from 'fs-extra'
|
||||
import { directories, name as _name, dependencies, peerDependencies, exports, types } from '../package.json'
|
||||
|
||||
const rootDir = path.join(__dirname, '..')
|
||||
const dstDir = path.join(rootDir, pkgJson.directories.dist)
|
||||
const srcDir = path.join(rootDir, 'src')
|
||||
const rootDir = join(__dirname, '..')
|
||||
const dstDir = join(rootDir, directories.dist)
|
||||
const srcDir = join(rootDir, 'src', 'ts')
|
||||
|
||||
function camelise (str) {
|
||||
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 { name } = pkgJson.name.match(regex).groups
|
||||
const { name } = _name.match(regex).groups
|
||||
const pkgCamelisedName = camelise(name)
|
||||
|
||||
const input = path.join(srcDir, 'index.ts')
|
||||
if (fs.existsSync(input) !== true) throw new Error('The entry point should be index.ts')
|
||||
const input = join(srcDir, 'index.ts')
|
||||
if (existsSync(input) !== true) throw new Error('The entry point should be index.ts')
|
||||
|
||||
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']
|
||||
}
|
||||
|
||||
const external = [...Object.keys(pkgJson.dependencies || {}), ...Object.keys(pkgJson.peerDependencies || {})]
|
||||
const external = [...Object.keys(dependencies || {}), ...Object.keys(peerDependencies || {})]
|
||||
|
||||
const sourcemapOutputOptions = {
|
||||
sourcemap: 'inline',
|
||||
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
|
||||
input: input,
|
||||
output: [
|
||||
{
|
||||
file: path.join(rootDir, pkgJson.exports['.'].default),
|
||||
file: join(rootDir, exports['.'].default),
|
||||
...sourcemapOutputOptions,
|
||||
format: 'es'
|
||||
}
|
||||
|
@ -62,16 +74,16 @@ module.exports = [
|
|||
input: input,
|
||||
output: [
|
||||
{
|
||||
file: path.join(dstDir, `bundles/${name}.iife.js`),
|
||||
file: join(dstDir, 'bundles/iife.js'),
|
||||
format: 'iife',
|
||||
name: pkgCamelisedName
|
||||
},
|
||||
{
|
||||
file: path.join(dstDir, `bundles/${name}.esm.js`),
|
||||
file: join(dstDir, 'bundles/esm.js'),
|
||||
format: 'es'
|
||||
},
|
||||
{
|
||||
file: path.join(dstDir, `bundles/${name}.umd.js`),
|
||||
file: join(dstDir, 'bundles/umd.js'),
|
||||
format: 'umd',
|
||||
name: pkgCamelisedName
|
||||
}
|
||||
|
@ -89,11 +101,10 @@ module.exports = [
|
|||
terser()
|
||||
]
|
||||
},
|
||||
{ // Node ESM
|
||||
{ // Node ESM with declaration files
|
||||
input: input,
|
||||
output: {
|
||||
dir: path.join(rootDir, path.dirname(pkgJson.exports['.'].node.import)),
|
||||
entryFileNames: path.basename(pkgJson.exports['.'].node.import),
|
||||
file: join(rootDir, exports['.'].node.import),
|
||||
...sourcemapOutputOptions,
|
||||
format: 'es'
|
||||
},
|
||||
|
@ -104,30 +115,37 @@ module.exports = [
|
|||
}),
|
||||
typescriptPlugin({
|
||||
...tsBundleOptions,
|
||||
// outDir: path.join(rootDir, path.dirname(pkgJson.exports['.'].node.import)),
|
||||
declaration: true,
|
||||
outDir: path.join(rootDir, path.dirname(pkgJson.exports['.'].node.import)),
|
||||
declarationDir: path.join(rootDir, path.dirname(pkgJson.exports['.'].node.import), 'types'),
|
||||
declarationDir: 'types',
|
||||
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
|
||||
},
|
||||
{ // Node CJS with declaration files
|
||||
{ // Node CJS
|
||||
input: input,
|
||||
output: {
|
||||
dir: path.join(rootDir, path.dirname(pkgJson.exports['.'].node.require)),
|
||||
entryFileNames: path.basename(pkgJson.exports['.'].node.require),
|
||||
...sourcemapOutputOptions,
|
||||
format: 'cjs'
|
||||
},
|
||||
output: [
|
||||
{
|
||||
file: join(rootDir, exports['.'].node.require),
|
||||
...sourcemapOutputOptions,
|
||||
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: [
|
||||
replace({
|
||||
IS_BROWSER: false,
|
||||
preventAssignment: true
|
||||
}),
|
||||
typescriptPlugin(tsBundleOptions),
|
||||
commonjs({ extensions: ['.js', '.ts'] }) // the ".ts" extension is required
|
||||
commonjs({ extensions: ['.js', '.cjs', '.ts'] }) // the ".ts" extension is required
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -42,7 +42,7 @@ const browserTests = async ({ logWarnings = false, serverPort = 38000, keepServe
|
|||
page.on('error', function (err) { page.emit(new Error(err)) })
|
||||
|
||||
await page.goto('http://localhost:38000/')
|
||||
const watchDog = page.waitForFunction('_mocha.state === \'stopped\'')
|
||||
const watchDog = page.waitForFunction('_mocha.state === \'stopped\'', { timeout: 0 })
|
||||
await watchDog
|
||||
|
||||
if (keepServerRunning === false) {
|
||||
|
|
|
@ -62,7 +62,8 @@ async function buildTests () {
|
|||
exportConditions: ['browser', 'module', 'import', 'default']
|
||||
}),
|
||||
commonjs()
|
||||
]
|
||||
],
|
||||
external: [pkgJson.name]
|
||||
}
|
||||
const bundle = await rollup.rollup(inputOptions)
|
||||
const { output } = await bundle.generate({ format: 'esm' })
|
||||
|
@ -79,7 +80,7 @@ class TestServer {
|
|||
const tests = await buildTests()
|
||||
this.server.on('request', function (req, res) {
|
||||
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) {
|
||||
res.writeHead(404)
|
||||
res.end(JSON.stringify(err))
|
||||
|
|
|
@ -28,7 +28,8 @@ module.exports = class TestsBuilder extends Builder {
|
|||
const fileStr = fs.readFileSync(path, 'utf8')
|
||||
const config = JSON5.parse(fileStr)
|
||||
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)
|
||||
}
|
||||
const configFile = ts.readJsonConfigFile(configPath, readFileAndMangle)
|
||||
|
@ -68,7 +69,6 @@ module.exports = class TestsBuilder extends Builder {
|
|||
...parsedTsConfig.options,
|
||||
rootDir,
|
||||
outDir: this.tempDir,
|
||||
module: 'commonjs',
|
||||
noEmit: false,
|
||||
noResolve: true,
|
||||
sourceMap: true
|
||||
|
|
|
@ -25,13 +25,21 @@ testBuilder.start() // This should be in exports.mochaGlobalSetup but mocha fail
|
|||
exports.mochaHooks = {
|
||||
beforeAll: [
|
||||
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).
|
||||
delete require.cache[require.resolve(rootDir)]
|
||||
global._pkg = require(rootDir)
|
||||
},
|
||||
async function () {
|
||||
this.timeout('120000')
|
||||
await Promise.all([rollupBuilder.ready(), testBuilder.ready()])
|
||||
|
||||
// And now reset any other transpiled module (just delete the cache so it is fully reloaded)
|
||||
for (const key in require.cache) {
|
||||
const relativePath = path.relative(rootDir, key)
|
||||
if (relativePath.startsWith(`.mocha-ts${path.sep}`)) {
|
||||
delete require.cache[key]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import * as _pkgModule from '../..'
|
||||
|
||||
export as namespace _pkg
|
||||
|
||||
declare global {
|
||||
const _pkg: typeof _pkgModule
|
||||
}
|
||||
export as namespace _pkgTypes
|
||||
export = _pkgModule
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -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
|
|
@ -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"}
|
|
@ -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"}
|
|
@ -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"}
|
|
@ -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"}
|
|
@ -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"}
|
|
@ -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"}
|
|
@ -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"}
|
|
@ -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"}
|
|
@ -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"}
|
|
@ -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"}
|
|
@ -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"}
|
202
docs/API.md
202
docs/API.md
|
@ -1,5 +1,3 @@
|
|||
bigint-mod-arith - v3.0.0
|
||||
|
||||
# bigint-mod-arith - v3.0.0
|
||||
|
||||
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
|
||||
|
||||
- [Egcd](interfaces/egcd.md)
|
||||
- [Egcd](interfaces/Egcd.md)
|
||||
|
||||
### Functions
|
||||
|
||||
|
@ -27,47 +25,55 @@ Some common functions for modular arithmetic using native JS implementation of B
|
|||
|
||||
### 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
|
||||
|
||||
#### Parameters:
|
||||
#### Parameters
|
||||
|
||||
Name | Type |
|
||||
:------ | :------ |
|
||||
`a` | *number* \| *bigint* |
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `a` | `number` \| `bigint` |
|
||||
|
||||
**Returns:** *number* \| *bigint*
|
||||
#### Returns
|
||||
|
||||
`number` \| `bigint`
|
||||
|
||||
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**(`a`: *number* \| *bigint*): *number*
|
||||
▸ **bitLength**(`a`): `number`
|
||||
|
||||
Returns the bitlength of a number
|
||||
|
||||
#### Parameters:
|
||||
#### Parameters
|
||||
|
||||
Name | Type |
|
||||
:------ | :------ |
|
||||
`a` | *number* \| *bigint* |
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `a` | `number` \| `bigint` |
|
||||
|
||||
**Returns:** *number*
|
||||
#### Returns
|
||||
|
||||
`number`
|
||||
|
||||
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**(`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.
|
||||
Take positive integers a, b as input, and return a triple (g, x, y), such that ax + by = g = gcd(a, b).
|
||||
|
@ -75,157 +81,185 @@ Take positive integers a, b as input, and return a triple (g, x, y), such that a
|
|||
**`throws`** {RangeError}
|
||||
This excepction is thrown if a or b are less than 0
|
||||
|
||||
#### Parameters:
|
||||
#### Parameters
|
||||
|
||||
Name | Type |
|
||||
:------ | :------ |
|
||||
`a` | *number* \| *bigint* |
|
||||
`b` | *number* \| *bigint* |
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `a` | `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).
|
||||
|
||||
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**(`a`: *number* \| *bigint*, `b`: *number* \| *bigint*): *bigint*
|
||||
▸ **gcd**(`a`, `b`): `bigint`
|
||||
|
||||
Greatest-common divisor of two integers based on the iterative binary algorithm.
|
||||
|
||||
#### Parameters:
|
||||
#### Parameters
|
||||
|
||||
Name | Type |
|
||||
:------ | :------ |
|
||||
`a` | *number* \| *bigint* |
|
||||
`b` | *number* \| *bigint* |
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `a` | `number` \| `bigint` |
|
||||
| `b` | `number` \| `bigint` |
|
||||
|
||||
**Returns:** *bigint*
|
||||
#### Returns
|
||||
|
||||
`bigint`
|
||||
|
||||
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**(`a`: *number* \| *bigint*, `b`: *number* \| *bigint*): *bigint*
|
||||
▸ **lcm**(`a`, `b`): `bigint`
|
||||
|
||||
The least common multiple computed as abs(a*b)/gcd(a,b)
|
||||
|
||||
#### Parameters:
|
||||
#### Parameters
|
||||
|
||||
Name | Type |
|
||||
:------ | :------ |
|
||||
`a` | *number* \| *bigint* |
|
||||
`b` | *number* \| *bigint* |
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `a` | `number` \| `bigint` |
|
||||
| `b` | `number` \| `bigint` |
|
||||
|
||||
**Returns:** *bigint*
|
||||
#### Returns
|
||||
|
||||
`bigint`
|
||||
|
||||
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**(`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
|
||||
|
||||
#### Parameters:
|
||||
#### Parameters
|
||||
|
||||
Name | Type |
|
||||
:------ | :------ |
|
||||
`a` | *number* \| *bigint* |
|
||||
`b` | *number* \| *bigint* |
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `a` | `number` \| `bigint` |
|
||||
| `b` | `number` \| `bigint` |
|
||||
|
||||
**Returns:** *number* \| *bigint*
|
||||
#### Returns
|
||||
|
||||
`number` \| `bigint`
|
||||
|
||||
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**(`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
|
||||
|
||||
#### Parameters:
|
||||
#### Parameters
|
||||
|
||||
Name | Type |
|
||||
:------ | :------ |
|
||||
`a` | *number* \| *bigint* |
|
||||
`b` | *number* \| *bigint* |
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `a` | `number` \| `bigint` |
|
||||
| `b` | `number` \| `bigint` |
|
||||
|
||||
**Returns:** *number* \| *bigint*
|
||||
#### Returns
|
||||
|
||||
`number` \| `bigint`
|
||||
|
||||
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**(`a`: *number* \| *bigint*, `n`: *number* \| *bigint*): *bigint*
|
||||
▸ **modInv**(`a`, `n`): `bigint`
|
||||
|
||||
Modular inverse.
|
||||
|
||||
**`throws`** {RangeError}
|
||||
Excpeption thorwn when a does not have inverse modulo n
|
||||
|
||||
#### Parameters:
|
||||
#### Parameters
|
||||
|
||||
Name | Type | Description |
|
||||
:------ | :------ | :------ |
|
||||
`a` | *number* \| *bigint* | The number to find an inverse for |
|
||||
`n` | *number* \| *bigint* | The modulo |
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `a` | `number` \| `bigint` | The number to find an inverse for |
|
||||
| `n` | `number` \| `bigint` | The modulo |
|
||||
|
||||
**Returns:** *bigint*
|
||||
#### Returns
|
||||
|
||||
`bigint`
|
||||
|
||||
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**(`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
|
||||
|
||||
**`throws`** {RangeError}
|
||||
Excpeption thrown when n is not > 0
|
||||
|
||||
#### Parameters:
|
||||
#### Parameters
|
||||
|
||||
Name | Type | Description |
|
||||
:------ | :------ | :------ |
|
||||
`b` | *number* \| *bigint* | base |
|
||||
`e` | *number* \| *bigint* | exponent |
|
||||
`n` | *number* \| *bigint* | modulo |
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `b` | `number` \| `bigint` | base |
|
||||
| `e` | `number` \| `bigint` | exponent |
|
||||
| `n` | `number` \| `bigint` | modulo |
|
||||
|
||||
**Returns:** *bigint*
|
||||
#### Returns
|
||||
|
||||
`bigint`
|
||||
|
||||
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**(`a`: *number* \| *bigint*, `n`: *number* \| *bigint*): *bigint*
|
||||
▸ **toZn**(`a`, `n`): `bigint`
|
||||
|
||||
Finds the smallest positive element that is congruent to a in modulo n
|
||||
|
||||
|
@ -235,15 +269,19 @@ a and b must be the same type, either number or bigint
|
|||
**`throws`** {RangeError}
|
||||
Excpeption thrown when n is not > 0
|
||||
|
||||
#### Parameters:
|
||||
#### Parameters
|
||||
|
||||
Name | Type | Description |
|
||||
:------ | :------ | :------ |
|
||||
`a` | *number* \| *bigint* | An integer |
|
||||
`n` | *number* \| *bigint* | The modulo |
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `a` | `number` \| `bigint` | An integer |
|
||||
| `n` | `number` \| `bigint` | The modulo |
|
||||
|
||||
**Returns:** *bigint*
|
||||
#### Returns
|
||||
|
||||
`bigint`
|
||||
|
||||
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)
|
||||
|
|
|
@ -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)
|
|
@ -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)
|
File diff suppressed because it is too large
Load Diff
34
package.json
34
package.json
|
@ -23,7 +23,7 @@
|
|||
"engines": {
|
||||
"node": ">=10.4.0"
|
||||
},
|
||||
"types": "./dist/esm/types/index.d.ts",
|
||||
"types": "./types/index.d.ts",
|
||||
"main": "./dist/cjs/index.node.cjs",
|
||||
"browser": "./dist/esm/index.browser.js",
|
||||
"module": "./dist/esm/index.node.js",
|
||||
|
@ -35,8 +35,10 @@
|
|||
},
|
||||
"default": "./dist/esm/index.browser.js"
|
||||
},
|
||||
"./bundles/": "./dist/bundles/",
|
||||
"./types/": "./dist/esm/types/"
|
||||
"./esm-browser-bundle": "./dist/bundles/esm.js",
|
||||
"./iife-browser-bundle": "./dist/bundles/iife.js",
|
||||
"./umd-browser-bundle": "./dist/bundles/umd.js",
|
||||
"./types": "./types/index.d.ts"
|
||||
},
|
||||
"directories": {
|
||||
"build": "./build",
|
||||
|
@ -49,16 +51,17 @@
|
|||
"build": "run-s lint build:js docs test:browser coverage",
|
||||
"build:js": "rollup -c build/rollup.config.js",
|
||||
"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",
|
||||
"git:add": "git add -A",
|
||||
"lint": "ts-standard --fix",
|
||||
"mocha": "node ./build/bin/mocha-ts.js --require build/testing/mocha/mocha-init.js ",
|
||||
"preversion": "run-s lint build:js test:browser coverage",
|
||||
"postversion": "npm run docs",
|
||||
"version": "run-s build git:add",
|
||||
"postversion": "git push --follow-tags",
|
||||
"test": "run-s test:browser test:node",
|
||||
"test:browser": "node build/testing/browser/index.js",
|
||||
"test:node": "npm run mocha -- '{src/**/*.spec.ts,test/**/*.ts}'",
|
||||
"watch": "npm run mocha -- --watch '{src/**/*.spec.ts,test/**/*.ts}'"
|
||||
"test:node": "npm run mocha -- '{src/ts/**/*.spec.ts,test/**/*.ts}'",
|
||||
"watch": "npm run mocha -- --watch '{src/ts/**/*.spec.ts,test/**/*.ts}'"
|
||||
},
|
||||
"ts-standard": {
|
||||
"env": [
|
||||
|
@ -77,28 +80,29 @@
|
|||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-commonjs": "^17.0.0",
|
||||
"@rollup/plugin-commonjs": "^20.0.0",
|
||||
"@rollup/plugin-multi-entry": "^4.0.0",
|
||||
"@rollup/plugin-node-resolve": "^11.2.0",
|
||||
"@rollup/plugin-replace": "^2.4.1",
|
||||
"@rollup/plugin-node-resolve": "^13.0.4",
|
||||
"@rollup/plugin-replace": "^3.0.0",
|
||||
"@rollup/plugin-typescript": "^8.2.0",
|
||||
"@types/chai": "^4.2.14",
|
||||
"@types/mocha": "^8.2.1",
|
||||
"@types/mocha": "^9.0.0",
|
||||
"chai": "^4.3.3",
|
||||
"fs-extra": "^10.0.0",
|
||||
"glob": "^7.1.6",
|
||||
"json5": "^2.2.0",
|
||||
"minimatch": "^3.0.4",
|
||||
"mocha": "^8.3.0",
|
||||
"mocha": "^9.0.3",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"nyc": "^15.1.0",
|
||||
"pirates": "^4.0.1",
|
||||
"puppeteer": "^8.0.0",
|
||||
"puppeteer": "^10.1.0",
|
||||
"rimraf": "^3.0.2",
|
||||
"rollup": "^2.40.0",
|
||||
"rollup-plugin-terser": "^7.0.2",
|
||||
"ts-standard": "^10.0.0",
|
||||
"tslib": "^2.1.0",
|
||||
"typedoc": "^0.20.29",
|
||||
"typedoc": "^0.21.5",
|
||||
"typedoc-plugin-markdown": "^3.6.0",
|
||||
"typescript": "^4.2.2"
|
||||
}
|
||||
|
|
|
@ -22,6 +22,12 @@ Then either require (Node.js CJS):
|
|||
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):
|
||||
|
||||
```javascript
|
||||
|
|
16
src/index.ts
16
src/index.ts
|
@ -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'
|
|
@ -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'
|
|
@ -1,10 +1,11 @@
|
|||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"compilerOptions": {
|
||||
"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. */
|
||||
"allowJs": true, /* Allow javascript files to be compiled. */
|
||||
"checkJs": true, /* Report errors in .js files. */
|
||||
"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. */
|
||||
"allowJs": true, /* Allow javascript files to be compiled. */
|
||||
"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'. */
|
||||
"strict": true, /* Enable all strict type-checking options. */
|
||||
|
||||
|
@ -35,5 +36,5 @@
|
|||
"skipLibCheck": true, /* Skip type checking of declaration files. */
|
||||
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
|
||||
},
|
||||
"include": ["src/**/*", "build/typings/**/*", "test/**/*"]
|
||||
"include": ["src/ts/**/*", "build/typings/**/*", "test/**/*"]
|
||||
}
|
||||
|
|
|
@ -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"}
|
|
@ -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"}
|
|
@ -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"}
|
|
@ -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"}
|
|
@ -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
|
|
@ -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"}
|
|
@ -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"}
|
|
@ -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"}
|
|
@ -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"}
|
|
@ -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"}
|
|
@ -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"}
|
|
@ -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"}
|
Loading…
Reference in New Issue