Comparing version 0.11.1 to 0.11.2
11
index.js
'use strict'; | ||
var lodash = require('lodash'); | ||
var isPromise = require('is-promise'); | ||
@@ -98,3 +99,11 @@ // Returns a lodash chain that calls .value() | ||
if (db.source && db.read) { | ||
db.object = db.read(db.source, db.deserialize); | ||
var res = db.read(db.source, db.deserialize); | ||
if (isPromise(res)) { | ||
return res.then(function (obj) { | ||
db.object = obj; | ||
return db; | ||
}); | ||
} else { | ||
db.object = res; | ||
} | ||
} | ||
@@ -101,0 +110,0 @@ |
{ | ||
"name": "lowdb", | ||
"version": "0.11.1", | ||
"version": "0.11.2", | ||
"description": "JSON database for Node and the browser powered by lodash", | ||
@@ -21,3 +21,3 @@ "keywords": [ | ||
"scripts": { | ||
"test": "babel-node test/all && standard {src,test}/**/*.js", | ||
"test": "babel-node test/all && standard", | ||
"prepublish": "npm run build", | ||
@@ -39,2 +39,3 @@ "precommit": "npm test", | ||
"graceful-fs": "^3.0.8", | ||
"is-promise": "^2.1.0", | ||
"json-parse-helpfulerror": "^1.0.3", | ||
@@ -41,0 +42,0 @@ "lodash": "^3.1.0", |
@@ -32,4 +32,6 @@ # 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) | ||
Please note that lowdb can only be run in one instance of Node, it doesn't support Cluster. | ||
_Examples use ES2015 syntax, it's supported by Node 5+. Node 0.12 is supported too but you need to use the older syntax._ | ||
_Please note that lowdb can only be run in one instance of Node, it doesn't support Cluster._ | ||
## Install | ||
@@ -51,3 +53,3 @@ | ||
Lowdb is also very easy to learn since it has __only 4 methods and properties__. | ||
Lowdb is also very easy to learn since it has __only a few methods and properties__. | ||
@@ -144,5 +146,4 @@ _lowdb powers [json-server](https://github.com/typicode/json-server) package, [jsonplaceholder](http://jsonplaceholder.typicode.com/) website and [many other great projects](https://www.npmjs.com/browse/depended/lowdb)._ | ||
// To create read-only or write-only database | ||
// pass only the read or write function. | ||
// For example: | ||
// To create read-only or write-only database, | ||
// set only storage.read or storage.write | ||
const fileSync = require('lowdb/fileSync') | ||
@@ -166,3 +167,3 @@ | ||
storage: { | ||
read: (source, deserialize) => // obj | ||
read: (source, deserialize) => // obj or a Promise | ||
write: (dest, obj, serialize) => // undefined or a Promise | ||
@@ -169,0 +170,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
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
16245
162
364
0
5
+ Addedis-promise@^2.1.0
+ Addedis-promise@2.2.2(transitive)