Catalog npm
PACKAGE EXPLORERView in registry

@01/as-lzma

npm

LZMA Decoder written in AssemblyScript

assemblyscriptcompressiondatajavascriptlzmawebassembly
Versions collected4
Direct dependencies1From release 1.0.2
Last observed20 Oct, 21:55 UTC

README

Current package documentation

LZMA Decoder (AssemblyScript)

This is an experimental lzma decoder written in AssemblyScript

Example

example code

var memory = new WebAssembly.Memory({ initial: 160 })
...
// You know how to instantiate WASM module
var lzma = module.instance.exports

// Get compressed data by fetch or by some other means
var inputData = new Uint8Array(await (await fetch('PATH/TO/COMPRESSED_FILE.lzma')).arrayBuffer())

// Allocate memory to copy input data. 
const inputDataPtr = lzma.newU8Array(inputData.length)

// AssemblyScript ArrayBuffer header length
const AS_ARRAY_OFFSET = 24

// Create an Uint8Array using allocated buffer and set input data
const u8Array = new Uint8Array(
  memory.buffer,
  inputDataPtr + AS_ARRAY_OFFSET,
  inputData.length
)
u8Array.set(inputData)

class DecodeResult {
  constructor(ptr, memory) {
    const result = new Uint32Array(memory.buffer, ptr, 4)
    const [success, error, unpackSize, dataPtr] = result;
    this.success = success
    this.error = error
    if (this.success) {
      this.unpackSize = unpackSize
      this.data = new Uint8Array(
        memory.buffer,
        dataPtr + AS_ARRAY_OFFSET,
        unpackSize
      )
    }
  }
}

// Decode LZMA data
const resultPtr = lzma.decode(inputDataPtr)
const result = new DecodeResult(resultPtr, memory)

// Decompressed data
console.log(result.data)

// If the data is plain text, decode using TextDecoder
// const decoder = new TextDecoder()
// const text = decoder.decode(result.data)
// console.log(text)

How to make lzma file

Download lzma sdk and use following command

lzma e input_filename.extension output_filename.lzma

Developed by Nidin Vinayakan

License

MIT

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 4

Collected releases
VersionPublishedDirect dependenciesOpen version
1.0.2Registry latest24 Sept 20191
1.0.124 Sept 20191
1.0.0-beta224 Sept 20191
1.0.0-beta124 Sept 20191

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
01alchemist/as-lzma

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 21:55 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:ca199375fc1f99cba5136f8f705d7157d84e95e8d9994c55f57ad4a130de3938