Skip to content

Commit

Permalink
Remove b4a
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperisager committed Oct 22, 2024
1 parent b9927b9 commit 3c0e76b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
18 changes: 8 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
const b4a = require('b4a')

class MemoryFile {
constructor (data, opts = {}) {
const {
executable = false,
mode = executable ? 0o755 : 0o644
} = opts

this._data = typeof data === 'string' ? b4a.from(data) : data
this._data = typeof data === 'string' ? Buffer.from(data) : data
this._mode = mode
}

Expand Down Expand Up @@ -229,11 +227,11 @@ const Bundle = module.exports = exports = class Bundle {
offset += length
}

const json = b4a.from(`\n${JSON.stringify(header, null, indent)}\n`)
const json = Buffer.from(`\n${JSON.stringify(header, null, indent)}\n`)

const len = b4a.from(json.byteLength.toString(10))
const len = Buffer.from(json.byteLength.toString(10))

const buffer = b4a.alloc(len.byteLength + json.byteLength + offset)
const buffer = Buffer.alloc(len.byteLength + json.byteLength + offset)

offset = 0

Expand Down Expand Up @@ -283,14 +281,14 @@ exports.from = function from (value) {
if (typeof value === 'string') return fromString(value)

// from(buffer)
if (b4a.isBuffer(value)) return fromBuffer(value)
if (Buffer.isBuffer(value)) return fromBuffer(value)

// from(bundle)
return value
}

function fromString (string) {
return fromBuffer(b4a.from(string))
return fromBuffer(Buffer.from(string))
}

function fromBuffer (buffer) {
Expand All @@ -306,9 +304,9 @@ function fromBuffer (buffer) {

while (isDecimal(buffer[end])) end++

const len = parseInt(b4a.toString(buffer, 'utf8', 0, end), 10)
const len = parseInt(buffer.toString('utf8', 0, end), 10)

const header = JSON.parse(b4a.toString(buffer, 'utf8', end, end + len))
const header = JSON.parse(buffer.toString('utf8', end, end + len))

const bundle = new Bundle()

Expand Down
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
"url": "https://github.com/holepunchto/bare-bundle/issues"
},
"homepage": "https://github.com/holepunchto/bare-bundle#readme",
"dependencies": {
"b4a": "^1.6.4"
},
"devDependencies": {
"brittle": "^3.1.1",
"standard": "^17.0.0"
Expand Down

0 comments on commit 3c0e76b

Please sign in to comment.