4.1.0 • Published 5 months ago
@transcend-io/conflux v4.1.0
Blazing Fast
- ~100 kB import
- Uses streams, minimizing memory overhead
Compatibility
Chrome | ✅ |
Safari | ✅ |
Edge | ✅ |
Firefox | ✅ |
Examples
Usage
Importing Conflux
Package Manager
# With Yarn
yarn add @transcend-io/conflux
# With NPM
npm install --save @transcend-io/conflux
import { Reader, Writer } from '@transcend-io/conflux';
CDN
<script src="https://cdn.jsdelivr.net/npm/@transcend-io/conflux@3"></script>
const { Reader, Writer } = window.conflux;
Writing a ZIP
import { Writer } from '@transcend-io/conflux';
import streamSaver from "streamsaver";
// Set up conflux
const { readable, writable } = new Writer();
const writer = writable.getWriter();
// Set up streamsaver
const fileStream = streamSaver.createWriteStream("conflux.zip");
// Add a file
writer.write({
name: "/cat.txt",
lastModified: new Date(0),
stream: () => new Response("mjau").body
});
readable.pipeTo(fileStream);
writer.close();
Incorporating other streams
import { Writer } from '@transcend-io/conflux';
const { readable, writable } = new Writer();
const writer = writable.getWriter();
const reader = readable.getReader();
(async () => {
writer.write({
name: "/cat.txt",
lastModified: new Date(0),
stream: () => new Response("mjau").body
});
const imgStream = await fetch(
"https://s3-us-west-2.amazonaws.com/bencmbrook/Earth.jpg"
).then(r => r.body);
writer.write({
name: "/Earth.jpg",
lastModified: new Date(0),
stream: () => imgStream
});
readable.pipeTo(fileStream);
writer.close();
})();
Reading ZIP files
import { Reader } from '@transcend-io/conflux';
fetch("https://cdn.jsdelivr.net/gh/Stuk/jszip/test/ref/deflate.zip").then(
async res => {
const zip = await res.blob();
for await (const entry of Reader(zip)) {
console.log(entry);
}
}
);
License
4.1.0
5 months ago
4.0.3
1 year ago
3.2.3
2 years ago
4.0.1
2 years ago
4.0.0
2 years ago
4.0.2
2 years ago
3.2.2
2 years ago
3.2.1
2 years ago
3.2.0
4 years ago
3.1.0
4 years ago
3.0.6
4 years ago
3.0.4
4 years ago
3.0.3
4 years ago
3.0.5
4 years ago
3.0.2
4 years ago
3.0.1
4 years ago
3.0.0
4 years ago
3.0.0-alpha.4
4 years ago
3.0.0-alpha.3
4 years ago
3.0.0-alpha.1
4 years ago
3.0.0-alpha.2
4 years ago
2.0.2
4 years ago
2.0.1
4 years ago
2.0.0
4 years ago
1.1.1
4 years ago
1.1.0
4 years ago
1.1.2
4 years ago
1.0.0
4 years ago
0.0.1
5 years ago
0.0.0
5 years ago