fs-blob-storage
Advanced tools
Comparing version 1.0.0 to 1.1.0
# Changelog | ||
## v1.1.0 2018-09-07 | ||
* The `defaultExt` and `defaultPart` options has need renamed to `ext` and | ||
`part`. | ||
## v1.0.0 2018-09-07 | ||
@@ -4,0 +9,0 @@ |
/// <reference types="node" /> | ||
import fs from 'fs'; | ||
export interface FsBlobStorageOptions { | ||
defaultExt?: string; | ||
defaultPart?: string; | ||
ext?: string; | ||
part?: string; | ||
exclusive?: boolean; | ||
@@ -34,4 +34,4 @@ path?: string; | ||
export declare class FsBlobStorage { | ||
protected defaultExt: string; | ||
protected defaultPart: string; | ||
protected ext: string; | ||
protected part: string; | ||
protected writeFlags: string; | ||
@@ -38,0 +38,0 @@ protected fs: typeof fs; |
@@ -14,4 +14,4 @@ "use strict"; | ||
constructor(options = {}) { | ||
this.defaultExt = options.defaultExt !== undefined ? options.defaultExt : DEFAULT_EXT; | ||
this.defaultPart = options.defaultPart !== undefined ? options.defaultPart : DEFAULT_PART; | ||
this.ext = options.ext !== undefined ? options.ext : DEFAULT_EXT; | ||
this.part = options.part !== undefined ? options.part : DEFAULT_PART; | ||
this.writeFlags = options.exclusive ? 'wx' : 'w'; | ||
@@ -27,3 +27,3 @@ this.fs = options.fs || fs_1.default; | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const { ext = this.defaultExt, part = this.defaultPart, encoding } = options; | ||
const { ext = this.ext, part = this.part, encoding } = options; | ||
const filepath = path_1.default.join(this.path, key + ext); | ||
@@ -48,3 +48,3 @@ const dirpath = path_1.default.dirname(filepath); | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const { ext = this.defaultExt, encoding } = options; | ||
const { ext = this.ext, encoding } = options; | ||
const filepath = path_1.default.join(this.path, key + ext); | ||
@@ -61,3 +61,3 @@ const fd = yield this.fsPromises.open(filepath, 'r'); | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const { ext = this.defaultExt, part = this.defaultPart } = options; | ||
const { ext = this.ext, part = this.part } = options; | ||
if (part) { | ||
@@ -71,3 +71,3 @@ const filepath = path_1.default.join(this.path, key + ext); | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const { ext = this.defaultExt } = options; | ||
const { ext = this.ext } = options; | ||
const filepath = path_1.default.join(this.path, key + ext); | ||
@@ -74,0 +74,0 @@ return this.fsPromises.unlink(filepath); |
{ | ||
"name": "fs-blob-storage", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Blob storage on filesystem, with streams and promises API", | ||
@@ -5,0 +5,0 @@ "main": "lib/fs-blob-storage.js", |
@@ -66,4 +66,4 @@ # fs-blob-storage | ||
* `defaultExt` is a default `ext` argument for methods (optional, default: `''`) | ||
* `defaultPart` is a default `part` argument for methods (optional, default: | ||
* `ext` is a default `ext` argument for methods (optional, default: `''`) | ||
* `part` is a default `part` argument for methods (optional, default: | ||
`'.part'`) | ||
@@ -80,3 +80,3 @@ * `exclusive` if is true then can't create new object if already exists with | ||
const storage = new FsBlobStorage({ | ||
defaultPart: '.lock', | ||
part: '.lock', | ||
path: '/var/spool/mail', | ||
@@ -96,5 +96,5 @@ exclusive: true | ||
* `ext` is a default extension added to file name for the object (optional, | ||
default: `this.defaultExt`) | ||
default: `this.ext`) | ||
* `part` is a extension added to file name which can be later commited | ||
(optional, default: `this.defaultPart`) | ||
(optional, default: `this.part`) | ||
* `encoding` is a encoding for created file (optional, default: `null`) | ||
@@ -130,5 +130,5 @@ | ||
* `ext` is a default extension added to file name for the object (optional, | ||
default: `this.defaultExt`) | ||
default: `this.ext`) | ||
* `part` is a extension added to file name which can be later commited | ||
(optional, default: `this.defaultPart`) | ||
(optional, default: `this.part`) | ||
@@ -148,3 +148,3 @@ Commits the object in the storage. It means that file name for the object is | ||
* `ext` is a default extension added to file name for the object (optional, | ||
default: `this.defaultExt`) | ||
default: `this.ext`) | ||
@@ -151,0 +151,0 @@ Removes the object from the storage. Throws an error if has occurred or the |
@@ -12,4 +12,4 @@ /// <reference types="node" /> | ||
export interface FsBlobStorageOptions { | ||
defaultExt?: string | ||
defaultPart?: string | ||
ext?: string | ||
part?: string | ||
exclusive?: boolean | ||
@@ -52,4 +52,4 @@ path?: string | ||
export class FsBlobStorage { | ||
protected defaultExt: string | ||
protected defaultPart: string | ||
protected ext: string | ||
protected part: string | ||
protected writeFlags: string | ||
@@ -62,4 +62,4 @@ protected fs: typeof fs | ||
constructor (options: FsBlobStorageOptions = {}) { | ||
this.defaultExt = options.defaultExt !== undefined ? options.defaultExt : DEFAULT_EXT | ||
this.defaultPart = options.defaultPart !== undefined ? options.defaultPart : DEFAULT_PART | ||
this.ext = options.ext !== undefined ? options.ext : DEFAULT_EXT | ||
this.part = options.part !== undefined ? options.part : DEFAULT_PART | ||
this.writeFlags = options.exclusive ? 'wx' : 'w' | ||
@@ -76,3 +76,3 @@ this.fs = options.fs || fs | ||
async createWriteStream (key: string, options: FsBlobStorageWriteStreamOptions = {}): Promise<fs.WriteStream> { | ||
const { ext = this.defaultExt, part = this.defaultPart, encoding } = options | ||
const { ext = this.ext, part = this.part, encoding } = options | ||
const filepath = path.join(this.path, key + ext) | ||
@@ -102,3 +102,3 @@ const dirpath = path.dirname(filepath) | ||
async createReadStream (key: string, options: FsBlobStorageReadStreamOptions = {}): Promise<fs.ReadStream> { | ||
const { ext = this.defaultExt, encoding } = options | ||
const { ext = this.ext, encoding } = options | ||
const filepath = path.join(this.path, key + ext) | ||
@@ -118,3 +118,3 @@ | ||
async commit (key: string, options: FsBlobStorageCommitOptions = {}): Promise<void> { | ||
const { ext = this.defaultExt, part = this.defaultPart } = options | ||
const { ext = this.ext, part = this.part } = options | ||
if (part) { | ||
@@ -127,3 +127,3 @@ const filepath = path.join(this.path, key + ext) | ||
async remove (key: string, options: FsBlobStorageRemoveOptions = {}): Promise<void> { | ||
const { ext = this.defaultExt } = options | ||
const { ext = this.ext } = options | ||
const filepath = path.join(this.path, key + ext) | ||
@@ -130,0 +130,0 @@ return this.fsPromises.unlink(filepath) |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
17673