Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = ["the Andromeda team"]
edition = "2024"
license = "Mozilla Public License 2.0"
repository = "https://github.com/tryandromeda/andromeda"
version = "0.1.0-draft7"
version = "0.1.0-draft8"

[workspace.dependencies]
andromeda-core = { path = "core" }
Expand Down
6 changes: 3 additions & 3 deletions examples/blob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const sliced = blob.slice(0, 5);
console.log(" Sliced size:", sliced.size);

const file = new File(["File content here"], "document.txt", {
type: "text/plain",
lastModified: Date.now() - 10000,
type: "text/plain",
lastModified: Date.now() - 10000,
});
console.log(" File name:", file.name);
console.log(" File size:", file.size);
Expand All @@ -28,5 +28,5 @@ console.log(" FormData has blob:", formData.has("blob"));

console.log(" FormData keys:");
for (const key of formData.keys()) {
console.log(" -", key);
console.log(" -", key);
}
2 changes: 1 addition & 1 deletion examples/lint_empty_statement.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
let a = 1;;
let a = 1;
16 changes: 8 additions & 8 deletions examples/modules/config.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "test-package",
"version": "1.0.0",
"description": "A test JSON module",
"features": ["json-import", "module-loading"],
"config": {
"debug": true,
"timeout": 5000
}
"name": "test-package",
"version": "1.0.0",
"description": "A test JSON module",
"features": ["json-import", "module-loading"],
"config": {
"debug": true,
"timeout": 5000
}
}
2 changes: 1 addition & 1 deletion examples/modules/default-export.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default function greet(name) {
return `Hello, ${name}!`;
return `Hello, ${name}!`;
}

export const version = "1.0.0";
5 changes: 2 additions & 3 deletions examples/modules/greeting.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

export default function greet(name: string): string {
return `Hello, ${name}!`;
return `Hello, ${name}!`;
}

export function farewell(name: string): string {
return `Goodbye, ${name}!`;
return `Goodbye, ${name}!`;
}
7 changes: 3 additions & 4 deletions examples/modules/math.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@

export function add(a, b) {
return a + b;
return a + b;
}

export function multiply(a, b) {
return a * b;
return a * b;
}

export const PI = 3.14159;

export default function square(x) {
return x * x;
return x * x;
}
30 changes: 15 additions & 15 deletions examples/modules/mixed-exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@ export const API_URL = "https://api.example.com";
export const MAX_RETRIES = 3;

export function fetchData(endpoint: string): string {
return `Fetching from ${API_URL}/${endpoint}`;
return `Fetching from ${API_URL}/${endpoint}`;
}

export class DataProcessor {
name: string;
constructor(name: string) {
this.name = name;
}
process(data: string): string {
return `${this.name} processed: ${data}`;
}
name: string;

constructor(name: string) {
this.name = name;
}

process(data: string): string {
return `${this.name} processed: ${data}`;
}
}

// Default export
export default {
name: "MixedExportsModule",
version: "2.0.0",
init() {
return "Module initialized";
}
name: "MixedExportsModule",
version: "2.0.0",
init() {
return "Module initialized";
},
};
54 changes: 27 additions & 27 deletions examples/modules/sequential-test.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
// Simple sequential test to avoid module loading conflicts
console.log('🚀 Testing ES6 modules sequentially...\n');
console.log("🚀 Testing ES6 modules sequentially...\n");

async function runTests() {
try {
// Test 1: Basic math module
console.log('📦 Test 1: Math module');
const mathModule = await import('./math.js');
console.log(' ✅ math.add(2, 3) =', mathModule.add(2, 3));
console.log(' ✅ math.PI =', mathModule.PI);
console.log(' ✅ Default export square(4) =', mathModule.default(4));
try {
// Test 1: Basic math module
console.log("📦 Test 1: Math module");
const mathModule = await import("./math.js");
console.log(" ✅ math.add(2, 3) =", mathModule.add(2, 3));
console.log(" ✅ math.PI =", mathModule.PI);
console.log(" ✅ Default export square(4) =", mathModule.default(4));

// Test 2: Default export module
console.log('\n🎯 Test 2: Default export');
const defaultModule = await import('./default-export.js');
console.log(' ✅ Default greeting:', defaultModule.default('Andromeda'));
console.log(' ✅ Version:', defaultModule.version);
// Test 2: Default export module
console.log("\n🎯 Test 2: Default export");
const defaultModule = await import("./default-export.js");
console.log(" ✅ Default greeting:", defaultModule.default("Andromeda"));
console.log(" ✅ Version:", defaultModule.version);

// Test 3: TypeScript module
console.log('\n🔀 Test 3: TypeScript module');
const tsModule = await import('./mixed-exports.ts');
console.log(' ✅ API_URL:', tsModule.API_URL);
console.log(' ✅ fetchData:', tsModule.fetchData('users'));
// Test 3: TypeScript module
console.log("\n🔀 Test 3: TypeScript module");
const tsModule = await import("./mixed-exports.ts");
console.log(" ✅ API_URL:", tsModule.API_URL);
console.log(" ✅ fetchData:", tsModule.fetchData("users"));

// Test 4: JSON module
console.log('\n📄 Test 4: JSON module');
const jsonModule = await import('./config.json');
console.log(' ✅ Package name:', jsonModule.default.name);
console.log(' ✅ Features:', jsonModule.default.features);
// Test 4: JSON module
console.log("\n📄 Test 4: JSON module");
const jsonModule = await import("./config.json");
console.log(" ✅ Package name:", jsonModule.default.name);
console.log(" ✅ Features:", jsonModule.default.features);

console.log('\n🎉 All tests completed successfully!');
} catch (error) {
console.error('❌ Test failed:', error.message);
}
console.log("\n🎉 All tests completed successfully!");
} catch (error) {
console.error("❌ Test failed:", error.message);
}
}

// Use async/await pattern instead of multiple concurrent imports
Expand Down
62 changes: 62 additions & 0 deletions examples/streams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
const stream1 = new ReadableStream({
start(controller) {
console.log(" ReadableStream started");
controller.enqueue("Hello");
controller.enqueue(" ");
controller.enqueue("World!");
controller.close();
console.log(" ReadableStream data enqueued and closed");
},
});

const _reader = stream1.getReader();

const chunks: string[] = [];
const stream2 = new WritableStream({
start(_controller) {
console.log(" WritableStream started");
},
write(chunk, _controller) {
console.log(" WritableStream received chunk:", chunk);
if (typeof chunk === "string") {
chunks.push(chunk);
} else if (chunk instanceof Uint8Array) {
const text = new TextDecoder().decode(chunk);
chunks.push(text);
}
},
close() {
console.log(" WritableStream closed");
},
});

const _writer = stream2.getWriter();

const strategy1 = new CountQueuingStrategy({ highWaterMark: 5 });
console.log(" Strategy highWaterMark:", strategy1.highWaterMark);
console.log(" Size of 'test':", strategy1.size("test"));
console.log(" Size of [1,2,3]:", strategy1.size([1, 2, 3]));

const strategy2 = new ByteLengthQueuingStrategy({ highWaterMark: 1024 });
console.log(" Strategy highWaterMark:", strategy2.highWaterMark);

const testBuffer = new Uint8Array([1, 2, 3, 4, 5]);
console.log(" Size of Uint8Array(5):", strategy2.size(testBuffer));

const upperCaseTransform = new TransformStream({
transform(chunk, controller) {
console.log(" Transform received chunk:", chunk);
if (typeof chunk === "string") {
controller.enqueue(chunk.toUpperCase());
} else if (chunk instanceof Uint8Array) {
const text = new TextDecoder().decode(chunk);
const upperText = text.toUpperCase();
const encoder = new TextEncoder();
controller.enqueue(encoder.encode(upperText));
}
},
});

console.log(" TransformStream created successfully");
console.log(" Readable side:", upperCaseTransform.readable);
console.log(" Writable side:", upperCaseTransform.writable);
Loading
Loading