Skip to content

Commit

Permalink
fix: remove is-typedarray and typedarray-to-buffer
Browse files Browse the repository at this point in the history
our support matrix has support for sending typed arrays directly to
tbuffers
  • Loading branch information
wraithgar committed Feb 9, 2022
1 parent 0b3ffdb commit 625526e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
12 changes: 2 additions & 10 deletions lib/index.js
Expand Up @@ -8,8 +8,6 @@ const fs = require('fs')
const MurmurHash3 = require('imurmurhash')
const onExit = require('signal-exit')
const path = require('path')
const isTypedArray = require('is-typedarray')
const typedArrayToBuffer = require('typedarray-to-buffer')
const { promisify } = require('util')
const activeFiles = {}

Expand Down Expand Up @@ -110,10 +108,7 @@ async function writeFileAsync (filename, data, options = {}) {
if (options.tmpfileCreated) {
await options.tmpfileCreated(tmpfile)
}
if (isTypedArray(data)) {
data = typedArrayToBuffer(data)
}
if (Buffer.isBuffer(data)) {
if (Buffer.isBuffer(data) || ArrayBuffer.isView(data)) {
await promisify(fs.write)(fd, data, 0, data.length, 0)
} else if (data != null) {
await promisify(fs.write)(fd, String(data), 0, String(options.encoding || 'utf8'))
Expand Down Expand Up @@ -215,10 +210,7 @@ function writeFileSync (filename, data, options) {
if (options.tmpfileCreated) {
options.tmpfileCreated(tmpfile)
}
if (isTypedArray(data)) {
data = typedArrayToBuffer(data)
}
if (Buffer.isBuffer(data)) {
if (Buffer.isBuffer(data) || ArrayBuffer.isView(data)) {
fs.writeSync(fd, data, 0, data.length, 0)
} else if (data != null) {
fs.writeSync(fd, String(data), 0, String(options.encoding || 'utf8'))
Expand Down
4 changes: 1 addition & 3 deletions package.json
Expand Up @@ -31,9 +31,7 @@
"homepage": "https://github.com/npm/write-file-atomic",
"dependencies": {
"imurmurhash": "^0.1.4",
"is-typedarray": "^1.0.0",
"signal-exit": "^3.0.7",
"typedarray-to-buffer": "^4.0.0"
"signal-exit": "^3.0.7"
},
"devDependencies": {
"@npmcli/template-oss": "^2.7.1",
Expand Down

0 comments on commit 625526e

Please sign in to comment.