feross / feross/buffer

TypeError: writeUint32LE is not a function

Open
#319 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.9k
Forks
260
PR merge metrics
No merged PRs in 30d

Description

Hi thank you for this library. It makes my life easier :)

I have some problem with this code. It tries to call `writeUint32LE`, but it seems to be undefined.

```javascript
function ttf2eot(arrayBuffer) {
const arr = Buffer.from(arrayBuffer);

const out = Buffer.alloc(SIZEOF.EOT_PREFIX, 0);

out.writeUint32LE(arr.length, EOT_OFFSET.FONT_LENGTH);
out.writeUint32LE(MAGIC.EOT_VERSION, EOT_OFFSET.VERSION);
// other code ...
}
```

I found a stackoverflow anser here https://stackoverflow.com/a/38543218/2638899
saying that i could use DataView

```js
var dataview = new DataView(arrayBuffer);
dataView.setUint32(0,value);
return dataView.getFloat32(0);
```
My problem is that `ttf2eot` function is based on `Buffer` and refactor it with `DataView` is not doable.

Do you have any suggestions? Can i use another method instead of `writeUint32LE`?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.