datastore-fs
Advanced tools
Comparing version 2.0.2 to 3.0.0
@@ -0,1 +1,10 @@ | ||
# [3.0.0](https://github.com/ipfs/js-datastore-fs/compare/v2.0.2...v3.0.0) (2021-01-22) | ||
### Features | ||
* types ([#62](https://github.com/ipfs/js-datastore-fs/issues/62)) ([de519dd](https://github.com/ipfs/js-datastore-fs/commit/de519dd6b8c0b892e827fb2d26cde3239358eaf6)) | ||
## [2.0.2](https://github.com/ipfs/js-datastore-fs/compare/v2.0.1...v2.0.2) (2020-11-09) | ||
@@ -2,0 +11,0 @@ |
{ | ||
"name": "datastore-fs", | ||
"version": "2.0.2", | ||
"version": "3.0.0", | ||
"description": "Datastore implementation with file system backend", | ||
"leadMaintainer": "Alex Potsides <alex.potsides@protocol.ai>", | ||
"main": "src/index.js", | ||
"types": "dist/src/index.d.ts", | ||
"files": [ | ||
"src", | ||
"dist" | ||
], | ||
"scripts": { | ||
"prepare": "aegir build --no-bundle", | ||
"test": "aegir test -t node", | ||
@@ -35,5 +41,5 @@ "build": "aegir build", | ||
"dependencies": { | ||
"datastore-core": "^2.0.0", | ||
"datastore-core": "^3.0.0", | ||
"fast-write-atomic": "^0.2.0", | ||
"interface-datastore": "^2.0.0", | ||
"interface-datastore": "^3.0.3", | ||
"it-glob": "0.0.10", | ||
@@ -43,10 +49,13 @@ "mkdirp": "^1.0.4" | ||
"devDependencies": { | ||
"aegir": "^28.1.0", | ||
"aegir": "^30.3.0", | ||
"async-iterator-all": "^1.0.0", | ||
"cids": "^1.0.0", | ||
"cids": "^1.1.5", | ||
"detect-node": "^2.0.4", | ||
"ipfs-utils": "^4.0.1", | ||
"ipfs-utils": "^6.0.0", | ||
"memdown": "^5.1.0", | ||
"rimraf": "^3.0.2" | ||
}, | ||
"eslintConfig": { | ||
"extends": "ipfs" | ||
}, | ||
"contributors": [ | ||
@@ -57,5 +66,5 @@ "achingbrain <alex@achingbrain.net>", | ||
"Jacob Heun <jacobheun@gmail.com>", | ||
"Hugo Dias <hugomrdias@gmail.com>", | ||
"Pedro Teixeira <i@pgte.me>", | ||
"Hector Sanjuan <code@hector.link>", | ||
"Hugo Dias <hugomrdias@gmail.com>", | ||
"ᴠɪᴄᴛᴏʀ ʙᴊᴇʟᴋʜᴏʟᴍ <victorbjelkholm@gmail.com>", | ||
@@ -62,0 +71,0 @@ "Richard Schneider <makaretu@gmail.com>", |
@@ -5,4 +5,6 @@ 'use strict' | ||
const glob = require('it-glob') | ||
// @ts-ignore | ||
const mkdirp = require('mkdirp') | ||
const promisify = require('util').promisify | ||
// @ts-ignore | ||
const writeAtomic = promisify(require('fast-write-atomic')) | ||
@@ -21,2 +23,14 @@ const path = require('path') | ||
/** | ||
* @typedef {import('interface-datastore').Datastore} Datastore | ||
* @typedef {import('interface-datastore').Pair} Pair | ||
* @typedef {import('interface-datastore').Query} Query | ||
*/ | ||
/** | ||
* Write a file atomically | ||
* | ||
* @param {string} path | ||
* @param {Uint8Array} contents | ||
*/ | ||
async function writeFile (path, contents) { | ||
@@ -47,4 +61,10 @@ try { | ||
* to the file system as is. | ||
* | ||
* @implements {Datastore} | ||
*/ | ||
class FsDatastore extends Adapter { | ||
/** | ||
* @param {string} location | ||
* @param {{ createIfMissing?: boolean; errorIfExists?: boolean; extension?: string; } | undefined} [opts] | ||
*/ | ||
constructor (location, opts) { | ||
@@ -70,6 +90,7 @@ super() | ||
} | ||
return Promise.resolve() | ||
} catch (err) { | ||
if (err.code === 'ERR_NOT_FOUND' && this.opts.createIfMissing) { | ||
mkdirp.sync(this.path, { fs: fs }) | ||
return | ||
return Promise.resolve() | ||
} | ||
@@ -81,2 +102,6 @@ | ||
close () { | ||
return Promise.resolve() | ||
} | ||
/** | ||
@@ -87,3 +112,3 @@ * Calculate the directory and file name for a given key. | ||
* @param {Key} key | ||
* @returns {{string, string}} | ||
* @returns {{dir:string, file:string}} | ||
*/ | ||
@@ -203,3 +228,3 @@ _encode (key) { | ||
* @param {Key} key | ||
* @returns {Promise<bool>} | ||
* @returns {Promise<boolean>} | ||
*/ | ||
@@ -235,3 +260,8 @@ async has (key) { | ||
async * _all (q) { // eslint-disable-line require-await | ||
/** | ||
* | ||
* @param {Query} q | ||
* @returns {AsyncIterable<Pair>} | ||
*/ | ||
async * _all (q) { | ||
let prefix = q.prefix || '**' | ||
@@ -267,3 +297,3 @@ | ||
} else { | ||
yield * map(files, f => ({ key: this._decode(f) })) | ||
yield * map(files, f => /** @type {Pair} */({ key: this._decode(f) })) | ||
} | ||
@@ -270,0 +300,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18964
7
329
+ Added@types/minimatch@3.0.5(transitive)
+ Addeddatastore-core@3.0.0(transitive)
+ Addedelectron-fetch@1.9.1(transitive)
+ Addederr-code@3.0.1(transitive)
+ Addedevents@3.3.0(transitive)
+ Addedfast-fifo@1.3.2(transitive)
+ Addedinterface-datastore@3.0.6(transitive)
+ Addedipfs-utils@6.0.8(transitive)
+ Addediso-random-stream@2.0.2(transitive)
+ Addedit-glob@0.0.14(transitive)
+ Addedit-to-stream@1.0.0(transitive)
+ Addedmerge-options@3.0.4(transitive)
+ Addednative-fetch@3.0.0(transitive)
+ Addedp-defer@3.0.0(transitive)
+ Addedp-fifo@1.0.0(transitive)
- Removed@achingbrain/electron-fetch@1.7.2(transitive)
- Removedcall-bind@1.0.7(transitive)
- Removedclass-is@1.1.0(transitive)
- Removeddatastore-core@2.0.1(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removeddefine-properties@1.2.1(transitive)
- Removederr-code@2.0.3(transitive)
- Removedes-define-property@1.0.0(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-intrinsic@1.2.4(transitive)
- Removedglobalthis@1.0.4(transitive)
- Removedgopd@1.1.0(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-proto@1.1.0(transitive)
- Removedhas-symbols@1.0.3(transitive)
- Removedhasown@2.0.2(transitive)
- Removedinterface-datastore@2.0.1(transitive)
- Removedipfs-utils@4.0.1(transitive)
- Removediso-random-stream@1.1.2(transitive)
- Removedmerge-options@2.0.0(transitive)
- Removednative-abort-controller@0.0.3(transitive)
- Removednative-fetch@2.0.1(transitive)
- Removedobject-keys@1.1.1(transitive)
- Removedset-function-length@1.2.2(transitive)
Updateddatastore-core@^3.0.0
Updatedinterface-datastore@^3.0.3