Socket
Socket
Sign inDemoInstall

lowdb

Package Overview
Dependencies
6
Maintainers
1
Versions
76
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.16.0 to 0.16.1

examples/fp.md

123

dist/lowdb.js

@@ -1,2 +0,2 @@

/*! lowdb v0.16.0 */
/*! lowdb v0.16.1 */
var low =

@@ -6,10 +6,10 @@ /******/ (function(modules) { // webpackBootstrap

/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/
/******/ // Create a new module (and put it into the cache)

@@ -21,23 +21,23 @@ /******/ var module = installedModules[moduleId] = {

/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // identity function for calling harmony imports with the correct context
/******/ __webpack_require__.i = function(value) { return value; };
/******/
/******/ // define getter function for harmony exports

@@ -53,3 +53,3 @@ /******/ __webpack_require__.d = function(exports, name, getter) {

/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules

@@ -63,11 +63,11 @@ /******/ __webpack_require__.n = function(module) {

/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 5);
/******/ return __webpack_require__(__webpack_require__.s = 2);
/******/ })

@@ -84,5 +84,5 @@ /************************************************************************/

var isPromise = __webpack_require__(4);
var memory = __webpack_require__(3);
var defaultStorage = __webpack_require__(2);
var isPromise = __webpack_require__(6);
var memory = __webpack_require__(5);
var defaultStorage = __webpack_require__(4);

@@ -155,3 +155,48 @@ var init = function init(db, key, source) {

var lodash = __webpack_require__(1);
var common = __webpack_require__(0);
module.exports = function (source) {
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
// Create a fresh copy of lodash
var _ = lodash.runInContext();
var db = _.chain({});
// Expose _ for mixins
db._ = _;
// Add write function to lodash
// Calls save before returning result
_.prototype.write = _.wrap(_.prototype.value, function (func) {
var dest = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : source;
var funcRes = func.apply(this);
return db.write(dest, funcRes);
});
return common.init(db, '__wrapped__', source, opts);
};
/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// Pretty stringify
module.exports = function stringify(obj) {
return JSON.stringify(obj, null, 2);
};
/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* global localStorage */
var stringify = __webpack_require__(3);

@@ -171,3 +216,3 @@ module.exports = {

write: function browserWrite(dest, obj) {
var serialize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : JSON.stringify;
var serialize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringify;

@@ -179,3 +224,3 @@ localStorage.setItem(dest, serialize(obj));

/***/ }),
/* 3 */
/* 5 */
/***/ (function(module, exports, __webpack_require__) {

@@ -196,3 +241,3 @@

/***/ }),
/* 4 */
/* 6 */
/***/ (function(module, exports) {

@@ -207,35 +252,3 @@

/***/ }),
/* 5 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var lodash = __webpack_require__(1);
var common = __webpack_require__(0);
module.exports = function (source) {
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
// Create a fresh copy of lodash
var _ = lodash.runInContext();
var db = _.chain({});
// Expose _ for mixins
db._ = _;
// Add write function to lodash
// Calls save before returning result
_.prototype.write = _.wrap(_.prototype.value, function (func) {
var dest = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : source;
var funcRes = func.apply(this);
return db.write(dest, funcRes);
});
return common.init(db, '__wrapped__', source, opts);
};
/***/ })
/******/ ]);

@@ -1,2 +0,2 @@

/*! lowdb v0.16.0 */
var low=function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var r={};return e.m=t,e.c=r,e.i=function(t){return t},e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=5)}([function(t,e,r){"use strict";var n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},o=r(4),i=r(3),u=r(2),a=function(t,e,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},c=a.storage,f=void 0===c?u:c,s=a.format,l=void 0===s?{}:s;return t.source=r,t.storage=n({},i,t.source&&f),t.read=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:r,n=t.storage.read(e,l.deserialize);return o(n)?n.then(t.plant):t.plant(n)},t.write=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:r,n=(arguments.length<=1?0:arguments.length-1)?arguments.length<=1?void 0:arguments[1]:t.getState(),i=t.storage.write(e,t.getState(),l.serialize);return o(i)?i.then(function(){return n}):n},t.plant=function(r){return t[e]=r,t},t.getState=function(){return t[e]},t.setState=function(e){return t.plant(e),t.write()},t.read()};t.exports={init:a}},function(t,e){t.exports=_},function(t,e,r){"use strict";t.exports={read:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:JSON.parse,r=localStorage.getItem(t);return r?e(r):(localStorage.setItem(t,"{}"),{})},write:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:JSON.stringify;localStorage.setItem(t,r(e))}}},function(t,e,r){"use strict";t.exports={read:function(){return{}},write:function(){return{}}}},function(t,e){function r(t){return!!t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then}t.exports=r},function(t,e,r){"use strict";var n=r(1),o=r(0);t.exports=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.runInContext(),i=r.chain({});return i._=r,r.prototype.write=r.wrap(r.prototype.value,function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,n=e.apply(this);return i.write(r,n)}),o.init(i,"__wrapped__",t,e)}}]);
/*! lowdb v0.16.1 */
var low=function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=2)}([function(t,e,n){"use strict";var r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},o=n(6),i=n(5),u=n(4),a=function(t,e,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},c=a.storage,f=void 0===c?u:c,s=a.format,l=void 0===s?{}:s;return t.source=n,t.storage=r({},i,t.source&&f),t.read=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:n,r=t.storage.read(e,l.deserialize);return o(r)?r.then(t.plant):t.plant(r)},t.write=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:n,r=(arguments.length<=1?0:arguments.length-1)?arguments.length<=1?void 0:arguments[1]:t.getState(),i=t.storage.write(e,t.getState(),l.serialize);return o(i)?i.then(function(){return r}):r},t.plant=function(n){return t[e]=n,t},t.getState=function(){return t[e]},t.setState=function(e){return t.plant(e),t.write()},t.read()};t.exports={init:a}},function(t,e){t.exports=_},function(t,e,n){"use strict";var r=n(1),o=n(0);t.exports=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.runInContext(),i=n.chain({});return i._=n,n.prototype.write=n.wrap(n.prototype.value,function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,r=e.apply(this);return i.write(n,r)}),o.init(i,"__wrapped__",t,e)}},function(t,e,n){"use strict";t.exports=function(t){return JSON.stringify(t,null,2)}},function(t,e,n){"use strict";var r=n(3);t.exports={read:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:JSON.parse,n=localStorage.getItem(t);return n?e(n):(localStorage.setItem(t,"{}"),{})},write:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:r;localStorage.setItem(t,n(e))}}},function(t,e,n){"use strict";t.exports={read:function(){return{}},write:function(){return{}}}},function(t,e){function n(t){return!!t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then}t.exports=n}]);

@@ -65,3 +65,3 @@ # Examples

.value()
res.send(post)

@@ -97,3 +97,3 @@ })

.write()
res.send(post)

@@ -125,26 +125,1 @@ })

In this case, it's recommended to create a custom storage.
## FP
This particular mode lets you use [lodash/fp](https://github.com/lodash/lodash/wiki/FP-Guide), [Ramda](https://github.com/ramda/ramda) or simple JavaScript functions with lowdb. If you're using Lowdb with a bundler like Webpack or Browserify it can help reduce the size of your bundle.js.
```js
import low from 'lowdb/lib/fp'
import concat from 'lodash/fp/concat'
const db = low()
// Get or set posts
const posts = db('posts', [])
// replace posts with a new array resulting from concat
// and persist database
posts.write(
concat({ title: 'lowdb is awesome' })
)
// Find post by id
const post = posts(
find({ id: 1 })
)
```
'use strict';
var flow = require('lodash/fp/flow');
var flow = require('lodash/flow');
var get = require('lodash/get');

@@ -5,0 +5,0 @@ var set = require('lodash/set');

'use strict';
/* global localStorage */
var stringify = require('./_stringify');

@@ -18,3 +19,3 @@ module.exports = {

write: function browserWrite(dest, obj) {
var serialize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : JSON.stringify;
var serialize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringify;

@@ -21,0 +22,0 @@ localStorage.setItem(dest, serialize(obj));

'use strict';
var steno = require('steno');
var stringify = require('./_stringify');

@@ -8,3 +9,3 @@ module.exports = {

write: function fileAsyncWrite(dest, obj) {
var serialize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : JSON.stringify;
var serialize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringify;

@@ -11,0 +12,0 @@ return new Promise(function (resolve, reject) {

'use strict';
var fs = require('graceful-fs');
var stringify = require('./_stringify');

@@ -28,3 +29,3 @@ module.exports = {

write: function fileSyncWrite(dest, obj) {
var serialize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : JSON.stringify;
var serialize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringify;

@@ -31,0 +32,0 @@ var data = serialize(obj);

{
"name": "lowdb",
"version": "0.16.0",
"version": "0.16.1",
"description": "JSON database for Node and the browser powered by lodash API",

@@ -5,0 +5,0 @@ "keywords": [

@@ -19,3 +19,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)

db.set('user.name', 'typicode')
.value()
.write()
```

@@ -36,3 +36,3 @@

You can use any [lodash](https://lodash.com/docs) function like `_.get` and `_.find` with shorthand syntax.
You can use any [lodash](https://lodash.com/docs) function like [`_.get`](https://lodash.com/docs#get) and [`_.find`](https://lodash.com/docs#find) with shorthand syntax.

@@ -54,2 +54,3 @@ ```js

* [In-memory](https://github.com/typicode/lowdb/tree/master/examples#in-memory)
* [lowdb/lib/fp](https://github.com/typicode/lowdb/tree/master/examples/fp.md)
* [JSFiddle live example](https://jsfiddle.net/typicode/4kd7xxbu/)

@@ -73,8 +74,10 @@ * [__Migrating from 0.14 to 0.15? See this guide.__](https://github.com/typicode/lowdb/releases/tag/v0.15.0)

* [felony](https://github.com/henryboldi/felony)
* [googlesamples/md2googleslides](https://github.com/googlesamples/md2googleslides)
* [fb-sleep-stats](https://github.com/sqren/fb-sleep-stats)
* [kadirahq/storybook-database-local](https://github.com/kadirahq/storybook-database-local)
* [json-server](https://github.com/typicode/json-server)
* ... and [other awesome projects](https://www.npmjs.com/browse/depended/lowdb)
* [typicode/json-server](https://github.com/typicode/json-server) - REST API with zero coding
* [henryboldi/felony](https://github.com/henryboldi/felony) - Next Level PGP
* [googlesamples/md2googleslides](https://github.com/googlesamples/md2googleslides) - Generate Google Slides from markdown
* [sqren/fb-sleep-stats](https://github.com/sqren/fb-sleep-stats) - Sleeping habits tracker
* [panzhangwang/getAwesomeness](https://github.com/panzhangwang/getAwesomeness) - All amazing awesomeness from Github
* [redux-promise-middleware](https://github.com/pburtchaell/redux-promise-middleware) - Redux middleware
* [sasha-alias/sqltabs](https://github.com/sasha-alias/sqltabs) - Rich SQL client
* ... and [__600+ repositories__](https://libraries.io/npm/lowdb/dependent-repositories)

@@ -81,0 +84,0 @@ ## Install

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc