Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 26, 2025

This PR addresses the need to update all codec README.md files with basic usage instructions and consistent import paths using @jsonjoy.com/json-pack/lib/<codec> format.

Changes Made

🔧 Fixed Import Paths

Updated all codec README files to use the correct import path format:

// Before (inconsistent)
import {CborEncoder} from 'json-joy/es2020/json-pack/cbor/CborEncoder';
import {JsonEncoder} from 'json-pack/lib/json';

// After (consistent)
import {CborEncoder, CborDecoder} from '@jsonjoy.com/json-pack/lib/cbor';
import {JsonEncoder, JsonDecoder} from '@jsonjoy.com/json-pack/lib/json';

➕ Added Missing Usage Examples

Several codec READMEs were missing basic usage examples:

  • Bencode: Added complete usage example with encoder/decoder
  • UBJSON: Added basic usage section (previously only had benchmarks)
  • Enhanced examples for other codecs with consistent structure

🔨 Fixed MessagePack Exports

  • Added missing MsgPackDecoder export in src/msgpack/index.ts
  • Added user-friendly aliases: MessagePackEncoder and MessagePackDecoder
  • This fixes the main README example that was using non-existent exports

📚 Improved Documentation Structure

All codec READMEs now follow a consistent structure:

  • Clear description and features
  • Basic usage with working code examples
  • Advanced usage patterns where applicable
  • Proper handling of complex constructors

⚠️ Addressed Constructor Complexity

Some codecs (JSON, BSON, Bencode, UBJSON) require Writer instances from @jsonjoy.com/util. The updated READMEs:

  • Show proper usage with required dependencies
  • Include installation instructions for peer dependencies
  • Suggest simpler alternatives (MessagePack, CBOR) for easier usage

Example Usage

All examples are now verified to work with the built library:

// Simple codecs - easy to use
import {MessagePackEncoder, MessagePackDecoder} from '@jsonjoy.com/json-pack/lib/msgpack';

const encoder = new MessagePackEncoder();
const decoder = new MessagePackDecoder();
const data = {hello: 'world'};
const encoded = encoder.encode(data);
const decoded = decoder.decode(encoded);

// Complex codecs - require Writer dependency
import {JsonEncoder, JsonDecoder} from '@jsonjoy.com/json-pack/lib/json';
import {Writer} from '@jsonjoy.com/util/lib/buffers/Writer';

const writer = new Writer();
const encoder = new JsonEncoder(writer);
const decoder = new JsonDecoder();
// ... usage

This ensures developers have accurate, working examples for all codecs with proper import paths and realistic usage patterns.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] Update all README.md files. Add basic usage instructions for each codec. Use @jsonjou.com/json-pack/lib/<codec> as import path in examples. Update all README.md files with consistent import paths and working usage examples Jul 26, 2025
Copilot AI requested a review from streamich July 26, 2025 12:07
@streamich streamich marked this pull request as ready for review July 26, 2025 13:22
Copy link
Collaborator

@streamich streamich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert changes to NPM dependency locks.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Removed package-lock.json file in commit 0d85ee1.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert changes to this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Reverted yarn.lock to original state in commit 0d85ee1.

Copilot AI requested a review from streamich July 26, 2025 13:29
Copy link
Collaborator

@streamich streamich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@streamich streamich merged commit 1cdf9b5 into master Jul 27, 2025
@streamich streamich deleted the copilot/fix-7672cc65-eadf-413e-ac7d-292148e768af branch July 27, 2025 08:45
@github-actions
Copy link

github-actions bot commented Aug 1, 2025

🎉 This PR is included in version 1.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants