Socket
Socket
Sign inDemoInstall

lowdb

Package Overview
Dependencies
7
Maintainers
1
Versions
76
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.10.2 to 0.10.3

Release.key

7

package.json
{
"name": "lowdb",
"version": "0.10.2",
"version": "0.10.3",
"description": "Flat JSON file database",

@@ -37,6 +37,7 @@ "keywords": [

"lodash": "^3.1.0",
"steno": "^0.4.1"
"steno": "^0.4.1",
"q": "^1.4.1"
},
"devDependencies": {
"husky": "^0.7.0",
"husky": "^0.9.0",
"mocha": "^2.2.5",

@@ -43,0 +44,0 @@ "rimraf": "^2.2.8",

@@ -65,2 +65,3 @@ # lowdb [![NPM version](https://badge.fury.io/js/lowdb.svg)](http://badge.fury.io/js/lowdb) [![Build Status](https://travis-ci.org/typicode/lowdb.svg?branch=master)](https://travis-ci.org/typicode/lowdb)

async: true // asynchronous write (default: true)
promise: false // .save() and .value() return a promise (default: false)
})

@@ -141,3 +142,3 @@ ```

```javascript
db('songs').pluck('titles')
db('songs').pluck('title')
```

@@ -144,0 +145,0 @@

var fs = require('graceful-fs')
var steno = require('steno')
var Q = require('q')

@@ -20,3 +21,16 @@ module.exports = {

steno.writeFileSync(file, data)
},
writePromise: function (file, data) {
var deferred = Q.defer()
steno.writeFile(file, data, function (err) {
if (err) {
deferred.reject(new Error(err))
} else {
deferred.resolve('success')
}
})
return deferred.promise
}
}
var lodash = require('lodash')
var disk = require('./disk')
var jph = require('json-parse-helpfulerror')
var Q = require('q')
// Returns a lodash chain that calls .value() and cb()

@@ -34,3 +34,4 @@ // automatically after the first .method()

autosave: true,
async: true
async: true,
promise: false
}, options)

@@ -42,4 +43,15 @@

var res = value.apply(this, arguments)
save()
return res
if (options.promise) {
return save().then(
function () {
return res
},
function (err) {
throw err
}
)
} else {
save()
return res
}
}

@@ -54,5 +66,21 @@

// Don't write if there's no changes
if (str === checksum) return
if (str === checksum) {
if (options.promise) {
return Q.fcall(function () {
return 'no changes'
})
} else {
return
}
}
checksum = str
options.async ? disk.write(file, str) : disk.writeSync(file, str)
if (options.async) {
if (options.promise) {
return disk.writePromise(file, str)
} else {
disk.write(file, str)
}
} else {
disk.writeSync(file, str)
}
}

@@ -87,2 +115,7 @@ }

db.savePromise = function (f) {
f = f ? f : file
return disk.writePromise(f, low.stringify(db.object))
}
// Expose lodash instance

@@ -89,0 +122,0 @@ db._ = _

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