pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/pine/arraybuffer-loader/commit/ea30e2ad1dd822e234578e48be63a6ebe3e55128

="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/global-9c8f61f9f58ad7b2.css" /> fix(arraybuffer-loader): fix binary file bugs · pine/arraybuffer-loader@ea30e2a · GitHub
Skip to content

Commit ea30e2a

Browse files
committed
fix(arraybuffer-loader): fix binary file bugs
1 parent b7d0009 commit ea30e2a

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

lib/arraybuffer-loader.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ module.exports = function (content) {
88
const toArrayBufferPath =
99
loaderUtils.stringifyRequest(this, require.resolve('./to-array-buffer.js'))
1010

11-
const base64Data = typeof content === 'string' ?
12-
new Buffer(content).toString('base64') : content.toString('base64')
11+
const base64Data = content.toString('base64')
1312

1413
return `module.exports = require(${toArrayBufferPath})("${base64Data}")`;
1514
}
15+
16+
module.exports.raw = true

test/arraybuffer-loader.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,13 @@ describe('text files', function () {
1919
expect(text).to.equal('\uD83D\uDE07\n') // :innocent:
2020
})
2121
})
22+
23+
describe('binary files', function () {
24+
it('can bundle binary file', function () {
25+
var buffer = require('arraybuffer!./data/binary.dat')
26+
var binarray = new Uint8Array(buffer)
27+
var array = Array.prototype.slice.call(binarray) // Array.from
28+
29+
expect(array).to.deep.equal([ 0x01, 0x02, 0x04, 0x00 ])
30+
})
31+
})

test/data/binary.dat

4 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy