![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
@votingworks/ballot-encoder
Advanced tools
Provides encoding and decoding services for completed ballots.
To use within VS Code:
yarn install
yarn pnpify --sdk
In dev ballot-encoder
dir, run yarn tsc
to generate JavaScript files.
In the PROJECT you wish to use this dev version of ballot-encoder
:
cd path/to/PROJECT/node_modules/@votingworks
rm -rf ballot-encoder
ln -s path/to/ballot-encoder ballot-encoder
npm version [major|minor|patch]
yarn prepare
(or yarn tsc
)yarn npm publish --access=public
Optionally, deprecate a previous version. For example:
npm deprecate -f '@votingworks/ballot-encoder@1.3.1' "Poor translations"
import {
decodeBallot,
electionSample as election,
encodeBallot,
getContests,
vote,
} from '@votingworks/ballot-encoder'
const ballotStyle = election.ballotStyles[0]
const precinct = election.precincts[0]
const ballotId = 'abcde'
const contests = getContests({ ballotStyle, election })
const votes = vote(contests, {
'judicial-robert-demergue': 'yes',
'judicial-elmer-hull': 'yes',
'question-a': 'yes',
'question-b': 'no',
'question-c': 'yes',
'proposition-1': 'yes',
'measure-101': 'no',
'102': 'yes',
})
const ballot = {
election,
ballotId,
ballotStyle,
precinct,
votes,
}
console.log(encodeBallot(ballot))
/*
Uint8Array [
86, 88, 1, 2, 49, 50, 2,
50, 51, 0, 15, 254, 208, 86,
22, 38, 54, 70, 80
]
*/
console.log(decodeBallot(election, encodeBallot(ballot)).ballot.votes)
/*
{
'102': 'yes',
'judicial-robert-demergue': 'yes',
'judicial-elmer-hull': 'yes',
'question-a': 'yes',
'question-b': 'no',
'question-c': 'yes',
'proposition-1': 'yes',
'measure-101': 'no'
}
*/
To encode a ballot, simply pass a completed ballot object to encodeBallot
.
You'll get back a buffer that may be stored or transmitted and later passed to
decodeBallot
with the same election
data that was part of the completed
ballot object.
There are multiple encoder versions and by default the latest will be used when
encoding. To specify the version, pass the EncoderVersion
as the second
parameter to encodeBallot
:
import { encodeBallot, EncoderVersion } from '@votingworks/ballot-encoder'
const encodedBallot = encodeBallot(ballot, EncoderVersion.v1)
When decoding, you may pass an EncoderVersion
or you may allow decodeBallot
to detect the encoder version:
import { decodeBallot, EncoderVersion } from '@votingworks/ballot-encoder'
// automatically detect version
const result = decodeBallot(election, encodedBallot)
console.log('Ballot version:', result.version)
console.log('Ballot:', result.ballot)
// specify version
const result = decodeBallot(election, encodedBallot, EncoderVersion.v0)
console.log('Ballot version:', result.version)
console.log('Ballot:', result.ballot)
If you only want to detect the version, you can simply use detect
:
import { detect } from '@votingworks/ballot-encoder'
const version = detect(encodedBallot)
console.log('Ballot version:', version)
This project uses the Angular Commit Message Format convention. How to publish a new version:
BUMP
.npm version $BUMP
.yarn publish:npm
.git push -u origin HEAD && git push --tags
.FAQs
Provides encoding and decoding services for completed ballots.
The npm package @votingworks/ballot-encoder receives a total of 6 weekly downloads. As such, @votingworks/ballot-encoder popularity was classified as not popular.
We found that @votingworks/ballot-encoder demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.