Thank you for your interest in contributing to json-as! This document provides guidelines and instructions for contributing.
- Getting Started
- Development Setup
- Project Structure
- Making Changes
- Testing
- Code Style
- Pull Request Process
- Reporting Issues
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/YOUR_USERNAME/json-as.git cd json-as - Add the upstream remote:
git remote add upstream https://github.com/JairusSW/json-as.git
- Node.js 18+ or Bun
- Wasmtime (for running tests)
npm install
# or
bun installThe transform is written in TypeScript and needs to be compiled:
npm run build:transformRun the full test suite across all modes (NAIVE, SWAR, SIMD):
npm testRun a specific test file:
npm test string # Runs string.spec.tsAssemblyScript benchmarks:
npm run bench:asJavaScript comparison benchmarks:
npm run bench:jsjson-as/
├── .as-test/ # As-test configuration and runners
├── assembly/ # AssemblyScript runtime implementation
│ ├── index.ts # Main entry point (JSON namespace)
│ ├── serialize/ # Serialization implementations
│ │ ├── index/ # Indexer of all methods
│ │ ├── simple/ # Naive implementation
│ │ ├── swar/ # SWAR-optimized
│ │ └── simd/ # SIMD-optimized
│ ├── deserialize/ # Deserialization implementations
│ │ ├── index/ # Indexer of all methods
│ │ ├── simple/ # Naive implementation
│ │ ├── swar/ # SWAR-optimized
│ │ └── simd/ # SIMD-optimized
│ ├── util/ # Utility functions
│ ├── custom/ # Constants and character codes
│ └── __tests__/ # Test files
├── transform/ # TypeScript compiler transform
│ └── src/ # Transform source code
├── lib/ # Shared utilities (buffer system)
├── bench/ # Benchmark suite
└── .github/ # CI/CD workflows
-
Create a feature branch from
main:git checkout -b feature/your-feature-name
-
Make your changes with clear, atomic commits
-
Keep your branch up to date:
git fetch upstream git rebase upstream/main
Use clear, descriptive commit messages:
feat: add support for BigInt serializationfix: handle escaped unicode in stringsperf: optimize SIMD string escapingdocs: update README examplestest: add edge case tests for nested arrayschore: update dependencies
Tests are located in assembly/__tests__/. Each test file follows the pattern *.spec.ts.
Example test structure:
import { JSON } from "..";
describe("Feature Name", () => {
test("should serialize correctly", () => {
const result = JSON.stringify<string>("hello");
expect(result).toBe('"hello"');
});
test("should deserialize correctly", () => {
const result = JSON.parse<string>('"hello"');
expect(result).toBe("hello");
});
});Ensure your changes include tests for:
- Happy path scenarios
- Edge cases
- Error conditions
- All three modes (NAIVE, SWAR, SIMD) if applicable
The project uses Prettier for formatting:
npm run format- Use
@inlinedecorator for small, frequently-called functions - Prefer
store<T>andload<T>for direct memory operations - Use typed arrays and explicit types
- Add
// @ts-ignorecomments with explanations when necessary
- Use strict TypeScript settings
- Document complex logic with comments
- Keep functions focused and small
-
Before submitting:
- Run the full test suite:
npm test - Run the formatter:
npm run format - Ensure your branch is up to date with
main
- Run the full test suite:
-
PR Description:
- Clearly describe the changes
- Reference any related issues
- Include before/after benchmarks for performance changes
-
Review Process:
- PRs require at least one approval
- Address review feedback promptly
- Keep the PR focused on a single concern
-
After Merge:
- Delete your feature branch
- Update any related issues
Include:
- json-as version
- AssemblyScript version
- Minimal reproduction case
- Expected vs actual behavior
- Error messages (if any)
Include:
- Use case description
- Proposed API (if applicable)
- Alternatives considered
If your change affects performance:
- Run benchmarks before and after
- Include benchmark results in the PR
- Test across all three modes (NAIVE, SWAR, SIMD)
- Consider memory usage implications
- Open a GitHub Discussion for general questions
- Join the AssemblyScript Discord
- Email the maintainer at me@jairus.dev
By contributing, you agree that your contributions will be licensed under the MIT License.