Git Product home page Git Product logo

torrefy's Issues

migrate to vite/vitest

Vite uses esbuild to prebundle dependencies and transform source codes in dev mode, which makes it a perfect selection to test the package in browser env without losing typescript features. And Vite is fast.

refactor web streams to async iterator/generators

Some related links

Basically, there're two functions that need implementing:

Other works left including refactoring transformers to async generators are already done in another branch of this repo. But they still need testing as I also refactored many other places.

ReadableStream instead of FileDirLike?

For large files, buffering the entire thing into an ArrayBuffer or Blob for new File(...) isn't always doable. Would it be possible to have create([my_ReadableStream]) to avoid needing to buffer everything at once?

Weird broken results with Cloudflare Workers

Trying to get this module to work with a Cloudflare Worker, but I seem to always get a weird truncated response. Any ideas on what I'm doing wrong?

interface Env {
}

import { create, encode } from "torrefy";

export default {
	async fetch(
		request: Request,
		env: Env,
		ctx: ExecutionContext
	): Promise<Response> {
		const testFile = new File(
			["Hello world. This is the test file content."],
			"testfile.txt"
		);

		// calculate (hash) the meta info of the test file
		const metaInfo = await create([testFile]);
		console.debug(metaInfo);

		// bencode meta info into a readable stream
		const torrentStream = encode(metaInfo);

		return new Response(torrentStream);
	},
};

I end up getting the following data returned:

00000000: 6431 303a 6372 6561 7465 6420 6279 3133  d10:created by13
00000010: 3a63 7265 6174 696f 6e20 6461 7465 343a  :creation date4:
00000020: 696e 666f 65                             infoe

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.