New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fs-blob-storage

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fs-blob-storage - npm Package Compare versions

Comparing version 0.4.1 to 0.5.0

test/fs-blob-storage-with-default-ext.js

4

CHANGELOG.md
# Changelog
## v0.5.0 2018-05-19
* New constructor option `defaultExt` and `defaultPart`.
## v0.4.1 2018-05-18

@@ -4,0 +8,0 @@

@@ -6,2 +6,4 @@ /// <reference types="node" />

export interface FsBlobStorageOptions {
defaultExt?: string
defaultPart?: string
exclusive?: boolean

@@ -8,0 +10,0 @@ path?: string

15

lib/fs-blob-storage.js

@@ -17,4 +17,6 @@ const fs = require('fs')

* @interface FsBlobStorageOptions
* @property {string} [defaultExt]
* @property {string} [defaultPart]
* @property {boolean} [exclusive]
* @property {string} path
* @property {string} [path]
*/

@@ -52,2 +54,4 @@

constructor (options = {}) {
this.defaultExt = options.defaultExt !== undefined ? options.defaultExt : DEFAULT_EXT
this.defaultPart = options.defaultPart !== undefined ? options.defaultPart : DEFAULT_PART
this.writeFlags = options.exclusive ? 'wx' : 'w'

@@ -63,3 +67,3 @@ this.path = options.path || '.'

createWriteStream (key, options = {}) {
const { ext = DEFAULT_EXT, part = DEFAULT_PART, encoding = null } = options
const { ext = this.defaultExt, part = this.defaultPart, encoding = null } = options
const filepath = path.join(this.path, key + ext)

@@ -99,3 +103,3 @@ const dirpath = path.dirname(filepath)

createReadStream (key, options = {}) {
const { ext = DEFAULT_EXT, encoding = null } = options
const { ext = this.defaultExt, encoding = null } = options
const filepath = path.join(this.path, key + ext)

@@ -123,3 +127,3 @@

commit (key, options = {}) {
const { ext = DEFAULT_EXT, part = DEFAULT_PART } = options
const { ext = this.defaultExt, part = this.defaultPart } = options
if (part) {

@@ -137,3 +141,3 @@ const filepath = path.join(this.path, key + ext)

remove (key, options = {}) {
const { ext = DEFAULT_EXT } = options
const { ext = this.defaultExt } = options
const filepath = path.join(this.path, key + ext)

@@ -145,4 +149,3 @@ return fsPromises.unlink(filepath)

FsBlobStorage.FsBlobStorage = FsBlobStorage
FsBlobStorage.default = FsBlobStorage
module.exports = FsBlobStorage
{
"name": "fs-blob-storage",
"version": "0.4.1",
"version": "0.5.0",
"description": "Blob storage on filesystem with promises API",

@@ -33,5 +33,11 @@ "main": "lib/fs-blob-storage.js",

"@types/make-dir": "^1.0.3",
"@types/node": "^10.1.1",
"@types/node": "^10.1.2",
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"eslint": "^4.19.1",
"eslint-config-standard": "^11.0.0",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^3.7.0",
"eslint-plugin-standard": "^3.1.0",
"markdownlint-cli": "^0.8.2",

@@ -41,3 +47,2 @@ "mock-fs": "^4.5.0",

"promise-writable": "^3.1.2",
"snazzy": "^7.1.1",
"standard": "^11.0.1",

@@ -51,3 +56,3 @@ "tap": "^12.0.1",

"scripts": {
"pretest": "standard --verbose | snazzy && tsc --noEmit --pretty && tslint -t stylish -p . && echo markdownlint *.md",
"pretest": "eslint . && tsc --noEmit --pretty && tslint -t stylish -p . && echo markdownlint *.md",
"test": "npm run test:api",

@@ -54,0 +59,0 @@ "test:api": "tap test/*.js",

@@ -43,5 +43,8 @@ # fs-blob-storage

* `defaultExt` is a default `ext` argument for methods (optional, default: "")
* `defaultPart` is a default `part` argument for methods (optional, default:
".part")
* `exclusive` if is true then can't create new object if already exists with
the same key (optional, default: false)
* `path` is a directory path of the storage
* `path` is a directory path of the storage (optional, default: ".")

@@ -52,2 +55,3 @@ _Example:_

const storage = new FsBlobStorage({
defaultPart: '.lock',
path: '/var/spool/mail',

@@ -67,5 +71,5 @@ exclusive: true

* `ext` is a default extension added to file name for the object (optional,
default: "")
default: `this.defaultExt`)
* `part` is a extension added to file name which can be later commited
(optional, default: ".part")
(optional, default: `this.defaultPart`)
* `encoding` is a encoding for created file (optional, default: `null`)

@@ -101,5 +105,5 @@

* `ext` is a default extension added to file name for the object (optional,
default: "")
default: `this.defaultExt`)
* `part` is a extension added to file name which can be later commited
(optional, default: ".part")
(optional, default: `this.defaultPart`)

@@ -119,3 +123,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: "")
default: `this.defaultExt`)

@@ -122,0 +126,0 @@ Removes the object from the storage. Throws an error if has occurred or the

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