Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bare-fs

Package Overview
Dependencies
Maintainers
2
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bare-fs - npm Package Compare versions

Comparing version 2.2.3 to 2.3.0

64

index.js
/* global Bare */
const EventEmitter = require('bare-events')
const path = require('bare-path')
const { Readable, Writable } = require('streamx')
const { Readable, Writable } = require('bare-stream')
const binding = require('./binding')

@@ -343,3 +343,3 @@

function write (fd, buffer, offset, len, pos, cb) {
function write (fd, data, offset, len, pos, cb) {
if (typeof fd !== 'number') {

@@ -353,15 +353,41 @@ throw typeError('ERR_INVALID_ARG_TYPE', 'File descriptor must be a number. Received type ' + (typeof fd) + ' (' + fd + ')')

if (!Buffer.isBuffer(buffer) && !ArrayBuffer.isView(buffer)) {
throw typeError('ERR_INVALID_ARG_TYPE', 'Buffer must be a buffer. Received type ' + (typeof buffer) + ' (' + buffer + ')')
if (typeof data !== 'string' && !Buffer.isBuffer(data) && !ArrayBuffer.isView(data)) {
throw typeError('ERR_INVALID_ARG_TYPE', 'Data must be a string or buffer. Received type ' + (typeof data))
}
if (typeof cb !== 'function') {
if (typeof data === 'string') {
let encoding = len
cb = pos
pos = offset
if (typeof cb !== 'function') {
if (typeof pos === 'function') {
cb = pos
pos = -1
encoding = 'utf8'
} else if (typeof encoding === 'function') {
cb = encoding
encoding = 'utf8'
} else {
throw typeError('ERR_INVALID_ARG_TYPE', 'Callback must be a function. Received type ' + (typeof cb) + ' (' + cb + ')')
}
}
if (typeof pos === 'string') {
encoding = pos
pos = -1
}
data = Buffer.from(data, encoding)
offset = 0
len = data.byteLength
} else if (typeof cb !== 'function') {
if (typeof offset === 'function') {
cb = offset
offset = 0
len = buffer.byteLength
len = data.byteLength
pos = -1
} else if (typeof len === 'function') {
cb = len
len = buffer.byteLength - offset
len = data.byteLength - offset
pos = -1

@@ -380,6 +406,6 @@ } else if (typeof pos === 'function') {

req.callback = cb
binding.write(req.handle, fd, buffer, offset, len, pos)
binding.write(req.handle, fd, data, offset, len, pos)
}
function writeSync (fd, buffer, offset = 0, len = buffer.byteLength - offset, pos = -1) {
function writeSync (fd, data, offset = 0, len, pos) {
if (typeof fd !== 'number') {

@@ -393,7 +419,13 @@ throw typeError('ERR_INVALID_ARG_TYPE', 'File descriptor must be a number. Received type ' + (typeof fd) + ' (' + fd + ')')

if (!Buffer.isBuffer(buffer) && !ArrayBuffer.isView(buffer)) {
throw typeError('ERR_INVALID_ARG_TYPE', 'Buffer must be a buffer. Received type ' + (typeof buffer) + ' (' + buffer + ')')
if (typeof data !== 'string' && !Buffer.isBuffer(data) && !ArrayBuffer.isView(data)) {
throw typeError('ERR_INVALID_ARG_TYPE', 'Data must be a string or buffer. Received type ' + (typeof data))
}
return binding.writeSync(fd, buffer, offset, len, pos)
if (typeof data === 'string') data = Buffer.from(data)
if (typeof len !== 'number') len = data.byteLength - offset
if (typeof pos !== 'number') pos = -1
return binding.writeSync(fd, data, offset, len, pos)
}

@@ -1262,3 +1294,3 @@

if (typeof data !== 'string' && !Buffer.isBuffer(data) && !ArrayBuffer.isView(data)) {
throw typeError('ERR_INVALID_ARG_TYPE', 'Data must be a string or buffer. Received type ' + (typeof data) + ' (' + data + ')')
throw typeError('ERR_INVALID_ARG_TYPE', 'Data must be a string or buffer. Received type ' + (typeof data))
}

@@ -1310,3 +1342,3 @@

if (typeof data !== 'string' && !Buffer.isBuffer(data) && !ArrayBuffer.isView(data)) {
throw typeError('ERR_INVALID_ARG_TYPE', 'Data must be a string or buffer. Received type ' + (typeof data) + ' (' + data + ')')
throw typeError('ERR_INVALID_ARG_TYPE', 'Data must be a string or buffer. Received type ' + (typeof data))
}

@@ -1341,3 +1373,3 @@

if (typeof data !== 'string' && !Buffer.isBuffer(data) && !ArrayBuffer.isView(data)) {
throw typeError('ERR_INVALID_ARG_TYPE', 'Data must be a string or buffer. Received type ' + (typeof data) + ' (' + data + ')')
throw typeError('ERR_INVALID_ARG_TYPE', 'Data must be a string or buffer. Received type ' + (typeof data))
}

@@ -1368,3 +1400,3 @@

if (typeof data !== 'string' && !Buffer.isBuffer(data) && !ArrayBuffer.isView(data)) {
throw typeError('ERR_INVALID_ARG_TYPE', 'Data must be a string or buffer. Received type ' + (typeof data) + ' (' + data + ')')
throw typeError('ERR_INVALID_ARG_TYPE', 'Data must be a string or buffer. Received type ' + (typeof data))
}

@@ -1371,0 +1403,0 @@

{
"name": "bare-fs",
"version": "2.2.3",
"version": "2.3.0",
"description": "Native file system for Javascript",

@@ -31,3 +31,3 @@ "main": "index.js",

"bare-path": "^2.0.0",
"streamx": "^2.13.0"
"bare-stream": "^1.0.0"
},

@@ -34,0 +34,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc