support for node16 and nodenext module resolution
This commit is contained in:
parent
fc5e3c53e4
commit
1f1862692b
|
@ -15,7 +15,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
node-version: [14, 16, 18]
|
node-version: [16, 18]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ jobs:
|
||||||
- uses: actions/setup-node@v1
|
- uses: actions/setup-node@v1
|
||||||
if: steps.check.outputs.changed == 'true'
|
if: steps.check.outputs.changed == 'true'
|
||||||
with:
|
with:
|
||||||
node-version: 14
|
node-version: 18
|
||||||
registry-url: https://registry.npmjs.org/
|
registry-url: https://registry.npmjs.org/
|
||||||
|
|
||||||
- name: install
|
- name: install
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
|
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
|
||||||
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)
|
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)
|
||||||
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
|
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
|
||||||
[![Node.js CI](https://github.com/juanelas/bigint-mod-arith/actions/workflows/nodejs.yml/badge.svg)](https://github.com/juanelas/bigint-mod-arith/actions/workflows/nodejs.yml)
|
[![Node.js CI](https://github.com/juanelas/bigint-mod-arith/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/juanelas/bigint-mod-arith/actions/workflows/build-and-test.yml)
|
||||||
[![Coverage Status](https://coveralls.io/repos/github/juanelas/bigint-mod-arith/badge.svg?branch=master)](https://coveralls.io/github/juanelas/bigint-mod-arith?branch=master)
|
[![Coverage Status](https://coveralls.io/repos/github/juanelas/bigint-mod-arith/badge.svg?branch=main)](https://coveralls.io/github/juanelas/bigint-mod-arith?branch=main)
|
||||||
|
|
||||||
# bigint-mod-arith
|
# bigint-mod-arith
|
||||||
|
|
||||||
|
@ -38,7 +38,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/iife.js), the [ESM bundle](https://raw.githubusercontent.com/juanelas/bigint-mod-arith/master/dist/bundles/esm.min.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/`.
|
You can also download the [IIFE bundle](https://raw.githubusercontent.com/juanelas/bigint-mod-arith/main/dist/bundles/iife.js), the [ESM bundle](https://raw.githubusercontent.com/juanelas/bigint-mod-arith/main/dist/bundles/esm.min.js) or the [UMD bundle](https://raw.githubusercontent.com/juanelas/bigint-mod-arith/main/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:
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,28 @@ const rimraf = require('rimraf')
|
||||||
|
|
||||||
const rootDir = path.join(__dirname, '..')
|
const rootDir = path.join(__dirname, '..')
|
||||||
|
|
||||||
|
const templateFilePath = path.join(rootDir, pkgJson.directories.src, 'docs/index.md')
|
||||||
|
let template = fs.readFileSync(templateFilePath, { encoding: 'utf-8' })
|
||||||
|
|
||||||
|
async function main () {
|
||||||
|
// Generate API doc with typedoc
|
||||||
|
await typedoc()
|
||||||
|
|
||||||
|
// Translate relaitive links to project's root
|
||||||
|
replaceRelativeLinks()
|
||||||
|
|
||||||
|
// Let us replace variables and badges
|
||||||
|
variableReplacements()
|
||||||
|
|
||||||
|
const readmeFile = path.join(rootDir, 'README.md')
|
||||||
|
fs.writeFileSync(readmeFile, template)
|
||||||
|
}
|
||||||
|
|
||||||
|
main()
|
||||||
|
/* ------------------------------------------------------------------------- |
|
||||||
|
| UTILITY FUNCTIONS |
|
||||||
|
| ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
function camelise (str) {
|
function camelise (str) {
|
||||||
return str.replace(/-([a-z])/g,
|
return str.replace(/-([a-z])/g,
|
||||||
function (m, w) {
|
function (m, w) {
|
||||||
|
@ -16,13 +38,13 @@ function camelise (str) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const tsConfigPath = path.join(rootDir, 'tsconfig.json')
|
|
||||||
const tempTsConfigPath = path.join(rootDir, '.tsconfig.json')
|
|
||||||
|
|
||||||
async function typedoc () {
|
async function typedoc () {
|
||||||
const app = new TypeDoc.Application()
|
const app = new TypeDoc.Application()
|
||||||
|
|
||||||
// prepare tsconfig
|
// prepare tsconfig
|
||||||
|
const tsConfigPath = path.join(rootDir, 'tsconfig.json')
|
||||||
|
const tempTsConfigPath = path.join(rootDir, '.tsconfig.json')
|
||||||
|
|
||||||
const tsConfig = json5.parse(fs.readFileSync(tsConfigPath, 'utf8'))
|
const tsConfig = json5.parse(fs.readFileSync(tsConfigPath, 'utf8'))
|
||||||
tsConfig.include = ['src/ts/**/*', 'build/typings/**/*.d.ts']
|
tsConfig.include = ['src/ts/**/*', 'build/typings/**/*.d.ts']
|
||||||
tsConfig.exclude = ['src/**/*.spec.ts']
|
tsConfig.exclude = ['src/**/*.spec.ts']
|
||||||
|
@ -30,7 +52,7 @@ async function typedoc () {
|
||||||
|
|
||||||
// If you want TypeDoc to load tsconfig.json / typedoc.json files
|
// If you want TypeDoc to load tsconfig.json / typedoc.json files
|
||||||
app.options.addReader(new TypeDoc.TSConfigReader())
|
app.options.addReader(new TypeDoc.TSConfigReader())
|
||||||
app.options.addReader(new TypeDoc.TypeDocReader())
|
// app.options.addReader(new TypeDoc.TypeDocReader())
|
||||||
|
|
||||||
app.bootstrap({
|
app.bootstrap({
|
||||||
// typedoc options here
|
// typedoc options here
|
||||||
|
@ -53,81 +75,130 @@ async function typedoc () {
|
||||||
// Rendered docs
|
// Rendered docs
|
||||||
await app.generateDocs(project, output)
|
await app.generateDocs(project, output)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rimraf.sync(tempTsConfigPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRepositoryData () {
|
function getRepositoryData () {
|
||||||
|
let ret
|
||||||
if (typeof pkgJson.repository === 'string') {
|
if (typeof pkgJson.repository === 'string') {
|
||||||
const repodata = pkgJson.repository.split(/[:/]/)
|
const repodata = pkgJson.repository.split(/[:/]/)
|
||||||
const repoProvider = repodata[0]
|
const repoProvider = repodata[0]
|
||||||
if (repoProvider === 'github' || repoProvider === 'gitlab' || repoProvider === 'bitbucket') {
|
if (repoProvider === 'github' || repoProvider === 'gitlab' || repoProvider === 'bitbucket') {
|
||||||
return {
|
ret = {
|
||||||
repoProvider,
|
repoProvider,
|
||||||
repoUsername: repodata[1],
|
repoUsername: repodata[1],
|
||||||
repoName: repodata.slice(2).join('/')
|
repoName: repodata.slice(2).join('/')
|
||||||
}
|
}
|
||||||
} else return null
|
}
|
||||||
} else {
|
} else if (typeof pkgJson.repository === 'object' && pkgJson.repository.type === 'git' && pkgJson.repository.url !== 'undefined') {
|
||||||
if (pkgJson.repository.url !== 'undefined') {
|
const regex = /(?:.+?\+)?http[s]?:\/\/(?<repoProvider>[\w._-]+)\.\w{2,3}\/(?<repoUsername>[\w._-]+)\/(?<repoName>[\w._\-/]+?)\.git/
|
||||||
const regex = /(?:.+?\+)?http[s]?:\/\/(?<repoProvider>[\w._-]+)\.\w{2,3}\/(?<repoUsername>[\w._-]+)\/(?<repoName>[\w._\-/]+?)\.git/
|
const match = pkgJson.repository.url.match(regex)
|
||||||
const match = pkgJson.repository.url.match(regex)
|
ret = {
|
||||||
return {
|
repoProvider: match[1],
|
||||||
repoProvider: match[1],
|
repoUsername: match[2],
|
||||||
repoUsername: match[2],
|
repoName: match[3],
|
||||||
repoName: match[3]
|
repoDirectory: pkgJson.repository.directory
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (typeof ret === 'object') {
|
||||||
|
if (typeof pkgJson.nodeBrowserSkel === 'object' && typeof pkgJson.nodeBrowserSkel.git === 'object' && typeof pkgJson.nodeBrowserSkel.git.branch === 'string') {
|
||||||
|
ret.branch = pkgJson.nodeBrowserSkel.git.branch
|
||||||
|
} else {
|
||||||
|
ret.branch = (ret.repoProvider === 'github') ? 'main' : 'master'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
const { repoProvider, repoUsername, repoName } = getRepositoryData() || { repoProvider: null, repoUsername: null, repoName: null }
|
function variableReplacements () {
|
||||||
|
const { repoProvider, repoUsername, repoName, repoDirectory, branch } = getRepositoryData() || {}
|
||||||
|
|
||||||
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 } = pkgJson.name.match(regex).groups
|
||||||
const camelCaseName = camelise(name)
|
const camelCaseName = camelise(name)
|
||||||
|
|
||||||
const iifeBundlePath = path.relative('.', pkgJson.exports['./iife-browser-bundle'])
|
const iifeBundlePath = pkgJson.exports['./iife-browser-bundle'] !== undefined ? path.relative('.', pkgJson.exports['./iife-browser-bundle']) : undefined
|
||||||
const esmBundlePath = path.relative('.', pkgJson.exports['./esm-browser-bundle'])
|
const esmBundlePath = pkgJson.exports['./esm-browser-bundle'] !== undefined ? path.relative('.', pkgJson.exports['./esm-browser-bundle']) : undefined
|
||||||
const umdBundlePath = path.relative('.', pkgJson.exports['./umd-browser-bundle'])
|
const umdBundlePath = pkgJson.exports['./umd-browser-bundle'] !== undefined ? path.relative('.', pkgJson.exports['./umd-browser-bundle']) : undefined
|
||||||
|
|
||||||
let iifeBundle, esmBundle, umdBundle, workflowBadget, coverallsBadge
|
let useWorkflowBadge = false
|
||||||
if (repoProvider) {
|
let useCoverallsBadge = false
|
||||||
switch (repoProvider) {
|
if (pkgJson.nodeBrowserSkel !== undefined && pkgJson.nodeBrowserSkel.badges !== undefined) {
|
||||||
case 'github':
|
if (pkgJson.nodeBrowserSkel.badges.workflow === true) {
|
||||||
iifeBundle = `[IIFE bundle](https://raw.githubusercontent.com/${repoUsername}/${repoName}/master/${iifeBundlePath})`
|
useWorkflowBadge = true
|
||||||
esmBundle = `[ESM bundle](https://raw.githubusercontent.com/${repoUsername}/${repoName}/master/${esmBundlePath})`
|
}
|
||||||
umdBundle = `[UMD bundle](https://raw.githubusercontent.com/${repoUsername}/${repoName}/master/${umdBundlePath})`
|
if (pkgJson.nodeBrowserSkel.badges.coveralls === true) {
|
||||||
workflowBadget = `[![Node.js CI](https://github.com/${repoUsername}/${repoName}/actions/workflows/nodejs.yml/badge.svg)](https://github.com/${repoUsername}/${repoName}/actions/workflows/nodejs.yml)`
|
useCoverallsBadge = true
|
||||||
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':
|
let iifeBundle, esmBundle, umdBundle, workflowBadge, coverallsBadge
|
||||||
iifeBundle = `[IIFE bundle](https://gitlab.com/${repoUsername}/${repoName}/-/raw/master/${iifeBundlePath}?inline=false)`
|
|
||||||
esmBundle = `[ESM bundle](https://gitlab.com/${repoUsername}/${repoName}/-/raw/master/${esmBundlePath}?inline=false)`
|
|
||||||
umdBundle = `[UMD bundle](https://gitlab.com/${repoUsername}/${repoName}/-/raw/master/${umdBundlePath}?inline=false)`
|
|
||||||
break
|
|
||||||
|
|
||||||
default:
|
if (repoProvider) {
|
||||||
break
|
switch (repoProvider) {
|
||||||
|
case 'github':
|
||||||
|
iifeBundle = iifeBundlePath !== undefined ? `[IIFE bundle](https://raw.githubusercontent.com/${repoUsername}/${repoName}/${branch}/${repoDirectory !== undefined ? repoDirectory + '/' : ''}${iifeBundlePath})` : undefined
|
||||||
|
esmBundle = esmBundlePath !== undefined ? `[ESM bundle](https://raw.githubusercontent.com/${repoUsername}/${repoName}/${branch}/${repoDirectory !== undefined ? repoDirectory + '/' : ''}${esmBundlePath})` : undefined
|
||||||
|
umdBundle = umdBundlePath !== undefined ? `[UMD bundle](https://raw.githubusercontent.com/${repoUsername}/${repoName}/${branch}/${repoDirectory !== undefined ? repoDirectory + '/' : ''}${umdBundlePath})` : undefined
|
||||||
|
workflowBadge = useWorkflowBadge ? `[![Node.js CI](https://github.com/${repoUsername}/${repoName}/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/${repoUsername}/${repoName}/actions/workflows/build-and-test.yml)` : undefined
|
||||||
|
coverallsBadge = useCoverallsBadge ? `[![Coverage Status](https://coveralls.io/repos/github/${repoUsername}/${repoName}/badge.svg?branch=${branch})](https://coveralls.io/github/${repoUsername}/${repoName}?branch=${branch})` : undefined
|
||||||
|
break
|
||||||
|
|
||||||
|
case 'gitlab':
|
||||||
|
iifeBundle = iifeBundlePath !== undefined ? `[IIFE bundle](https://gitlab.com/${repoUsername}/${repoName}/-/raw/${branch}/${repoDirectory !== undefined ? repoDirectory + '/' : ''}${iifeBundlePath}?inline=false)` : undefined
|
||||||
|
esmBundle = esmBundlePath !== undefined ? `[ESM bundle](https://gitlab.com/${repoUsername}/${repoName}/-/raw/${branch}/${repoDirectory !== undefined ? repoDirectory + '/' : ''}${esmBundlePath}?inline=false)` : undefined
|
||||||
|
umdBundle = umdBundlePath !== undefined ? `[UMD bundle](https://gitlab.com/${repoUsername}/${repoName}/-/raw/${branch}/${repoDirectory !== undefined ? repoDirectory + '/' : ''}${umdBundlePath}?inline=false)` : undefined
|
||||||
|
break
|
||||||
|
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template = template
|
||||||
|
.replace(/\{\{PKG_NAME\}\}/g, pkgJson.name)
|
||||||
|
.replace(/\{\{PKG_LICENSE\}\}/g, pkgJson.license.replace('-', '_'))
|
||||||
|
.replace(/\{\{PKG_DESCRIPTION\}\}/g, pkgJson.description)
|
||||||
|
.replace(/\{\{PKG_CAMELCASE\}\}/g, camelCaseName)
|
||||||
|
.replace(/\{\{IIFE_BUNDLE\}\}/g, iifeBundle || 'IIFE bundle')
|
||||||
|
.replace(/\{\{ESM_BUNDLE\}\}/g, esmBundle || 'ESM bundle')
|
||||||
|
.replace(/\{\{UMD_BUNDLE\}\}/g, umdBundle || 'UMD bundle')
|
||||||
|
|
||||||
|
if (repoProvider && repoProvider === 'github') {
|
||||||
|
template = template.replace(/\{\{GITHUB_ACTIONS_BADGES\}\}\n/gs, (workflowBadge ? `${workflowBadge}\n` : '') + (coverallsBadge ? `${coverallsBadge}\n` : ''))
|
||||||
|
} else {
|
||||||
|
template = template.replace(/\{\{GITHUB_ACTIONS_BADGES\}\}\n/gs, '')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const templateFile = path.join(rootDir, pkgJson.directories.src, 'docs/index.md')
|
function replaceRelativeLinks () {
|
||||||
let template = fs.readFileSync(templateFile, { encoding: 'UTF-8' })
|
const replacements = []
|
||||||
.replace(/\{\{PKG_NAME\}\}/g, pkgJson.name)
|
const relativePathRegex = /(\[[\w\s\d]+\]\()(?!(?:http:\/\/)|(?:https:\/\/))([\w\d;,/?:@&=+$-_.!~*'()\\#]+)\)/g
|
||||||
.replace(/\{\{PKG_CAMELCASE\}\}/g, camelCaseName)
|
const matches = template.matchAll(relativePathRegex)
|
||||||
.replace(/\{\{IIFE_BUNDLE\}\}/g, iifeBundle || 'IIFE bundle')
|
if (matches) {
|
||||||
.replace(/\{\{ESM_BUNDLE\}\}/g, esmBundle || 'ESM bundle')
|
for (const match of matches) {
|
||||||
.replace(/\{\{UMD_BUNDLE\}\}/g, umdBundle || 'UMD bundle')
|
const index = (match.index ?? 0) + match[1].length
|
||||||
|
const filepath = match[2]
|
||||||
if (repoProvider && repoProvider === 'github') {
|
if (!path.isAbsolute(filepath)) {
|
||||||
template = template.replace(/\{\{GITHUB_ACTIONS_BADGES\}\}/g, workflowBadget + '\n' + coverallsBadge)
|
const absoluteFilePath = path.join(path.dirname(templateFilePath), filepath)
|
||||||
} else {
|
if (!fs.existsSync(absoluteFilePath)) {
|
||||||
template = template.replace(/\{\{GITHUB_ACTIONS_BADGES\}\}/g, '')
|
console.warn(`File ${absoluteFilePath} is linked in your index.md but it does not exist. Ignoring`)
|
||||||
|
} else {
|
||||||
|
const replacement = path.relative(rootDir, absoluteFilePath)
|
||||||
|
replacements.push({ index, length: filepath.length, replacement })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const sortedReplacements = replacements.sort((a, b) => a.index - b.index)
|
||||||
|
let ret = ''
|
||||||
|
let index = 0
|
||||||
|
for (const replacement of sortedReplacements) {
|
||||||
|
ret += template.slice(index, replacement.index)
|
||||||
|
ret += replacement.replacement
|
||||||
|
index = replacement.index + replacement.length
|
||||||
|
}
|
||||||
|
ret += template.slice(index)
|
||||||
|
template = ret
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const readmeFile = path.join(rootDir, 'README.md')
|
|
||||||
fs.writeFileSync(readmeFile, template)
|
|
||||||
|
|
||||||
typedoc()
|
|
||||||
|
|
||||||
rimraf.sync(tempTsConfigPath)
|
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
import { mkdirSync, readFileSync, writeFileSync } from 'fs'
|
import { mkdirSync, readFileSync, writeFileSync } from 'fs'
|
||||||
import ts from 'typescript'
|
import ts from 'typescript'
|
||||||
import { join, dirname } from 'path'
|
import { join, dirname, extname } from 'path'
|
||||||
import { sync } from 'rimraf'
|
import { sync } from 'rimraf'
|
||||||
|
import * as url from 'url'
|
||||||
|
const __dirname = url.fileURLToPath(new URL('.', import.meta.url))
|
||||||
|
|
||||||
const { readJsonConfigFile, sys, parseJsonSourceFileConfigFileContent, createCompilerHost, createProgram } = ts
|
const { readJsonConfigFile, sys, parseJsonSourceFileConfigFileContent, createCompilerHost, createProgram } = ts
|
||||||
|
|
||||||
|
@ -31,6 +33,15 @@ const host = createCompilerHost(compilerOptions)
|
||||||
host.writeFile = (fileName, contents) => {
|
host.writeFile = (fileName, contents) => {
|
||||||
mkdirSync(dirname(fileName), { recursive: true })
|
mkdirSync(dirname(fileName), { recursive: true })
|
||||||
writeFileSync(fileName, contents)
|
writeFileSync(fileName, contents)
|
||||||
|
|
||||||
|
// we also write the .d.cts types
|
||||||
|
let fileName2 = ''
|
||||||
|
if (extname(fileName) === '.ts') {
|
||||||
|
fileName2 = fileName.slice(0, -2) + 'cts'
|
||||||
|
} else { // ext is .d.ts.map
|
||||||
|
fileName2 = fileName.slice(0, -6) + 'cts.map'
|
||||||
|
}
|
||||||
|
writeFileSync(fileName2, contents)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const compile = () => {
|
export const compile = () => {
|
||||||
|
|
|
@ -1,19 +1,25 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
|
import inject from '@rollup/plugin-inject'
|
||||||
import { nodeResolve as resolve } from '@rollup/plugin-node-resolve'
|
import { nodeResolve as resolve } from '@rollup/plugin-node-resolve'
|
||||||
import replace from '@rollup/plugin-replace'
|
import replace from '@rollup/plugin-replace'
|
||||||
import { terser } from 'rollup-plugin-terser'
|
import terser from '@rollup/plugin-terser'
|
||||||
import typescriptPlugin from '@rollup/plugin-typescript'
|
import typescriptPlugin from '@rollup/plugin-typescript'
|
||||||
import commonjs from '@rollup/plugin-commonjs'
|
import commonjs from '@rollup/plugin-commonjs'
|
||||||
import json from '@rollup/plugin-json'
|
import json from '@rollup/plugin-json'
|
||||||
|
|
||||||
import { join } from 'path'
|
import { dirname, join } from 'path'
|
||||||
import { existsSync } from 'fs'
|
import { existsSync, readFileSync } from 'fs'
|
||||||
import { directories, name as _name, exports } from '../package.json'
|
|
||||||
|
// import { browser, name as _name, exports } from '../package.json' assert { type: 'json' }
|
||||||
import { compile } from './rollup-plugin-dts.js'
|
import { compile } from './rollup-plugin-dts.js'
|
||||||
|
|
||||||
|
import * as url from 'url'
|
||||||
|
const __dirname = url.fileURLToPath(new URL('.', import.meta.url))
|
||||||
|
|
||||||
const rootDir = join(__dirname, '..')
|
const rootDir = join(__dirname, '..')
|
||||||
const dstDir = join(rootDir, directories.dist)
|
const pkgJson = JSON.parse(readFileSync(join(rootDir, 'package.json')))
|
||||||
|
// const dstDir = join(rootDir, directories.dist)
|
||||||
const srcDir = join(rootDir, 'src', 'ts')
|
const srcDir = join(rootDir, 'src', 'ts')
|
||||||
|
|
||||||
function camelise (str) {
|
function camelise (str) {
|
||||||
|
@ -24,7 +30,7 @@ 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 } = _name.match(regex).groups
|
const { name } = pkgJson.name.match(regex).groups
|
||||||
const pkgCamelisedName = camelise(name)
|
const pkgCamelisedName = camelise(name)
|
||||||
|
|
||||||
const input = join(srcDir, 'index.ts')
|
const input = join(srcDir, 'index.ts')
|
||||||
|
@ -52,119 +58,61 @@ function compileDts () {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
{ // Node ESM with declarations
|
{ // Browser ESM bundle
|
||||||
input: input,
|
input,
|
||||||
output: [
|
output: [
|
||||||
{
|
{
|
||||||
file: join(rootDir, exports['.'].node.import),
|
file: join(rootDir, pkgJson.browser),
|
||||||
...sourcemapOutputOptions,
|
...sourcemapOutputOptions,
|
||||||
format: 'es'
|
format: 'es'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
plugins: [
|
|
||||||
replace({
|
|
||||||
IS_BROWSER: false,
|
|
||||||
preventAssignment: true
|
|
||||||
}),
|
|
||||||
typescriptPlugin(tsBundleOptions),
|
|
||||||
compileDts(),
|
|
||||||
// resolve({
|
|
||||||
// browser: false,
|
|
||||||
// exportConditions: ['node']
|
|
||||||
// }),
|
|
||||||
commonjs({ extensions: ['.js', '.cjs', '.ts', '.jsx', '.cjsx', '.tsx'] }), // the ".ts" extension is required
|
|
||||||
json()
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{ // Node CJS
|
|
||||||
input: input,
|
|
||||||
output: [
|
|
||||||
{
|
|
||||||
file: join(rootDir, exports['.'].node.require),
|
|
||||||
...sourcemapOutputOptions,
|
|
||||||
format: 'cjs',
|
|
||||||
exports: 'auto'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
plugins: [
|
|
||||||
// replace({
|
|
||||||
// 'await import(': 'require(',
|
|
||||||
// delimiters: ['', ''],
|
|
||||||
// preventAssignment: true
|
|
||||||
// }),
|
|
||||||
replace({
|
|
||||||
IS_BROWSER: false,
|
|
||||||
preventAssignment: true
|
|
||||||
}),
|
|
||||||
typescriptPlugin(tsBundleOptions),
|
|
||||||
// resolve({
|
|
||||||
// browser: false,
|
|
||||||
// exportConditions: ['node']
|
|
||||||
// }),
|
|
||||||
commonjs({ extensions: ['.js', '.cjs', '.ts', '.jsx', '.cjsx', '.tsx'] }), // the ".ts" extension is required
|
|
||||||
json()
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{ // ESM for browsers
|
|
||||||
input: input,
|
|
||||||
output: [
|
|
||||||
{
|
|
||||||
file: join(rootDir, exports['.'].default),
|
|
||||||
...sourcemapOutputOptions,
|
|
||||||
format: 'es'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
file: join(dstDir, 'bundles/esm.js'),
|
|
||||||
...sourcemapOutputOptions,
|
|
||||||
format: 'es'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
file: join(dstDir, 'bundles/esm.min.js'),
|
|
||||||
format: 'es',
|
|
||||||
plugins: [terser()]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
plugins: [
|
plugins: [
|
||||||
replace({
|
replace({
|
||||||
IS_BROWSER: true,
|
IS_BROWSER: true,
|
||||||
|
_MODULE_TYPE: "'ESM'",
|
||||||
preventAssignment: true
|
preventAssignment: true
|
||||||
}),
|
}),
|
||||||
typescriptPlugin(tsBundleOptions),
|
typescriptPlugin(tsBundleOptions),
|
||||||
resolve({
|
|
||||||
browser: true,
|
|
||||||
exportConditions: ['browser', 'default']
|
|
||||||
}),
|
|
||||||
commonjs({ extensions: ['.js', '.cjs', '.ts', '.jsx', '.cjsx', '.tsx'] }), // the ".ts" extension is required
|
commonjs({ extensions: ['.js', '.cjs', '.ts', '.jsx', '.cjsx', '.tsx'] }), // the ".ts" extension is required
|
||||||
json()
|
json()
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{ // Browser bundles
|
{ // Browser bundles
|
||||||
input: input,
|
input,
|
||||||
output: [
|
output: [
|
||||||
{
|
{
|
||||||
file: join(dstDir, 'bundles/iife.js'),
|
file: join(rootDir, pkgJson.exports['./esm-browser-bundle-nomin']),
|
||||||
|
format: 'es'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
file: join(rootDir, pkgJson.exports['./esm-browser-bundle']),
|
||||||
|
format: 'es',
|
||||||
|
plugins: [terser()]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
file: join(rootDir, pkgJson.exports['./iife-browser-bundle']),
|
||||||
format: 'iife',
|
format: 'iife',
|
||||||
name: pkgCamelisedName,
|
name: pkgCamelisedName,
|
||||||
plugins: [terser()]
|
plugins: [terser()]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
file: join(dstDir, 'bundles/umd.js'),
|
file: join(rootDir, pkgJson.exports['./umd-browser-bundle']),
|
||||||
format: 'umd',
|
format: 'umd',
|
||||||
name: pkgCamelisedName,
|
name: pkgCamelisedName,
|
||||||
plugins: [terser()]
|
plugins: [terser()]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
plugins: [
|
plugins: [
|
||||||
// replace({
|
|
||||||
// 'await import(': 'require(',
|
|
||||||
// delimiters: ['', ''],
|
|
||||||
// preventAssignment: true
|
|
||||||
// }),
|
|
||||||
replace({
|
replace({
|
||||||
IS_BROWSER: true,
|
IS_BROWSER: true,
|
||||||
|
_MODULE_TYPE: "'BUNDLE'",
|
||||||
preventAssignment: true
|
preventAssignment: true
|
||||||
}),
|
}),
|
||||||
typescriptPlugin(tsBundleOptions),
|
typescriptPlugin({
|
||||||
|
...tsBundleOptions,
|
||||||
|
sourceMap: false
|
||||||
|
}),
|
||||||
resolve({
|
resolve({
|
||||||
browser: true,
|
browser: true,
|
||||||
exportConditions: ['browser', 'default'],
|
exportConditions: ['browser', 'default'],
|
||||||
|
@ -173,5 +121,69 @@ export default [
|
||||||
commonjs({ extensions: ['.js', '.cjs', '.ts', '.jsx', '.cjsx', '.tsx'] }), // the ".ts" extension is required
|
commonjs({ extensions: ['.js', '.cjs', '.ts', '.jsx', '.cjsx', '.tsx'] }), // the ".ts" extension is required
|
||||||
json()
|
json()
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{ // Node CJS
|
||||||
|
input,
|
||||||
|
output: [
|
||||||
|
{
|
||||||
|
file: join(rootDir, pkgJson.exports['.'].node.require.default),
|
||||||
|
...sourcemapOutputOptions,
|
||||||
|
format: 'cjs',
|
||||||
|
exports: 'auto',
|
||||||
|
plugins: [
|
||||||
|
terser()
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
plugins: [
|
||||||
|
replace({
|
||||||
|
IS_BROWSER: false,
|
||||||
|
_MODULE_TYPE: "'CJS'",
|
||||||
|
preventAssignment: true
|
||||||
|
}),
|
||||||
|
inject({
|
||||||
|
crypto: ['crypto', 'webcrypto']
|
||||||
|
}),
|
||||||
|
typescriptPlugin(tsBundleOptions),
|
||||||
|
// resolve({
|
||||||
|
// browser: false,
|
||||||
|
// exportConditions: ['require', 'node', 'module', 'import']
|
||||||
|
// }),
|
||||||
|
commonjs({ extensions: ['.js', '.cjs', '.ts', '.jsx', '.cjsx', '.tsx'] }), // the ".ts" extension is required
|
||||||
|
json()
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{ // Node ESM and type declarations
|
||||||
|
input,
|
||||||
|
output: [
|
||||||
|
{
|
||||||
|
file: join(rootDir, pkgJson.exports['.'].node.import.default),
|
||||||
|
...sourcemapOutputOptions,
|
||||||
|
format: 'es',
|
||||||
|
plugins: [
|
||||||
|
terser()
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
plugins: [
|
||||||
|
replace({
|
||||||
|
IS_BROWSER: false,
|
||||||
|
_MODULE_TYPE: "'ESM'",
|
||||||
|
__filename: `'${pkgJson.exports['.'].node.import.default}'`,
|
||||||
|
__dirname: `'${dirname(pkgJson.exports['.'].node.import.default)}'`,
|
||||||
|
preventAssignment: true
|
||||||
|
}),
|
||||||
|
inject({
|
||||||
|
crypto: ['crypto', 'webcrypto']
|
||||||
|
}),
|
||||||
|
typescriptPlugin(tsBundleOptions),
|
||||||
|
// resolve({
|
||||||
|
// browser: false,
|
||||||
|
// exportConditions: ['node']
|
||||||
|
// }),
|
||||||
|
compileDts(),
|
||||||
|
commonjs({ extensions: ['.js', '.cjs', '.ts', '.jsx', '.cjsx', '.tsx'] }), // the ".ts" extension is required
|
||||||
|
json()
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 326 B |
|
@ -4,6 +4,7 @@ const puppeteer = require('puppeteer')
|
||||||
const minimatch = require('minimatch')
|
const minimatch = require('minimatch')
|
||||||
const glob = require('glob')
|
const glob = require('glob')
|
||||||
const rootDir = path.join(__dirname, '../../..')
|
const rootDir = path.join(__dirname, '../../..')
|
||||||
|
const pkgJson = require(path.join(rootDir, 'package.json'))
|
||||||
|
|
||||||
const browserTests = async (
|
const browserTests = async (
|
||||||
{
|
{
|
||||||
|
@ -21,12 +22,7 @@ const browserTests = async (
|
||||||
const browser = await puppeteer.launch(puppeteerOptions)
|
const browser = await puppeteer.launch(puppeteerOptions)
|
||||||
const page = (await browser.pages())[0]
|
const page = (await browser.pages())[0]
|
||||||
page.on('console', function (message) {
|
page.on('console', function (message) {
|
||||||
let ignore = message.type() === 'warning' && !logWarnings
|
const ignore = message.type() === 'warning' && !logWarnings
|
||||||
if (message.type() === 'error' && message.location()) {
|
|
||||||
if (message.location().url.includes('favicon.ico')) {
|
|
||||||
ignore = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ignore) return
|
if (ignore) return
|
||||||
|
|
||||||
let text = (message.args().length > 0) ? message.args()[0].remoteObject().value : message.text()
|
let text = (message.args().length > 0) ? message.args()[0].remoteObject().value : message.text()
|
||||||
|
@ -83,12 +79,15 @@ const browserTests = async (
|
||||||
|
|
||||||
function processedTestFiles (testFilesStr) {
|
function processedTestFiles (testFilesStr) {
|
||||||
if (testFilesStr === undefined) {
|
if (testFilesStr === undefined) {
|
||||||
return undefined
|
testFilesStr = [pkgJson.directories.test + '/**/*.ts', pkgJson.directories.src + '/**/*.spec.ts']
|
||||||
|
} else {
|
||||||
|
// Let us first remove surrounding quotes in string (it gives issues in windows)
|
||||||
|
testFilesStr = testFilesStr.replace(/^['"]/, '').replace(/['"]$/, '')
|
||||||
}
|
}
|
||||||
// Let us first remove surrounding quotes in string (it gives issues in windows)
|
|
||||||
testFilesStr = testFilesStr.replace(/^['"]/, '').replace(/['"]$/, '')
|
|
||||||
const filenames = glob.sync(testFilesStr, { cwd: rootDir, matchBase: true })
|
const filenames = glob.sync(testFilesStr, { cwd: rootDir, matchBase: true })
|
||||||
if (filenames.length > 0) {
|
if (filenames.length === 0) {
|
||||||
|
throw new Error('no test files found for ' + testFilesStr)
|
||||||
|
} else {
|
||||||
filenames.forEach(file => {
|
filenames.forEach(file => {
|
||||||
const isTsTestFile = minimatch(file, '{test/**/*.ts,src/**/*.spec.ts}', { matchBase: true })
|
const isTsTestFile = minimatch(file, '{test/**/*.ts,src/**/*.spec.ts}', { matchBase: true })
|
||||||
if (!isTsTestFile) {
|
if (!isTsTestFile) {
|
||||||
|
|
|
@ -9,10 +9,10 @@ require('dotenv').config()
|
||||||
const rollup = require('rollup')
|
const rollup = require('rollup')
|
||||||
const resolve = require('@rollup/plugin-node-resolve').nodeResolve
|
const resolve = require('@rollup/plugin-node-resolve').nodeResolve
|
||||||
const replace = require('@rollup/plugin-replace')
|
const replace = require('@rollup/plugin-replace')
|
||||||
const multi = require('@rollup/plugin-multi-entry')
|
|
||||||
const typescriptPlugin = require('@rollup/plugin-typescript')
|
const typescriptPlugin = require('@rollup/plugin-typescript')
|
||||||
const commonjs = require('@rollup/plugin-commonjs')
|
const commonjs = require('@rollup/plugin-commonjs')
|
||||||
const json = require('@rollup/plugin-json')
|
const json = require('@rollup/plugin-json')
|
||||||
|
const multi = require('@rollup/plugin-multi-entry')
|
||||||
const runScript = require('../../run-script.cjs')
|
const runScript = require('../../run-script.cjs')
|
||||||
|
|
||||||
const rootDir = path.join(__dirname, '..', '..', '..')
|
const rootDir = path.join(__dirname, '..', '..', '..')
|
||||||
|
@ -49,16 +49,17 @@ const indexHtml = `<!DOCTYPE html>
|
||||||
|
|
||||||
const tsBundleOptions = {
|
const tsBundleOptions = {
|
||||||
tsconfig: path.join(rootDir, 'tsconfig.json'),
|
tsconfig: path.join(rootDir, 'tsconfig.json'),
|
||||||
outDir: undefined // ignore outDir in tsconfig.json
|
outDir: undefined, // ignore outDir in tsconfig.json
|
||||||
|
sourceMap: false
|
||||||
|
// include: ['build/typings/is-browser.d.ts']
|
||||||
}
|
}
|
||||||
|
|
||||||
async function buildTests (testFiles) {
|
async function buildTests (testFiles) {
|
||||||
// create a bundle
|
// create a bundle
|
||||||
const input = testFiles ?? [path.join(rootDir, pkgJson.directories.test, '**/*.ts'), path.join(rootDir, pkgJson.directories.src, '**/*.spec.ts')]
|
|
||||||
const inputOptions = {
|
const inputOptions = {
|
||||||
input,
|
input: testFiles,
|
||||||
plugins: [
|
plugins: [
|
||||||
multi({ exports: true }),
|
multi(),
|
||||||
replace({
|
replace({
|
||||||
'#pkg': `/${name}.esm.js`,
|
'#pkg': `/${name}.esm.js`,
|
||||||
delimiters: ['', ''],
|
delimiters: ['', ''],
|
||||||
|
@ -66,12 +67,14 @@ async function buildTests (testFiles) {
|
||||||
}),
|
}),
|
||||||
replace({
|
replace({
|
||||||
IS_BROWSER: true,
|
IS_BROWSER: true,
|
||||||
|
_MODULE_TYPE: "'ESM'",
|
||||||
preventAssignment: true
|
preventAssignment: true
|
||||||
}),
|
}),
|
||||||
typescriptPlugin(tsBundleOptions),
|
typescriptPlugin(tsBundleOptions),
|
||||||
resolve({
|
resolve({
|
||||||
browser: true,
|
browser: true,
|
||||||
exportConditions: ['browser', 'default']
|
exportConditions: ['browser', 'default'],
|
||||||
|
mainFields: ['browser', 'module', 'main']
|
||||||
}),
|
}),
|
||||||
commonjs(),
|
commonjs(),
|
||||||
json()
|
json()
|
||||||
|
@ -79,7 +82,7 @@ async function buildTests (testFiles) {
|
||||||
external: [`/${name}.esm.js`]
|
external: [`/${name}.esm.js`]
|
||||||
}
|
}
|
||||||
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: 'es' })
|
||||||
await bundle.close()
|
await bundle.close()
|
||||||
let bundledCode = output[0].code
|
let bundledCode = output[0].code
|
||||||
const replacements = _getEnvVarsReplacements(bundledCode)
|
const replacements = _getEnvVarsReplacements(bundledCode)
|
||||||
|
@ -97,14 +100,14 @@ class TestServer {
|
||||||
|
|
||||||
async init (testFiles) {
|
async init (testFiles) {
|
||||||
/** Let us first check if the necessary files are built, and if not, build */
|
/** Let us first check if the necessary files are built, and if not, build */
|
||||||
if (!fs.existsSync(pkgJson.exports['./esm-browser-bundle'])) {
|
if (!fs.existsSync(pkgJson.exports['./esm-browser-bundle-nomin'])) {
|
||||||
await runScript(path.join(rootDir, 'node_modules', '.bin', 'rollup'), ['-c', 'build/rollup.config.js'])
|
await runScript(path.join(rootDir, 'node_modules', '.bin', 'rollup'), ['-c', 'build/rollup.config.js'])
|
||||||
}
|
}
|
||||||
|
|
||||||
const tests = await buildTests(testFiles)
|
const tests = await buildTests(testFiles)
|
||||||
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.exports['./esm-browser-bundle']), function (err, data) {
|
fs.readFile(path.join(rootDir, pkgJson.exports['./esm-browser-bundle-nomin']), function (err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
res.writeHead(404)
|
res.writeHead(404)
|
||||||
res.end(JSON.stringify(err))
|
res.end(JSON.stringify(err))
|
||||||
|
@ -129,6 +132,16 @@ class TestServer {
|
||||||
res.writeHead(200, { 'Content-Type': 'text/javascript' })
|
res.writeHead(200, { 'Content-Type': 'text/javascript' })
|
||||||
res.end(data)
|
res.end(data)
|
||||||
})
|
})
|
||||||
|
} else if (req.url === '/mocha.js.map') {
|
||||||
|
fs.readFile(path.join(rootDir, 'node_modules/mocha/mocha.js.map'), function (err, data) {
|
||||||
|
if (err) {
|
||||||
|
res.writeHead(404)
|
||||||
|
res.end(JSON.stringify(err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
res.writeHead(200, { 'Content-Type': 'text/javascript' })
|
||||||
|
res.end(data)
|
||||||
|
})
|
||||||
} else if (req.url === '/chai.js' || req.url === '/chai') {
|
} else if (req.url === '/chai.js' || req.url === '/chai') {
|
||||||
fs.readFile(path.join(rootDir, 'node_modules/chai/chai.js'), function (err, data) {
|
fs.readFile(path.join(rootDir, 'node_modules/chai/chai.js'), function (err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -139,6 +152,16 @@ class TestServer {
|
||||||
res.writeHead(200, { 'Content-Type': 'text/javascript' })
|
res.writeHead(200, { 'Content-Type': 'text/javascript' })
|
||||||
res.end(data)
|
res.end(data)
|
||||||
})
|
})
|
||||||
|
} else if (req.url === '/favicon.ico') {
|
||||||
|
fs.readFile(path.join(__dirname, 'favicon.ico'), function (err, data) {
|
||||||
|
if (err) {
|
||||||
|
res.writeHead(404)
|
||||||
|
res.end(JSON.stringify(err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
res.writeHead(200, { 'Content-Type': 'application/ico' })
|
||||||
|
res.end(data)
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
res.writeHead(404)
|
res.writeHead(404)
|
||||||
res.end()
|
res.end()
|
||||||
|
@ -171,7 +194,7 @@ function _getEnvVarsReplacements (testsCode) {
|
||||||
if (process.env[envVar] !== undefined) {
|
if (process.env[envVar] !== undefined) {
|
||||||
replacements[match[0]] = '`' + process.env[envVar] + '`'
|
replacements[match[0]] = '`' + process.env[envVar] + '`'
|
||||||
} else {
|
} else {
|
||||||
missingEnvVars.push(envVar)
|
replacements[match[0]] = undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const match of testsCode.matchAll(/process\.env\[['"](\w+)['"]\]/g)) {
|
for (const match of testsCode.matchAll(/process\.env\[['"](\w+)['"]\]/g)) {
|
||||||
|
@ -179,11 +202,11 @@ function _getEnvVarsReplacements (testsCode) {
|
||||||
if (process.env[envVar] !== undefined) {
|
if (process.env[envVar] !== undefined) {
|
||||||
replacements[match[0]] = '`' + process.env[envVar] + '`'
|
replacements[match[0]] = '`' + process.env[envVar] + '`'
|
||||||
} else {
|
} else {
|
||||||
missingEnvVars.push(envVar)
|
replacements[match[0]] = undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (missingEnvVars.length > 0) {
|
if (missingEnvVars.length > 0) {
|
||||||
throw EvalError('The folloinwg environment variables are missing in your .env file: ' + missingEnvVars)
|
console.warn('The folloinwg environment variables are missing in your .env file and will be replaced with "undefined": ' + [...(new Set(missingEnvVars)).values()].join(', '))
|
||||||
}
|
}
|
||||||
return replacements
|
return replacements
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ const fs = require('fs')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
|
||||||
const rollup = require('rollup')
|
const rollup = require('rollup')
|
||||||
const loadAndParseConfigFile = require('rollup/dist/loadConfigFile')
|
const loadAndParseConfigFile = require('rollup/loadConfigFile').loadConfigFile
|
||||||
|
|
||||||
const Builder = require('./Builder.cjs')
|
const Builder = require('./Builder.cjs')
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ class RollupBuilder extends Builder {
|
||||||
|
|
||||||
this.watch = watch
|
this.watch = watch
|
||||||
this.commonjs = commonjs
|
this.commonjs = commonjs
|
||||||
this.watchedModule = commonjs ? pkgJson.exports['.'].node.require : pkgJson.exports['.'].node.import
|
this.watchedModule = commonjs ? pkgJson.exports['.'].node.require.default : pkgJson.exports['.'].node.import.default
|
||||||
|
|
||||||
const { options } = await loadAndParseConfigFile(this.configPath)
|
const { options } = await loadAndParseConfigFile(this.configPath)
|
||||||
|
|
||||||
|
|
|
@ -30,13 +30,36 @@ function renameJsToCjs (dir, fileList = []) {
|
||||||
const files = fs.readdirSync(dir)
|
const files = fs.readdirSync(dir)
|
||||||
|
|
||||||
files.forEach(file => {
|
files.forEach(file => {
|
||||||
if (fs.statSync(path.join(dir, file)).isDirectory()) {
|
const srcFile = path.join(dir, file)
|
||||||
fileList = renameJsToCjs(path.join(dir, file), fileList)
|
if (fs.statSync(srcFile).isDirectory()) {
|
||||||
|
fileList = renameJsToCjs(srcFile, fileList)
|
||||||
} else {
|
} else {
|
||||||
const match = file.match(/(.*)\.js$/)
|
const match = file.match(/(.*)\.js$/)
|
||||||
if (match !== null) {
|
if (match !== null) {
|
||||||
const filename = match[1]
|
const filename = match[1]
|
||||||
fs.renameSync(path.join(dir, file), path.join(dir, `${filename}.cjs`))
|
const dstFile = path.join(dir, `${filename}.cjs`)
|
||||||
|
fs.renameSync(srcFile, dstFile)
|
||||||
|
const fileContents = fs.readFileSync(dstFile, 'utf8')
|
||||||
|
const updatedFileContents = fileContents.replace(/(require\([`'"])(\..*[^.]{5})([`'"])/g, '$1$2.cjs$3')
|
||||||
|
fs.writeFileSync(dstFile, updatedFileContents, { encoding: 'utf8' })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function fixJsonAssertsInESMTests (dir, fileList = []) {
|
||||||
|
const files = fs.readdirSync(dir)
|
||||||
|
|
||||||
|
files.forEach(file => {
|
||||||
|
const srcFile = path.join(dir, file)
|
||||||
|
if (fs.statSync(srcFile).isDirectory()) {
|
||||||
|
fileList = fixJsonAssertsInESMTests(srcFile, fileList)
|
||||||
|
} else {
|
||||||
|
const match = file.match(/(.*)\.js$/)
|
||||||
|
if (match !== null) {
|
||||||
|
const fileContents = fs.readFileSync(srcFile, 'utf8')
|
||||||
|
const updatedFileContents = fileContents.replace(/(import\([`'"]\..*\.json[`'"])\)/g, '$1, { assert: { type: "json" } })')
|
||||||
|
fs.writeFileSync(srcFile, updatedFileContents, { encoding: 'utf8' })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -124,6 +147,8 @@ class TestsBuilder extends Builder {
|
||||||
}
|
}
|
||||||
if (this.commonjs) {
|
if (this.commonjs) {
|
||||||
renameJsToCjs(mochaTsDir)
|
renameJsToCjs(mochaTsDir)
|
||||||
|
} else {
|
||||||
|
fixJsonAssertsInESMTests(mochaTsDir)
|
||||||
}
|
}
|
||||||
this.emit('ready', updateSemaphore)
|
this.emit('ready', updateSemaphore)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -27,6 +27,8 @@ let commonjs = setup.commonjs
|
||||||
|
|
||||||
commonjs = watch ? true : commonjs // mocha in watch mode only supports commonjs
|
commonjs = watch ? true : commonjs // mocha in watch mode only supports commonjs
|
||||||
|
|
||||||
|
global._MODULE_TYPE = commonjs ? 'CJS' : 'ESM'
|
||||||
|
|
||||||
exports.mochaGlobalSetup = async function () {
|
exports.mochaGlobalSetup = async function () {
|
||||||
if (watch) {
|
if (watch) {
|
||||||
await rollupBuilder.start({ commonjs, watch })
|
await rollupBuilder.start({ commonjs, watch })
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
declare const IS_BROWSER: boolean
|
declare const IS_BROWSER: boolean
|
||||||
|
declare const _MODULE_TYPE: string
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
||||||
var bigintModArith=function(n){"use strict";function t(n){return n>=0?n:-n}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,i=0n;for(;0n!==n;){const u=t/n,f=t%n,g=r-o*u,b=e-i*u;t=n,n=f,r=o,e=i,o=g,i=b}return{g:t,x:r,y:e}}function e(n,r){let e="number"==typeof n?BigInt(t(n)):t(n),o="number"==typeof r?BigInt(t(r)):t(r);if(0n===e)return o;if(0n===o)return e;let i=0n;for(;0n===(1n&(e|o));)e>>=1n,o>>=1n,i++;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<<i}function o(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 i(n,t){const e=r(o(n,t),t);if(1n!==e.g)throw new RangeError(`${n.toString()} does not have inverse modulo ${t.toString()}`);return o(e.x,t)}return n.abs=t,n.bitLength=function(n){if("number"==typeof n&&(n=BigInt(n)),1n===n)return 1;let t=1;do{t++}while((n>>=1n)>1n);return t},n.eGcd=r,n.gcd=e,n.lcm=function(n,r){return"number"==typeof n&&(n=BigInt(n)),"number"==typeof r&&(r=BigInt(r)),0n===n&&0n===r?BigInt(0):t(n/e(n,r)*r)},n.max=function(n,t){return n>=t?n:t},n.min=function(n,t){return n>=t?t:n},n.modInv=i,n.modPow=function n(r,e,u){if("number"==typeof r&&(r=BigInt(r)),"number"==typeof e&&(e=BigInt(e)),"number"==typeof u&&(u=BigInt(u)),u<=0n)throw new RangeError("n must be > 0");if(1n===u)return 0n;if(r=o(r,u),e<0n)return i(n(r,t(e),u),u);let f=1n;for(;e>0;)e%2n===1n&&(f=f*r%u),e/=2n,r=r**2n%u;return f},n.toZn=o,Object.defineProperty(n,"__esModule",{value:!0}),n}({});
|
var bigintModArith=function(n){"use strict";function t(n){return n>=0?n:-n}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,i=0n;for(;0n!==n;){const u=t/n,f=t%n,g=r-o*u,m=e-i*u;t=n,n=f,r=o,e=i,o=g,i=m}return{g:t,x:r,y:e}}function e(n,r){let e="number"==typeof n?BigInt(t(n)):t(n),o="number"==typeof r?BigInt(t(r)):t(r);if(0n===e)return o;if(0n===o)return e;let i=0n;for(;0n===(1n&(e|o));)e>>=1n,o>>=1n,i++;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<<i}function o(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 i(n,t){const e=r(o(n,t),t);if(1n!==e.g)throw new RangeError(`${n.toString()} does not have inverse modulo ${t.toString()}`);return o(e.x,t)}return n.abs=t,n.bitLength=function(n){if("number"==typeof n&&(n=BigInt(n)),1n===n)return 1;let t=1;do{t++}while((n>>=1n)>1n);return t},n.eGcd=r,n.gcd=e,n.lcm=function(n,r){return"number"==typeof n&&(n=BigInt(n)),"number"==typeof r&&(r=BigInt(r)),0n===n&&0n===r?BigInt(0):t(n/e(n,r)*r)},n.max=function(n,t){return n>=t?n:t},n.min=function(n,t){return n>=t?t:n},n.modInv=i,n.modPow=function n(r,e,u){if("number"==typeof r&&(r=BigInt(r)),"number"==typeof e&&(e=BigInt(e)),"number"==typeof u&&(u=BigInt(u)),u<=0n)throw new RangeError("n must be > 0");if(1n===u)return 0n;if(r=o(r,u),e<0n)return i(n(r,t(e),u),u);let f=1n;for(;e>0;)e%2n===1n&&(f=f*r%u),e/=2n,r=r**2n%u;return f},n.toZn=o,n}({});
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((n="undefined"!=typeof globalThis?globalThis:n||self).bigintModArith={})}(this,(function(n){"use strict";function e(n){return n>=0?n:-n}function t(n,e){if("number"==typeof n&&(n=BigInt(n)),"number"==typeof e&&(e=BigInt(e)),n<=0n||e<=0n)throw new RangeError("a and b MUST be > 0");let t=0n,r=1n,o=1n,i=0n;for(;0n!==n;){const f=e/n,u=e%n,g=t-o*f,b=r-i*f;e=n,n=u,t=o,r=i,o=g,i=b}return{g:e,x:t,y:r}}function r(n,t){let r="number"==typeof n?BigInt(e(n)):e(n),o="number"==typeof t?BigInt(e(t)):e(t);if(0n===r)return o;if(0n===o)return r;let i=0n;for(;0n===(1n&(r|o));)r>>=1n,o>>=1n,i++;for(;0n===(1n&r);)r>>=1n;do{for(;0n===(1n&o);)o>>=1n;if(r>o){const n=r;r=o,o=n}o-=r}while(0n!==o);return r<<i}function o(n,e){if("number"==typeof n&&(n=BigInt(n)),"number"==typeof e&&(e=BigInt(e)),e<=0n)throw new RangeError("n must be > 0");const t=n%e;return t<0n?t+e:t}function i(n,e){const r=t(o(n,e),e);if(1n!==r.g)throw new RangeError(`${n.toString()} does not have inverse modulo ${e.toString()}`);return o(r.x,e)}n.abs=e,n.bitLength=function(n){if("number"==typeof n&&(n=BigInt(n)),1n===n)return 1;let e=1;do{e++}while((n>>=1n)>1n);return e},n.eGcd=t,n.gcd=r,n.lcm=function(n,t){return"number"==typeof n&&(n=BigInt(n)),"number"==typeof t&&(t=BigInt(t)),0n===n&&0n===t?BigInt(0):e(n/r(n,t)*t)},n.max=function(n,e){return n>=e?n:e},n.min=function(n,e){return n>=e?e:n},n.modInv=i,n.modPow=function n(t,r,f){if("number"==typeof t&&(t=BigInt(t)),"number"==typeof r&&(r=BigInt(r)),"number"==typeof f&&(f=BigInt(f)),f<=0n)throw new RangeError("n must be > 0");if(1n===f)return 0n;if(t=o(t,f),r<0n)return i(n(t,e(r),f),f);let u=1n;for(;r>0;)r%2n===1n&&(u=u*t%f),r/=2n,t=t**2n%f;return u},n.toZn=o,Object.defineProperty(n,"__esModule",{value:!0})}));
|
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n="undefined"!=typeof globalThis?globalThis:n||self).bigintModArith={})}(this,(function(n){"use strict";function t(n){return n>=0?n:-n}function e(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 e=0n,r=1n,o=1n,i=0n;for(;0n!==n;){const f=t/n,u=t%n,g=e-o*f,b=r-i*f;t=n,n=u,e=o,r=i,o=g,i=b}return{g:t,x:e,y:r}}function r(n,e){let r="number"==typeof n?BigInt(t(n)):t(n),o="number"==typeof e?BigInt(t(e)):t(e);if(0n===r)return o;if(0n===o)return r;let i=0n;for(;0n===(1n&(r|o));)r>>=1n,o>>=1n,i++;for(;0n===(1n&r);)r>>=1n;do{for(;0n===(1n&o);)o>>=1n;if(r>o){const n=r;r=o,o=n}o-=r}while(0n!==o);return r<<i}function o(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 e=n%t;return e<0n?e+t:e}function i(n,t){const r=e(o(n,t),t);if(1n!==r.g)throw new RangeError(`${n.toString()} does not have inverse modulo ${t.toString()}`);return o(r.x,t)}n.abs=t,n.bitLength=function(n){if("number"==typeof n&&(n=BigInt(n)),1n===n)return 1;let t=1;do{t++}while((n>>=1n)>1n);return t},n.eGcd=e,n.gcd=r,n.lcm=function(n,e){return"number"==typeof n&&(n=BigInt(n)),"number"==typeof e&&(e=BigInt(e)),0n===n&&0n===e?BigInt(0):t(n/r(n,e)*e)},n.max=function(n,t){return n>=t?n:t},n.min=function(n,t){return n>=t?t:n},n.modInv=i,n.modPow=function n(e,r,f){if("number"==typeof e&&(e=BigInt(e)),"number"==typeof r&&(r=BigInt(r)),"number"==typeof f&&(f=BigInt(f)),f<=0n)throw new RangeError("n must be > 0");if(1n===f)return 0n;if(e=o(e,f),r<0n)return i(n(e,t(r),f),f);let u=1n;for(;r>0;)r%2n===1n&&(u=u*e%f),r/=2n,e=e**2n%f;return u},n.toZn=o}));
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
20
docs/API.md
20
docs/API.md
|
@ -43,7 +43,7 @@ The absolute value of a
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[abs.ts:8](https://github.com/juanelas/bigint-mod-arith/blob/59cd071/src/ts/abs.ts#L8)
|
[abs.ts:8](https://github.com/juanelas/bigint-mod-arith/blob/fc5e3c5/src/ts/abs.ts#L8)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ The bit length
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[bitLength.ts:7](https://github.com/juanelas/bigint-mod-arith/blob/59cd071/src/ts/bitLength.ts#L7)
|
[bitLength.ts:7](https://github.com/juanelas/bigint-mod-arith/blob/fc5e3c5/src/ts/bitLength.ts#L7)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ A triple (g, x, y), such that ax + by = g = gcd(a, b).
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[egcd.ts:17](https://github.com/juanelas/bigint-mod-arith/blob/59cd071/src/ts/egcd.ts#L17)
|
[egcd.ts:17](https://github.com/juanelas/bigint-mod-arith/blob/fc5e3c5/src/ts/egcd.ts#L17)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ The greatest common divisor of a and b
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[gcd.ts:10](https://github.com/juanelas/bigint-mod-arith/blob/59cd071/src/ts/gcd.ts#L10)
|
[gcd.ts:10](https://github.com/juanelas/bigint-mod-arith/blob/fc5e3c5/src/ts/gcd.ts#L10)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ The least common multiple of a and b
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[lcm.ts:10](https://github.com/juanelas/bigint-mod-arith/blob/59cd071/src/ts/lcm.ts#L10)
|
[lcm.ts:10](https://github.com/juanelas/bigint-mod-arith/blob/fc5e3c5/src/ts/lcm.ts#L10)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ Maximum of numbers a and b
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[max.ts:9](https://github.com/juanelas/bigint-mod-arith/blob/59cd071/src/ts/max.ts#L9)
|
[max.ts:9](https://github.com/juanelas/bigint-mod-arith/blob/fc5e3c5/src/ts/max.ts#L9)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ Minimum of numbers a and b
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[min.ts:9](https://github.com/juanelas/bigint-mod-arith/blob/59cd071/src/ts/min.ts#L9)
|
[min.ts:9](https://github.com/juanelas/bigint-mod-arith/blob/fc5e3c5/src/ts/min.ts#L9)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ The inverse modulo n
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[modInv.ts:13](https://github.com/juanelas/bigint-mod-arith/blob/59cd071/src/ts/modInv.ts#L13)
|
[modInv.ts:13](https://github.com/juanelas/bigint-mod-arith/blob/fc5e3c5/src/ts/modInv.ts#L13)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
@ -256,7 +256,7 @@ b**e mod n
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[modPow.ts:15](https://github.com/juanelas/bigint-mod-arith/blob/59cd071/src/ts/modPow.ts#L15)
|
[modPow.ts:15](https://github.com/juanelas/bigint-mod-arith/blob/fc5e3c5/src/ts/modPow.ts#L15)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
@ -289,4 +289,4 @@ A bigint with the smallest positive representation of a modulo n
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[toZn.ts:14](https://github.com/juanelas/bigint-mod-arith/blob/59cd071/src/ts/toZn.ts#L14)
|
[toZn.ts:14](https://github.com/juanelas/bigint-mod-arith/blob/fc5e3c5/src/ts/toZn.ts#L14)
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[egcd.ts:2](https://github.com/juanelas/bigint-mod-arith/blob/59cd071/src/ts/egcd.ts#L2)
|
[egcd.ts:2](https://github.com/juanelas/bigint-mod-arith/blob/fc5e3c5/src/ts/egcd.ts#L2)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ ___
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[egcd.ts:3](https://github.com/juanelas/bigint-mod-arith/blob/59cd071/src/ts/egcd.ts#L3)
|
[egcd.ts:3](https://github.com/juanelas/bigint-mod-arith/blob/fc5e3c5/src/ts/egcd.ts#L3)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
@ -36,4 +36,4 @@ ___
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[egcd.ts:4](https://github.com/juanelas/bigint-mod-arith/blob/59cd071/src/ts/egcd.ts#L4)
|
[egcd.ts:4](https://github.com/juanelas/bigint-mod-arith/blob/fc5e3c5/src/ts/egcd.ts#L4)
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
91
package.json
91
package.json
|
@ -24,28 +24,47 @@
|
||||||
"node": ">=10.4.0"
|
"node": ">=10.4.0"
|
||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"types": "./types/index.d.ts",
|
|
||||||
"main": "./dist/cjs/index.node.cjs",
|
"main": "./dist/cjs/index.node.cjs",
|
||||||
|
"types": "./types/index.d.cts",
|
||||||
"browser": "./dist/esm/index.browser.js",
|
"browser": "./dist/esm/index.browser.js",
|
||||||
"module": "./dist/esm/index.node.js",
|
"module": "./dist/esm/index.node.js",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
"node": {
|
"node": {
|
||||||
"require": "./dist/cjs/index.node.cjs",
|
"require": {
|
||||||
"import": "./dist/esm/index.node.js",
|
"default": "./dist/cjs/index.node.cjs",
|
||||||
"module": "./dist/esm/index.node.js"
|
"types": "./types/index.d.cts"
|
||||||
|
},
|
||||||
|
"import": {
|
||||||
|
"default": "./dist/esm/index.node.js",
|
||||||
|
"types": "./types/index.d.ts"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"default": "./dist/esm/index.browser.js"
|
"default": {
|
||||||
|
"default": "./dist/esm/index.browser.js",
|
||||||
|
"types": "./types/index.d.ts"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"./esm-browser-bundle": "./dist/bundles/esm.min.js",
|
"./esm-browser-bundle": "./dist/bundles/esm.min.js",
|
||||||
|
"./esm-browser-bundle-nomin": "./dist/bundles/esm.js",
|
||||||
"./iife-browser-bundle": "./dist/bundles/iife.js",
|
"./iife-browser-bundle": "./dist/bundles/iife.js",
|
||||||
"./umd-browser-bundle": "./dist/bundles/umd.js",
|
"./umd-browser-bundle": "./dist/bundles/umd.js",
|
||||||
"./types": "./types/index.d.ts"
|
"./types": "./types/index.d.cts"
|
||||||
},
|
},
|
||||||
"imports": {
|
"imports": {
|
||||||
"#pkg": {
|
"#pkg": {
|
||||||
"import": "./dist/esm/index.node.js",
|
"require": {
|
||||||
"require": "./dist/cjs/index.node.cjs"
|
"default": "./dist/cjs/index.node.cjs",
|
||||||
|
"types": "./types/index.d.cts"
|
||||||
|
},
|
||||||
|
"import": {
|
||||||
|
"default": "./dist/esm/index.node.js",
|
||||||
|
"types": "./types/index.d.ts"
|
||||||
|
},
|
||||||
|
"default": {
|
||||||
|
"default": "./dist/esm/index.browser.js",
|
||||||
|
"types": "./types/index.d.ts"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"directories": {
|
"directories": {
|
||||||
|
@ -58,19 +77,21 @@
|
||||||
"mocha-ts": "./.mocha-ts"
|
"mocha-ts": "./.mocha-ts"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "run-s lint build:js docs",
|
"build": "run-s lint:src build:js lint:test docs",
|
||||||
"build:js": "rollup -c build/rollup.config.js",
|
"build:js": "rollup -c build/rollup.config.js",
|
||||||
"clean": "rimraf .mocha-ts coverage dist types docs",
|
"clean": "rimraf .mocha-ts coverage dist types docs",
|
||||||
"coverage": "c8 --check-coverage --exclude '{src/ts/**/*.spec.ts,test,test-vectors,build}' --exclude-after-remap --reporter=text --reporter=lcov node ./build/bin/mocha-ts.cjs --commonjs ",
|
"coverage": "c8 --clean --check-coverage --exclude \"{src/ts/**/*.spec.ts,test,test-vectors,build}\" --exclude-after-remap --reporter=text --reporter=lcov node ./build/bin/mocha-ts.cjs --commonjs ",
|
||||||
"docs": "node build/build.docs.cjs",
|
"docs": "node build/build.docs.cjs",
|
||||||
"git:add": "git add -A",
|
"git:add": "git add -A",
|
||||||
"lint": "ts-standard --fix",
|
"lint": "ts-standard --fix",
|
||||||
"mocha-ts": "node --experimental-modules --es-module-specifier-resolution=node ./build/bin/mocha-ts.cjs ",
|
"lint:src": "ts-standard --fix \"src/**/!(*.spec).ts\"",
|
||||||
|
"lint:test": "ts-standard --fix \"{test/**/*.ts,src/**/*.spec.ts}\"",
|
||||||
|
"mocha-ts": "node --experimental-modules --experimental-json-modules --es-module-specifier-resolution=node ./build/bin/mocha-ts.cjs ",
|
||||||
"mocha-ts:cjs": "node ./build/bin/mocha-ts.cjs --commonjs ",
|
"mocha-ts:cjs": "node ./build/bin/mocha-ts.cjs --commonjs ",
|
||||||
"mocha-ts:watch": "npm run mocha-ts:cjs -- --watch ",
|
"mocha-ts:watch": "npm run mocha-ts:cjs -- --watch ",
|
||||||
"mocha-ts:browser": "node build/testing/browser/index.cjs ",
|
"mocha-ts:browser": "node build/testing/browser/index.cjs ",
|
||||||
"mocha-ts:browser-headless": "node build/testing/browser/index.cjs headless ",
|
"mocha-ts:browser-headless": "node build/testing/browser/index.cjs headless ",
|
||||||
"preversion": "run-s clean lint build:js coverage test:browser-headless",
|
"preversion": "run-s clean lint:src build:js lint:test coverage test:browser-headless",
|
||||||
"version": "run-s docs git:add",
|
"version": "run-s docs git:add",
|
||||||
"postversion": "git push --follow-tags",
|
"postversion": "git push --follow-tags",
|
||||||
"test": "run-s test:node test:browser-headless",
|
"test": "run-s test:node test:browser-headless",
|
||||||
|
@ -82,6 +103,7 @@
|
||||||
"watch": "npm run mocha-ts:watch "
|
"watch": "npm run mocha-ts:watch "
|
||||||
},
|
},
|
||||||
"ts-standard": {
|
"ts-standard": {
|
||||||
|
"project": "tsconfig.json",
|
||||||
"env": [
|
"env": [
|
||||||
"mocha"
|
"mocha"
|
||||||
],
|
],
|
||||||
|
@ -91,40 +113,49 @@
|
||||||
"page",
|
"page",
|
||||||
"chai"
|
"chai"
|
||||||
],
|
],
|
||||||
"project": "tsconfig.json",
|
|
||||||
"ignore": [
|
"ignore": [
|
||||||
"dist/**/*",
|
"dist/**/*",
|
||||||
"examples/**/*",
|
"examples/**/*",
|
||||||
"types/**/*",
|
"types/**/*",
|
||||||
"build/testing/mocha/mocha-init.js"
|
"benchmark/**/*"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"nodeBrowserSkel": {
|
||||||
|
"badges": {
|
||||||
|
"workflow": true,
|
||||||
|
"coveralls": true
|
||||||
|
},
|
||||||
|
"git": {
|
||||||
|
"branch": "main"
|
||||||
|
}
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rollup/plugin-commonjs": "^22.0.0",
|
"@rollup/plugin-commonjs": "^24.0.1",
|
||||||
"@rollup/plugin-json": "^4.1.0",
|
"@rollup/plugin-inject": "^5.0.3",
|
||||||
"@rollup/plugin-multi-entry": "^4.0.0",
|
"@rollup/plugin-json": "^6.0.0",
|
||||||
"@rollup/plugin-node-resolve": "^14.1.0",
|
"@rollup/plugin-multi-entry": "^6.0.0",
|
||||||
"@rollup/plugin-replace": "^4.0.0",
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
||||||
"@rollup/plugin-typescript": "^8.2.0",
|
"@rollup/plugin-replace": "^5.0.1",
|
||||||
|
"@rollup/plugin-terser": "^0.4.0",
|
||||||
|
"@rollup/plugin-typescript": "^11.1.0",
|
||||||
"@types/chai": "^4.2.22",
|
"@types/chai": "^4.2.22",
|
||||||
"@types/mocha": "^10.0.0",
|
"@types/mocha": "^10.0.0",
|
||||||
"c8": "^7.12.0",
|
"c8": "^7.12.0",
|
||||||
"chai": "^4.3.3",
|
"chai": "^4.3.3",
|
||||||
"dotenv": "^16.0.3",
|
"dotenv": "^16.0.3",
|
||||||
"glob": "^8.0.1",
|
"glob": "^9.3.4",
|
||||||
"json5": "^2.2.0",
|
"json5": "^2.2.0",
|
||||||
"minimatch": "^5.0.1",
|
"minimatch": "^8.0.3",
|
||||||
"mocha": "^10.0.0",
|
"mocha": "^10.0.0",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"pirates": "^4.0.1",
|
"pirates": "^4.0.1",
|
||||||
"puppeteer": "^18.0.5",
|
"puppeteer": "^19.1.2",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^4.4.1",
|
||||||
"rollup": "^2.57.0",
|
"rollup": "^3.20.2",
|
||||||
"rollup-plugin-terser": "^7.0.2",
|
"ts-standard": "^12.0.2",
|
||||||
"ts-standard": "^11.0.0",
|
|
||||||
"tslib": "^2.3.1",
|
"tslib": "^2.3.1",
|
||||||
"typedoc": "^0.23.0",
|
"typedoc": "~0.23.0",
|
||||||
"typedoc-plugin-markdown": "^3.11.0",
|
"typedoc-plugin-markdown": "~3.14.0",
|
||||||
"typescript": "^4.4.3"
|
"typescript": "^5.0.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
*
|
*
|
||||||
* @returns The absolute value of a
|
* @returns The absolute value of a
|
||||||
*/
|
*/
|
||||||
export function abs (a: number|bigint): number|bigint {
|
export function abs (a: number | bigint): number | bigint {
|
||||||
return (a >= 0) ? a : -a
|
return (a >= 0) ? a : -a
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* @param a
|
* @param a
|
||||||
* @returns The bit length
|
* @returns The bit length
|
||||||
*/
|
*/
|
||||||
export function bitLength (a: number|bigint): number {
|
export function bitLength (a: number | bigint): number {
|
||||||
if (typeof a === 'number') a = BigInt(a)
|
if (typeof a === 'number') a = BigInt(a)
|
||||||
|
|
||||||
if (a === 1n) { return 1 }
|
if (a === 1n) { return 1 }
|
||||||
|
|
|
@ -14,7 +14,7 @@ export interface Egcd {
|
||||||
*
|
*
|
||||||
* @returns A triple (g, x, y), such that ax + by = g = gcd(a, b).
|
* @returns A triple (g, x, y), such that ax + by = g = gcd(a, b).
|
||||||
*/
|
*/
|
||||||
export function eGcd (a: number|bigint, b: number|bigint): Egcd {
|
export function eGcd (a: number | bigint, b: number | bigint): Egcd {
|
||||||
if (typeof a === 'number') a = BigInt(a)
|
if (typeof a === 'number') a = BigInt(a)
|
||||||
if (typeof b === 'number') b = BigInt(b)
|
if (typeof b === 'number') b = BigInt(b)
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ export function eGcd (a: number|bigint, b: number|bigint): Egcd {
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
g: b,
|
g: b,
|
||||||
x: x,
|
x,
|
||||||
y: y
|
y
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { abs } from './abs'
|
import { abs } from './abs.js'
|
||||||
/**
|
/**
|
||||||
* Greatest common divisor of two integers based on the iterative binary algorithm.
|
* Greatest common divisor of two integers based on the iterative binary algorithm.
|
||||||
*
|
*
|
||||||
|
@ -7,7 +7,7 @@ import { abs } from './abs'
|
||||||
*
|
*
|
||||||
* @returns The greatest common divisor of a and b
|
* @returns The greatest common divisor of a and b
|
||||||
*/
|
*/
|
||||||
export function gcd (a: number|bigint, b: number|bigint): bigint {
|
export function gcd (a: number | bigint, b: number | bigint): bigint {
|
||||||
let aAbs = (typeof a === 'number') ? BigInt(abs(a)) : abs(a) as bigint
|
let aAbs = (typeof a === 'number') ? BigInt(abs(a)) : abs(a) as bigint
|
||||||
let bAbs = (typeof b === 'number') ? BigInt(abs(b)) : abs(b) as bigint
|
let bAbs = (typeof b === 'number') ? BigInt(abs(b)) : abs(b) as bigint
|
||||||
|
|
||||||
|
|
|
@ -4,13 +4,13 @@
|
||||||
* @packageDocumentation
|
* @packageDocumentation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export { abs } from './abs'
|
export { abs } from './abs.js'
|
||||||
export { bitLength } from './bitLength'
|
export { bitLength } from './bitLength.js'
|
||||||
export { Egcd, eGcd } from './egcd'
|
export { Egcd, eGcd } from './egcd.js'
|
||||||
export { gcd } from './gcd'
|
export { gcd } from './gcd.js'
|
||||||
export { lcm } from './lcm'
|
export { lcm } from './lcm.js'
|
||||||
export { max } from './max'
|
export { max } from './max.js'
|
||||||
export { min } from './min'
|
export { min } from './min.js'
|
||||||
export { modInv } from './modInv'
|
export { modInv } from './modInv.js'
|
||||||
export { modPow } from './modPow'
|
export { modPow } from './modPow.js'
|
||||||
export { toZn } from './toZn'
|
export { toZn } from './toZn.js'
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { abs } from './abs'
|
import { abs } from './abs.js'
|
||||||
import { gcd } from './gcd'
|
import { gcd } from './gcd.js'
|
||||||
/**
|
/**
|
||||||
* The least common multiple computed as abs(a*b)/gcd(a,b)
|
* The least common multiple computed as abs(a*b)/gcd(a,b)
|
||||||
* @param a
|
* @param a
|
||||||
|
@ -7,7 +7,7 @@ import { gcd } from './gcd'
|
||||||
*
|
*
|
||||||
* @returns The least common multiple of a and b
|
* @returns The least common multiple of a and b
|
||||||
*/
|
*/
|
||||||
export function lcm (a: number|bigint, b: number|bigint): bigint {
|
export function lcm (a: number | bigint, b: number | bigint): bigint {
|
||||||
if (typeof a === 'number') a = BigInt(a)
|
if (typeof a === 'number') a = BigInt(a)
|
||||||
if (typeof b === 'number') b = BigInt(b)
|
if (typeof b === 'number') b = BigInt(b)
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,6 @@
|
||||||
*
|
*
|
||||||
* @returns Maximum of numbers a and b
|
* @returns Maximum of numbers a and b
|
||||||
*/
|
*/
|
||||||
export function max (a: number|bigint, b: number|bigint): number|bigint {
|
export function max (a: number | bigint, b: number | bigint): number | bigint {
|
||||||
return (a >= b) ? a : b
|
return (a >= b) ? a : b
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,6 @@
|
||||||
*
|
*
|
||||||
* @returns Minimum of numbers a and b
|
* @returns Minimum of numbers a and b
|
||||||
*/
|
*/
|
||||||
export function min (a: number|bigint, b: number|bigint): number|bigint {
|
export function min (a: number | bigint, b: number | bigint): number | bigint {
|
||||||
return (a >= b) ? b : a
|
return (a >= b) ? b : a
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { eGcd } from './egcd'
|
import { eGcd } from './egcd.js'
|
||||||
import { toZn } from './toZn'
|
import { toZn } from './toZn.js'
|
||||||
/**
|
/**
|
||||||
* Modular inverse.
|
* Modular inverse.
|
||||||
*
|
*
|
||||||
|
@ -10,7 +10,7 @@ import { toZn } from './toZn'
|
||||||
*
|
*
|
||||||
* @returns The inverse modulo n
|
* @returns The inverse modulo n
|
||||||
*/
|
*/
|
||||||
export function modInv (a: number|bigint, n: number|bigint): bigint {
|
export function modInv (a: number | bigint, n: number | bigint): bigint {
|
||||||
const egcd = eGcd(toZn(a, n), n)
|
const egcd = eGcd(toZn(a, n), n)
|
||||||
if (egcd.g !== 1n) {
|
if (egcd.g !== 1n) {
|
||||||
throw new RangeError(`${a.toString()} does not have inverse modulo ${n.toString()}`) // modular inverse does not exist
|
throw new RangeError(`${a.toString()} does not have inverse modulo ${n.toString()}`) // modular inverse does not exist
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { abs } from './abs'
|
import { abs } from './abs.js'
|
||||||
import { modInv } from './modInv'
|
import { modInv } from './modInv.js'
|
||||||
import { toZn } from './toZn'
|
import { toZn } from './toZn.js'
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
*
|
*
|
||||||
|
@ -12,7 +12,7 @@ import { toZn } from './toZn'
|
||||||
*
|
*
|
||||||
* @returns b**e mod n
|
* @returns b**e mod n
|
||||||
*/
|
*/
|
||||||
export function modPow (b: number|bigint, e: number|bigint, n: number|bigint): bigint {
|
export function modPow (b: number | bigint, e: number | bigint, n: number | bigint): bigint {
|
||||||
if (typeof b === 'number') b = BigInt(b)
|
if (typeof b === 'number') b = BigInt(b)
|
||||||
if (typeof e === 'number') e = BigInt(e)
|
if (typeof e === 'number') e = BigInt(e)
|
||||||
if (typeof n === 'number') n = BigInt(n)
|
if (typeof n === 'number') n = BigInt(n)
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
*
|
*
|
||||||
* @returns A bigint with the smallest positive representation of a modulo n
|
* @returns A bigint with the smallest positive representation of a modulo n
|
||||||
*/
|
*/
|
||||||
export function toZn (a: number|bigint, n: number|bigint): bigint {
|
export function toZn (a: number | bigint, n: number | bigint): bigint {
|
||||||
if (typeof a === 'number') a = BigInt(a)
|
if (typeof a === 'number') a = BigInt(a)
|
||||||
if (typeof n === 'number') n = BigInt(n)
|
if (typeof n === 'number') n = BigInt(n)
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"$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', 'ES2021', 'ES2023', 'ES2023' or 'ESNEXT'. */
|
||||||
"module": "ESNext",
|
"module": "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. */
|
||||||
|
@ -9,6 +9,7 @@
|
||||||
"checkJs": true, /* Report errors in .js files. */
|
"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. */
|
||||||
|
"removeComments": true,
|
||||||
|
|
||||||
/* Additional Checks */
|
/* Additional Checks */
|
||||||
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
||||||
|
@ -21,13 +22,14 @@
|
||||||
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
||||||
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
||||||
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
||||||
|
// "rootDir": ".",
|
||||||
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
||||||
"typeRoots": [ "node_modules/@types", "build/typings" ], /* List of folders to include type definitions from. */
|
"typeRoots": [ "node_modules/@types", "build/typings" ], /* List of folders to include type definitions from. */
|
||||||
// "types": [], /* Type declaration files to be included in compilation. */
|
// "types": [], /* Type declaration files to be included in compilation. */
|
||||||
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
||||||
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||||
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
||||||
"allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
||||||
|
|
||||||
/* Experimental Options */
|
/* Experimental Options */
|
||||||
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
||||||
|
@ -38,7 +40,7 @@
|
||||||
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
|
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"paths": {
|
"paths": {
|
||||||
"#pkg": ["."]
|
"#pkg": ["./src/ts/index.ts"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"include": ["src/ts/**/*", "build/typings/**/*.d.ts", "test/**/*", "test-vectors/**/*.ts", "benchmark/**/*.ts"]
|
"include": ["src/ts/**/*", "build/typings/**/*.d.ts", "test/**/*", "test-vectors/**/*.ts", "benchmark/**/*.ts"]
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
export declare function abs(a: number | bigint): number | bigint;
|
||||||
|
//# sourceMappingURL=abs.d.ts.map
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"abs.d.ts","sourceRoot":"","sources":["../src/ts/abs.ts"],"names":[],"mappings":"AAOA,wBAAgB,GAAG,CAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAExD"}
|
|
@ -1,9 +1,2 @@
|
||||||
/**
|
|
||||||
* Absolute value. abs(a)==a if a>=0. abs(a)==-a if a<0
|
|
||||||
*
|
|
||||||
* @param a
|
|
||||||
*
|
|
||||||
* @returns The absolute value of a
|
|
||||||
*/
|
|
||||||
export declare function abs(a: number | bigint): number | bigint;
|
export declare function abs(a: number | bigint): number | bigint;
|
||||||
//# sourceMappingURL=abs.d.ts.map
|
//# sourceMappingURL=abs.d.ts.map
|
|
@ -1 +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"}
|
{"version":3,"file":"abs.d.ts","sourceRoot":"","sources":["../src/ts/abs.ts"],"names":[],"mappings":"AAOA,wBAAgB,GAAG,CAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAExD"}
|
|
@ -0,0 +1,2 @@
|
||||||
|
export declare function bitLength(a: number | bigint): number;
|
||||||
|
//# sourceMappingURL=bitLength.d.ts.map
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"bitLength.d.ts","sourceRoot":"","sources":["../src/ts/bitLength.ts"],"names":[],"mappings":"AAMA,wBAAgB,SAAS,CAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CASrD"}
|
|
@ -1,8 +1,2 @@
|
||||||
/**
|
|
||||||
* Returns the (minimum) length of a number expressed in bits.
|
|
||||||
*
|
|
||||||
* @param a
|
|
||||||
* @returns The bit length
|
|
||||||
*/
|
|
||||||
export declare function bitLength(a: number | bigint): number;
|
export declare function bitLength(a: number | bigint): number;
|
||||||
//# sourceMappingURL=bitLength.d.ts.map
|
//# sourceMappingURL=bitLength.d.ts.map
|
|
@ -1 +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"}
|
{"version":3,"file":"bitLength.d.ts","sourceRoot":"","sources":["../src/ts/bitLength.ts"],"names":[],"mappings":"AAMA,wBAAgB,SAAS,CAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CASrD"}
|
|
@ -0,0 +1,7 @@
|
||||||
|
export interface Egcd {
|
||||||
|
g: bigint;
|
||||||
|
x: bigint;
|
||||||
|
y: bigint;
|
||||||
|
}
|
||||||
|
export declare function eGcd(a: number | bigint, b: number | bigint): Egcd;
|
||||||
|
//# sourceMappingURL=egcd.d.ts.map
|
|
@ -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;AAYD,wBAAgB,IAAI,CAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA4BlE"}
|
|
@ -3,16 +3,5 @@ export interface Egcd {
|
||||||
x: bigint;
|
x: bigint;
|
||||||
y: bigint;
|
y: bigint;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* 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).
|
|
||||||
*
|
|
||||||
* @param a
|
|
||||||
* @param b
|
|
||||||
*
|
|
||||||
* @throws {@link RangeError} if a or b are <= 0
|
|
||||||
*
|
|
||||||
* @returns A triple (g, x, y), such that ax + by = g = gcd(a, b).
|
|
||||||
*/
|
|
||||||
export declare function eGcd(a: number | bigint, b: number | bigint): Egcd;
|
export declare function eGcd(a: number | bigint, b: number | bigint): Egcd;
|
||||||
//# sourceMappingURL=egcd.d.ts.map
|
//# sourceMappingURL=egcd.d.ts.map
|
|
@ -1 +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;;;;;;;;;;GAUG;AACH,wBAAgB,IAAI,CAAE,CAAC,EAAE,MAAM,GAAC,MAAM,EAAE,CAAC,EAAE,MAAM,GAAC,MAAM,GAAG,IAAI,CA4B9D"}
|
{"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;AAYD,wBAAgB,IAAI,CAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA4BlE"}
|
|
@ -0,0 +1,2 @@
|
||||||
|
export declare function gcd(a: number | bigint, b: number | bigint): bigint;
|
||||||
|
//# sourceMappingURL=gcd.d.ts.map
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"gcd.d.ts","sourceRoot":"","sources":["../src/ts/gcd.ts"],"names":[],"mappings":"AASA,wBAAgB,GAAG,CAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CA6BnE"}
|
|
@ -1,10 +1,2 @@
|
||||||
/**
|
|
||||||
* Greatest common divisor of two integers based on the iterative binary algorithm.
|
|
||||||
*
|
|
||||||
* @param a
|
|
||||||
* @param b
|
|
||||||
*
|
|
||||||
* @returns The greatest common divisor of a and b
|
|
||||||
*/
|
|
||||||
export declare function gcd(a: number | bigint, b: number | bigint): bigint;
|
export declare function gcd(a: number | bigint, b: number | bigint): bigint;
|
||||||
//# sourceMappingURL=gcd.d.ts.map
|
//# sourceMappingURL=gcd.d.ts.map
|
|
@ -1 +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"}
|
{"version":3,"file":"gcd.d.ts","sourceRoot":"","sources":["../src/ts/gcd.ts"],"names":[],"mappings":"AASA,wBAAgB,GAAG,CAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CA6BnE"}
|
|
@ -0,0 +1,11 @@
|
||||||
|
export { abs } from './abs.js';
|
||||||
|
export { bitLength } from './bitLength.js';
|
||||||
|
export { Egcd, eGcd } from './egcd.js';
|
||||||
|
export { gcd } from './gcd.js';
|
||||||
|
export { lcm } from './lcm.js';
|
||||||
|
export { max } from './max.js';
|
||||||
|
export { min } from './min.js';
|
||||||
|
export { modInv } from './modInv.js';
|
||||||
|
export { modPow } from './modPow.js';
|
||||||
|
export { toZn } from './toZn.js';
|
||||||
|
//# sourceMappingURL=index.d.ts.map
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/ts/index.ts"],"names":[],"mappings":"AAMA,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,16 +1,11 @@
|
||||||
/**
|
export { abs } from './abs.js';
|
||||||
* Some common functions for modular arithmetic using native JS implementation of BigInt
|
export { bitLength } from './bitLength.js';
|
||||||
*
|
export { Egcd, eGcd } from './egcd.js';
|
||||||
* @packageDocumentation
|
export { gcd } from './gcd.js';
|
||||||
*/
|
export { lcm } from './lcm.js';
|
||||||
export { abs } from './abs';
|
export { max } from './max.js';
|
||||||
export { bitLength } from './bitLength';
|
export { min } from './min.js';
|
||||||
export { Egcd, eGcd } from './egcd';
|
export { modInv } from './modInv.js';
|
||||||
export { gcd } from './gcd';
|
export { modPow } from './modPow.js';
|
||||||
export { lcm } from './lcm';
|
export { toZn } from './toZn.js';
|
||||||
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
|
//# sourceMappingURL=index.d.ts.map
|
|
@ -1 +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"}
|
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/ts/index.ts"],"names":[],"mappings":"AAMA,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"}
|
|
@ -0,0 +1,2 @@
|
||||||
|
export declare function lcm(a: number | bigint, b: number | bigint): bigint;
|
||||||
|
//# sourceMappingURL=lcm.d.ts.map
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"lcm.d.ts","sourceRoot":"","sources":["../src/ts/lcm.ts"],"names":[],"mappings":"AASA,wBAAgB,GAAG,CAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAOnE"}
|
|
@ -1,9 +1,2 @@
|
||||||
/**
|
|
||||||
* The least common multiple computed as abs(a*b)/gcd(a,b)
|
|
||||||
* @param a
|
|
||||||
* @param b
|
|
||||||
*
|
|
||||||
* @returns The least common multiple of a and b
|
|
||||||
*/
|
|
||||||
export declare function lcm(a: number | bigint, b: number | bigint): bigint;
|
export declare function lcm(a: number | bigint, b: number | bigint): bigint;
|
||||||
//# sourceMappingURL=lcm.d.ts.map
|
//# sourceMappingURL=lcm.d.ts.map
|
|
@ -1 +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,CAO/D"}
|
{"version":3,"file":"lcm.d.ts","sourceRoot":"","sources":["../src/ts/lcm.ts"],"names":[],"mappings":"AASA,wBAAgB,GAAG,CAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAOnE"}
|
|
@ -0,0 +1,2 @@
|
||||||
|
export declare function max(a: number | bigint, b: number | bigint): number | bigint;
|
||||||
|
//# sourceMappingURL=max.d.ts.map
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"max.d.ts","sourceRoot":"","sources":["../src/ts/max.ts"],"names":[],"mappings":"AAQA,wBAAgB,GAAG,CAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAE5E"}
|
|
@ -1,10 +1,2 @@
|
||||||
/**
|
|
||||||
* Maximum. max(a,b)==a if a>=b. max(a,b)==b if a<b
|
|
||||||
*
|
|
||||||
* @param a
|
|
||||||
* @param b
|
|
||||||
*
|
|
||||||
* @returns Maximum of numbers a and b
|
|
||||||
*/
|
|
||||||
export declare function max(a: number | bigint, b: number | bigint): number | bigint;
|
export declare function max(a: number | bigint, b: number | bigint): number | bigint;
|
||||||
//# sourceMappingURL=max.d.ts.map
|
//# sourceMappingURL=max.d.ts.map
|
|
@ -1 +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"}
|
{"version":3,"file":"max.d.ts","sourceRoot":"","sources":["../src/ts/max.ts"],"names":[],"mappings":"AAQA,wBAAgB,GAAG,CAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAE5E"}
|
|
@ -0,0 +1,2 @@
|
||||||
|
export declare function min(a: number | bigint, b: number | bigint): number | bigint;
|
||||||
|
//# sourceMappingURL=min.d.ts.map
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"min.d.ts","sourceRoot":"","sources":["../src/ts/min.ts"],"names":[],"mappings":"AAQA,wBAAgB,GAAG,CAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAE5E"}
|
|
@ -1,10 +1,2 @@
|
||||||
/**
|
|
||||||
* Minimum. min(a,b)==b if a>=b. min(a,b)==a if a<b
|
|
||||||
*
|
|
||||||
* @param a
|
|
||||||
* @param b
|
|
||||||
*
|
|
||||||
* @returns Minimum of numbers a and b
|
|
||||||
*/
|
|
||||||
export declare function min(a: number | bigint, b: number | bigint): number | bigint;
|
export declare function min(a: number | bigint, b: number | bigint): number | bigint;
|
||||||
//# sourceMappingURL=min.d.ts.map
|
//# sourceMappingURL=min.d.ts.map
|
|
@ -1 +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"}
|
{"version":3,"file":"min.d.ts","sourceRoot":"","sources":["../src/ts/min.ts"],"names":[],"mappings":"AAQA,wBAAgB,GAAG,CAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAE5E"}
|
|
@ -0,0 +1,2 @@
|
||||||
|
export declare function modInv(a: number | bigint, n: number | bigint): bigint;
|
||||||
|
//# sourceMappingURL=modInv.d.ts.map
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"modInv.d.ts","sourceRoot":"","sources":["../src/ts/modInv.ts"],"names":[],"mappings":"AAYA,wBAAgB,MAAM,CAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAOtE"}
|
|
@ -1,12 +1,2 @@
|
||||||
/**
|
|
||||||
* Modular inverse.
|
|
||||||
*
|
|
||||||
* @param a The number to find an inverse for
|
|
||||||
* @param n The modulo
|
|
||||||
*
|
|
||||||
* @throws {@link RangeError} if a does not have inverse modulo n
|
|
||||||
*
|
|
||||||
* @returns The inverse modulo n
|
|
||||||
*/
|
|
||||||
export declare function modInv(a: number | bigint, n: number | bigint): bigint;
|
export declare function modInv(a: number | bigint, n: number | bigint): bigint;
|
||||||
//# sourceMappingURL=modInv.d.ts.map
|
//# sourceMappingURL=modInv.d.ts.map
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"modInv.d.ts","sourceRoot":"","sources":["../src/ts/modInv.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,wBAAgB,MAAM,CAAE,CAAC,EAAE,MAAM,GAAC,MAAM,EAAE,CAAC,EAAE,MAAM,GAAC,MAAM,GAAG,MAAM,CAOlE"}
|
{"version":3,"file":"modInv.d.ts","sourceRoot":"","sources":["../src/ts/modInv.ts"],"names":[],"mappings":"AAYA,wBAAgB,MAAM,CAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAOtE"}
|
|
@ -0,0 +1,2 @@
|
||||||
|
export declare function modPow(b: number | bigint, e: number | bigint, n: number | bigint): bigint;
|
||||||
|
//# sourceMappingURL=modPow.d.ts.map
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"modPow.d.ts","sourceRoot":"","sources":["../src/ts/modPow.ts"],"names":[],"mappings":"AAcA,wBAAgB,MAAM,CAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CA0B1F"}
|
|
@ -1,13 +1,2 @@
|
||||||
/**
|
|
||||||
* Modular exponentiation b**e mod n. Currently using the right-to-left binary method
|
|
||||||
*
|
|
||||||
* @param b base
|
|
||||||
* @param e exponent
|
|
||||||
* @param n modulo
|
|
||||||
*
|
|
||||||
* @throws {@link RangeError} if n <= 0
|
|
||||||
*
|
|
||||||
* @returns b**e mod n
|
|
||||||
*/
|
|
||||||
export declare function modPow(b: number | bigint, e: number | bigint, n: number | bigint): bigint;
|
export declare function modPow(b: number | bigint, e: number | bigint, n: number | bigint): bigint;
|
||||||
//# sourceMappingURL=modPow.d.ts.map
|
//# sourceMappingURL=modPow.d.ts.map
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"modPow.d.ts","sourceRoot":"","sources":["../src/ts/modPow.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAE,CAAC,EAAE,MAAM,GAAC,MAAM,EAAE,CAAC,EAAE,MAAM,GAAC,MAAM,EAAE,CAAC,EAAE,MAAM,GAAC,MAAM,GAAG,MAAM,CA0BpF"}
|
{"version":3,"file":"modPow.d.ts","sourceRoot":"","sources":["../src/ts/modPow.ts"],"names":[],"mappings":"AAcA,wBAAgB,MAAM,CAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CA0B1F"}
|
|
@ -0,0 +1,2 @@
|
||||||
|
export declare function toZn(a: number | bigint, n: number | bigint): bigint;
|
||||||
|
//# sourceMappingURL=toZn.d.ts.map
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"toZn.d.ts","sourceRoot":"","sources":["../src/ts/toZn.ts"],"names":[],"mappings":"AAaA,wBAAgB,IAAI,CAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAUpE"}
|
|
@ -1,15 +1,2 @@
|
||||||
/**
|
|
||||||
* Finds the smallest positive element that is congruent to a in modulo n
|
|
||||||
*
|
|
||||||
* @remarks
|
|
||||||
* a and b must be the same type, either number or bigint
|
|
||||||
*
|
|
||||||
* @param a - An integer
|
|
||||||
* @param n - The modulo
|
|
||||||
*
|
|
||||||
* @throws {@link RangeError} if n <= 0
|
|
||||||
*
|
|
||||||
* @returns A bigint with the smallest positive representation of a modulo n
|
|
||||||
*/
|
|
||||||
export declare function toZn(a: number | bigint, n: number | bigint): bigint;
|
export declare function toZn(a: number | bigint, n: number | bigint): bigint;
|
||||||
//# sourceMappingURL=toZn.d.ts.map
|
//# sourceMappingURL=toZn.d.ts.map
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"toZn.d.ts","sourceRoot":"","sources":["../src/ts/toZn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,IAAI,CAAE,CAAC,EAAE,MAAM,GAAC,MAAM,EAAE,CAAC,EAAE,MAAM,GAAC,MAAM,GAAG,MAAM,CAUhE"}
|
{"version":3,"file":"toZn.d.ts","sourceRoot":"","sources":["../src/ts/toZn.ts"],"names":[],"mappings":"AAaA,wBAAgB,IAAI,CAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAUpE"}
|
Loading…
Reference in New Issue