Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

random-access-web

Package Overview
Dependencies
20
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.0 to 2.0.0

112

index.js

@@ -1,28 +0,108 @@

const global = (typeof window !== 'undefined') ? window : self;
/* global self */
const global = (typeof window !== 'undefined') ? window : self
const requestFileSystem = global.requestFileSystem || global.webkitRequestFileSystem
const mutableFile = global.IDBMutableFile
const idb = global.indexedDB
const DEFAULT_DB_NAME = 'random-access-web'
let init = async (options={}) => {
if(typeof options === 'string') options = {name: options}
const name = options.name || DEFAULT_DB_NAME
return require('random-access-idb')(name)
let storage = () => require('random-access-memory')
if (requestFileSystem) {
storage = (options) => {
const RACF = require('random-access-chrome-file')
if ((typeof options === 'object') && options.maxSize) {
RACF.DEFAULT_MAX_SIZE = options.maxSize
}
return RACF
}
} else if (mutableFile) {
storage = (options = {}) => {
if (typeof options === 'string') options = { name: options }
return mutableStorage(options)
}
} else if (idb) {
storage = (options = {}) => {
if (typeof options === 'string') options = { name: options }
const name = options.name || DEFAULT_DB_NAME
return require('random-access-idb')(name, options)
}
}
if(requestFileSystem) {
init = async (options) => {
return require('random-access-chrome-file')
module.exports = storage
function mutableStorage (options) {
const randomAccess = require('random-access-storage')
const mutableAccess = require('@sammacbeth/random-access-idb-mutable-file')
let mounted = null
let loading = null
function doMount () {
return mutableAccess.mount(options).then((requestFile) => {
mounted = requestFile
loading = null
})
}
} else if(mutableFile) {
init = async (options) => {
const RandomAccess = require('@sammacbeth/random-access-idb-mutable-file')
return RandomAccess.mount()
return (name) => {
let file = null
return randomAccess({
open: function (req) {
if (!mounted) {
loading = doMount()
}
if(loading) {
loading.then(() => {
this._open(req)
}, (err) => {
req.callback(err)
})
return
}
file = mounted(name)
file._open(req)
},
openReadonly: function (req) {
if (!mounted) {
loading = doMount()
}
if(loading) {
loading.then(() => {
this._openReadonly(req)
}, (err) => {
req.callback(err)
})
return
}
file = mounted(name)
file._openReadonly(req)
},
write: function (req) {
file._write(req)
},
read: function (req) {
file._read(req)
},
del: function (req) {
file._del(req)
},
stat: function (req) {
file._stat(req)
},
close: function (req) {
file._close(req)
},
destroy: function (req) {
file._destroy(req)
}
})
}
}
module.exports = {
init
}

6

package.json
{
"name": "random-access-web",
"version": "1.1.0",
"version": "2.0.0",
"description": "Chooses the fastest random access backend based on the user's browser",

@@ -29,4 +29,6 @@ "main": "index.js",

"random-access-chrome-file": "^1.1.2",
"random-access-idb": "^1.2.1"
"random-access-idb": "^1.2.1",
"random-access-memory": "^3.1.1",
"random-access-storage": "^1.3.0"
}
}

@@ -9,5 +9,5 @@ # random-access-web

```js
const RandomAccessWeb = require('random-access-web')
const RAW = require('random-access-web')
const storage = await RandomAccessWeb.init()
const storage = RAW('dats')

@@ -14,0 +14,0 @@ const dat = new DatJs({

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc