Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gmp-wasm

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gmp-wasm - npm Package Compare versions

Comparing version 0.9.1 to 0.9.2

dist/mini.esm.js

3

CHANGELOG.md

@@ -0,1 +1,4 @@

## 0.9.2 (Dec 5, 2021)
* Add mini build without Float / MPFR functions
## 0.9.1 (Dec 4, 2021)

@@ -2,0 +5,0 @@ * Accept string parameter for common operations in the high level wrapper

@@ -9,2 +9,5 @@ module.exports = {

cacheDirectory: '<rootDir>/.jest-cache',
moduleNameMapper: {
"gmpwasmts": "<rootDir>/gmp.wasm.ts",
},
};

5

package.json
{
"name": "gmp-wasm",
"version": "0.9.1",
"version": "0.9.2",
"description": "Arbitrary-precision Integer, Rational and Float types based on the GMP and MPFR libraries",

@@ -15,3 +15,3 @@ "main": "dist/index.umd.js",

"build-rollup": "rollup -c",
"build-types": "tsc ./src/index -t es5 --outDir ./dist/types --downlevelIteration --declaration --emitDeclarationOnly --allowSyntheticDefaultImports",
"build-types": "tsc --project types.tsconfig.json",
"build": "npm run build-bindings && npm run build-rollup && npm run build-types",

@@ -58,2 +58,3 @@ "test": "jest --coverage",

"devDependencies": {
"@rollup/plugin-alias": "^3.1.8",
"@rollup/plugin-commonjs": "^21.0.1",

@@ -60,0 +61,0 @@ "@rollup/plugin-json": "^4.1.0",

# GMP-WASM
[![npm package](https://img.shields.io/npm/v/gmp-wasm.svg)](http://npmjs.org/package/gmp-wasm)
[![Bundle size](https://badgen.net/bundlephobia/minzip/gmp-wasm)](https://bundlephobia.com/result?p=gmp-wasm)
[![codecov](https://codecov.io/gh/Daninet/gmp-wasm/branch/master/graph/badge.svg)](https://codecov.io/gh/Daninet/gmp-wasm)

@@ -20,3 +19,4 @@ [![Build status](https://github.com/Daninet/gmp-wasm/workflows/Build/badge.svg?branch=master)](https://github.com/Daninet/gmp-wasm/actions)

- Zero dependencies
- Minified and gzipped bundle has a size of [![Bundle size](https://badgen.net/bundlephobia/minzip/gmp-wasm)](https://bundlephobia.com/result?p=gmp-wasm)
- Full minified and gzipped bundle has a size of ![Bundle size](https://img.badgesize.io/Daninet/gmp-wasm/binaries/index.umd.min.js?compression=gzip&label=minzipped%20size)
- It also packages a mini bundle without Float/MPFR operations ![Bundle size](https://img.badgesize.io/Daninet/gmp-wasm/binaries/mini.umd.min.js?compression=gzip&label=minzipped%20size)
- 100% open source & [transparent build process](https://github.com/Daninet/gmp-wasm/actions)

@@ -33,7 +33,10 @@

```html
<!-- loads the minified library into the global `gmp` variable -->
<!-- loads the full, minified library into the global `gmp` variable -->
<script src="https://cdn.jsdelivr.net/npm/gmp-wasm"></script>
<!-- or the non-minified library -->
<!-- or loads the non-minified library -->
<script src="https://cdn.jsdelivr.net/npm/gmp-wasm/dist/index.umd.js"></script>
<!-- or loads the minified library without Float/MPFR functions -->
<script src="https://cdn.jsdelivr.net/npm/gmp-wasm/dist/mini.umd.min.js"></script>
```

@@ -40,0 +43,0 @@

import typescript from '@rollup/plugin-typescript';
import json from '@rollup/plugin-json';
import alias from '@rollup/plugin-alias';
import { nodeResolve } from '@rollup/plugin-node-resolve';

@@ -7,2 +8,3 @@ import { terser } from 'rollup-plugin-terser';

import commonjs from '@rollup/plugin-commonjs';
import packageJson from './package.json';

@@ -18,3 +20,3 @@ const TERSER_CONFIG = {

commentStyle: 'ignored',
content: `gmp-wasm (https://www.npmjs.com/package/gmp-wasm)
content: `gmp-wasm v${packageJson.version} (https://www.npmjs.com/package/gmp-wasm)
(c) Dani Biro

@@ -25,7 +27,7 @@ @license LGPL-3.0`,

const getBundleConfig = (minified = false) => ({
const getBundleConfig = (miniLib = false, minified = false) => ({
input: 'src/index.ts',
output: [
{
file: `dist/index.umd${minified ? '.min' : ''}.js`,
file: `dist/${miniLib ? 'mini' : 'index'}.umd${minified ? '.min' : ''}.js`,
name: 'gmp',

@@ -35,3 +37,3 @@ format: 'umd',

{
file: `dist/index.esm${minified ? '.min' : ''}.js`,
file: `dist/${miniLib ? 'mini' : 'index'}.esm${minified ? '.min' : ''}.js`,
format: 'es',

@@ -41,2 +43,7 @@ },

plugins: [
alias({
entries: [
{ find: 'gmpwasmts', replacement: `../${miniLib ? 'gmpmini' : 'gmp'}.wasm.ts` }
]
}),
nodeResolve(),

@@ -51,2 +58,7 @@ commonjs(),

export default [getBundleConfig(false), getBundleConfig(true)];
export default [
getBundleConfig(false, false),
getBundleConfig(false, true),
getBundleConfig(true, false),
getBundleConfig(true, true)
];
const fs = require('fs');
const fflate = require('fflate');
const data = fs.readFileSync('./binding/dist/gmp.wasm');
console.time('compress');
const dataCompressed = fflate.deflateSync(data, { level: 9, mem: 4 });
const base64 = Buffer.from(dataCompressed).toString('base64');
console.timeEnd('compress');
const src = `export const gmpWasmLength = ${data.length}; export const gmpWasm = '${base64}';`;
fs.writeFileSync('./gmp.wasm.ts', src);
const compress = (filename) => {
const data = fs.readFileSync(`./binding/dist/${filename}`);
console.time('compress');
const dataCompressed = fflate.deflateSync(data, { level: 9, mem: 4 });
const base64 = Buffer.from(dataCompressed).toString('base64');
console.timeEnd('compress');
const src = `export const gmpWasmLength = ${data.length}; export const gmpWasm = '${base64}';`;
fs.writeFileSync(`./${filename}.ts`, src);
};
compress('gmp.wasm');
compress('gmpmini.wasm');
import { inflateSync } from 'fflate';
import { decodeBase64 } from './base64';
import { gmpWasmLength, gmpWasm } from '../gmp.wasm';
import { gmpWasmLength, gmpWasm } from 'gmpwasmts';

@@ -5,0 +5,0 @@ let instance: any = null;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc