A Wrapper Around JSZip for Deno

Deno zip

A wrapper around JSZip for deno.

Usage:

Create zipfile:

import { JSZip } from "https://deno.land/x/jszip/mod.ts";

const zip = new JSZip();
zip.addFile("Hello.txt", "Hello World\n");

const img = zip.folder("images");
img.addFile("smile.gif", "\0", { base64: true });

await zip.writeZip("example.zip");

Read zipfile:

import { readZip } from "https://deno.land/x/jszip/mod.ts";

const zip = await readZip("example.zip");
for (const z of zip) {
  console.log(z.name);
}

console.log(await zip.file("Hello.txt").async("string"));
// "Hello World\n"

Download Details:

Author: hayd

Source Code: https://github.com/hayd/deno-zip

#deno #nodejs #node #javascript

What is GEEK

Buddha Community

A Wrapper Around JSZip for Deno

A Wrapper Around JSZip for Deno

Deno zip

A wrapper around JSZip for deno.

Usage:

Create zipfile:

import { JSZip } from "https://deno.land/x/jszip/mod.ts";

const zip = new JSZip();
zip.addFile("Hello.txt", "Hello World\n");

const img = zip.folder("images");
img.addFile("smile.gif", "\0", { base64: true });

await zip.writeZip("example.zip");

Read zipfile:

import { readZip } from "https://deno.land/x/jszip/mod.ts";

const zip = await readZip("example.zip");
for (const z of zip) {
  console.log(z.name);
}

console.log(await zip.file("Hello.txt").async("string"));
// "Hello World\n"

Download Details:

Author: hayd

Source Code: https://github.com/hayd/deno-zip

#deno #nodejs #node #javascript

Darren  Watsica

Darren Watsica

1597913858

Should You Learn Deno Js ? The Deno Js Intro By DESI PROGRAMMER

Hey youtube, This is Prince and welcome back to another exciting video and in this video we are going to explore a bit of Deno JS !

Comparison : 1:39
Installation : 3:39

#deno #deno js

Welde Tekle

Welde Tekle

1592957880

Deno Transforme -This package provides wrappers for Deno

Deno Transformer

nest badge

Based on Golang Transformer

Building Transformers

import * as Transform from "https://deno.land/x/transform/mod.ts";

const ATransformer: Transform.Transformer =  {
   reset() {
      // To reset internal state
      // it is called by: newReader
   },
   async transform(src: Uint8Array, dst: Deno.Writer, atEOF: boolean): Promise<number | null> {
       const transformed = new TextEncoder().encode("a".repeat(src.length));
       await Deno.writeAll(dst, transformed);
       return transformed.length;
   }
}

Built-in Transformers

Base64

Base64Decoder

import * as Transform from "https://deno.land/x/transform/mod.ts";
const { Base64Decoder } = Transform.Transformers;

const input = await Deno.open('./image.b64', { read: true });
const output = await Deno.open('./image.png', { create: true, write: true });
const reader = Transform.newReader(input, new Base64Decoder());
await Deno.copy(reader, output);
input.close();
output.close();

Base64Encoder

import * as Transform from "https://deno.land/x/transform/mod.ts";
const { Base64Encoder } = Transform.Transformers;

const input = await Deno.open('./image.png', { read: true });
const output = await Deno.open('./image.b64', { create: true, write: true });
const reader = Transform.newReader(input, new Base64Encoder);
await Deno.copy(reader, output);
input.close();
output.close();

Zlib

GzEncoder

import { Untar } from "https://deno.land/std/archive/tar.ts";
import * as Transform from "https://deno.land/x/transform/mod.ts";
const { GzEncoder } = Transform.Transformers;

const tar = new Tar();
const content = new TextEncoder().encode("Deno.land");
await tar.append("deno.txt", {
  reader:  new  Deno.Buffer(content),
  contentSize: content.byteLength,
});

const output = await Deno.open('file.tar.gz', { write: true, create: true });
await Transform.pipeline(tar.getReader(), new GzEncoder())
  .to(output);

output.close()

GzDecoder

import { tar } from "https://deno.land/std/archive/tar.ts";
import * as Transform from "https://deno.land/x/transform/mod.ts";
const { GzDecoder } = Transform.Transformers;

const input = await Deno.open('file.tar.gz', { read: true });
const untar = new Untar(
  Transform.newReader(input, new GzDecoder())
);

for await (const entry of untar) {
  console.log(entry);
}

API

newReader(r: Reader, t: Transformer): Reader

Returns a new Reader that wraps r by transforming the bytes read via t. It calls t.reset().

import * as Transform from "https://deno.land/x/transform/mod.ts";

/* ... */

const file = await Deno.open('file.txt'); // deno.land
const reader = Transform.newReader(
    file,
    ATransformer
);
assertEquals(
    new TextDecoder().decode(await Deno.readAll(reader)),
    'aaaaaaaaa'
);
file.close()

chain(...t: Transformer[]): Transformer

Returns a Transformer that applies t in sequence.

import * as Transform from "https://deno.land/x/transform/mod.ts";
const { Base64Decoder, Base64Encoder } = Transform.Transformers;

const expected = await Deno.readFile('./image.png');
const input = await Deno.open('./image.png', { read: true });

const transformer = Transform.chain(new Base64Encoder(), new Base64Decoder())
const reader = Transform.newReader(input, transformer);

assertEquals(expected,  await Deno.readAll(reader))
input.close();

pipeline(r: Reader, ...t: Transformer[]): Reader

A wrapper around Transformer.chain & Transformer.newReader

import * as Transform from "https://deno.land/x/transform/mod.ts";
const { Base64Decoder, Base64Encoder } = Transform.Transformers;

const expected = await Deno.readFile('./image.png');
const input = await Deno.open('./image.png', { read: true });
const output = await Deno.open('./image.b64', { read: true });

// const reader = await Transform.pipeline(input, new Base64Encoder())

await Transform.pipeline(input, new Base64Encoder())
  .to(writer)

output.close();
input.close()

Download Details:

Author: marcosc90

GitHub: https://github.com/marcosc90/transform

#deno #nodejs #node #javascript

Khaitan

Khaitan

1590306362

Deno | What is Deno? | Deno tamil

Learn what is Deno in tamil?

Deno is a runtime for JavaScript and TypeScript that is based on the V8 JavaScript engine and the Rust programming language. It was created by Ryan Dahl, original creator of Node.js, and is focused on productivity.

#deno #node #javascript #typescript #rust

Renato Silva

1597895940

How JavaScript Works for Deno js

Deno js Bootcamp 2020, Deno web development, Deno tutorials - with Real Projects

#javascript #deno tutorials #deno