Skip to content

alexzhang1030/memcode

Repository files navigation

memcode

NPM Version NPM Downloads License

Organize your filles and download them in your browser.

Installation

pnpm i memcode

Usage

import { MemCode } from 'memcode'

// add files when creating
const code = new MemCode([{
  name: 'src/index.ts',
  content: 'console.log("hello world")'
}])

// add
code.add('package.json', JSON.stringify({
  name: 'hello world'
}))

// add also support directory
code.add('/src/index.ts', 'console.log("hello world")')
code.add('/src/foo/bar.ts', 'console.log("hello foo bar"')

// update
code.update('src/index.ts', 'const a = 1')

// remove
code.remove('src/index.ts')

// To zip
const blob = await code.toZipBlob()

// Download zip
code.downloadZip(blob, 'memcode.zip')

License

MIT