npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@cryptosat/private-voting

v1.0.0

Published

This library implements an API for running privacy-preserving ballots. The library can be compiled to WASM, making it suitable for use within a browser application (for Cryptosim), as well as part of the flight software.

Downloads

4

Readme

Private Voting

This library implements an API for running privacy-preserving ballots. The library can be compiled to WASM, making it suitable for use within a browser application (for Cryptosim), as well as part of the flight software.

Installing prerequisites

Prerequisites include

  • cargo
  • wasm-pack

cargo can be installed using rustup. Follow the installation instructions on https://www.rust-lang.org/tools/install.

Once cargo is installed, wasm-pack can be installed by running

$ cargo install wasm-pack

Building and testing

To run the unit tests, execute

$ cargo test

To build the WASM target and its JS bindings, run

$ wasm-pack build --target web

The WASM target and JS bindings will then be placed in a pkg directory.

To test the library, use html/test.html, serving it using a local webserver (rather than opening the file directly which won't work due to CORS policies). You can run a simple Python HTTP server using:

$ python3 -m http.server 8000

and then access https://localhost:8000/html/test.html in your browser.

Testing in a browser

To run unit tests in a browser, execute

$ wasm-pack test --chrome

To test calling the compiled WASM from Javascript code, there is a simple HTML under the html directory, named test.html. It has to be served over HTTP and not just opened directly as a file in the browser, since otherwise, CORS policies will block importing the Javascript file with the WASM bindings.

Generating documentation

To build the documentation for the private_voting library, execute

 $ cargo doc
 

which outputs the documentation in HTML format under target/doc.

Build Instructions

To build this package, you will need to have wasm-pack installed on your machine.

Run the following command to build the package for both browser and Node.js environments:

npm run build This command will execute the following scripts:

build:browser: Builds the package for browser environment using wasm-pack with the web target and outputs to ./build/browser directory. It then removes the package.json file in the ./build/browser directory using rimraf.

build:node: Builds the package for Node.js environment using wasm-pack with the nodejs target and outputs to ./build/node directory. It then removes the package.json file in the ./build/node directory using rimraf.

Package Structure

The package includes the following files and directories:

build: The build output directory containing the compiled WASM modules for both browser and Node.js environments. types: The TypeScript type definitions for the package. exports: The package exports, including the browser and Node.js modules and the corresponding WASM binary files.

Dependencies

This package has the following development dependency:

rimraf: A utility to remove files and directories. It is used to remove the package.json files generated by wasm-pack in the build output directories.

Usage

After building the package, you can import and use it in your projects. The package supports both browser and Node.js environments. Below is an example of how to import and use the package:

import * as privateVoting from 'private_voting';

// Use the privateVoting module functions here...

Publishing to npm

To publish the private_voting package on npm, follow these steps:

Make sure you have an npm account and you're logged in to your account using the npm CLI.

Ensure the package.json file is updated with the correct version number and other necessary information.

In the terminal or command prompt, navigate to the root directory of your package (where the package.json file is located).

Run the following command to publish the package:

npm publish

This command will package and publish your module to the npm registry.