first commit

This commit is contained in:
Myk
2025-07-31 23:47:20 +03:00
commit 2186b278a0
5149 changed files with 537218 additions and 0 deletions

12
node_modules/lowdb/.babelrc generated vendored Normal file
View File

@@ -0,0 +1,12 @@
{
"presets": [
[
"env",
{
"targets": {
"node": "4"
}
}
]
]
}

14
node_modules/lowdb/.eslintrc.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
module.exports = {
extends: ['standard', 'prettier'],
plugins: ['prettier'],
rules: {
'prettier/prettier': [
'error',
{
singleQuote: true,
semi: false,
},
]
},
env: { jest: true }
}

3
node_modules/lowdb/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,3 @@
.travis.yml
src
__tests__

20
node_modules/lowdb/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2014 typicode
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

383
node_modules/lowdb/README.md generated vendored Normal file
View File

@@ -0,0 +1,383 @@
# Lowdb
[![](http://img.shields.io/npm/dm/lowdb.svg?style=flat)](https://www.npmjs.org/package/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) [![Donate](https://img.shields.io/badge/patreon-donate-ff69b4.svg)](https://www.patreon.com/typicode)
> Small JSON database for Node, Electron and the browser. Powered by Lodash. :zap:
```js
db.get('posts')
.push({ id: 1, title: 'lowdb is awesome'})
.write()
```
## Usage
```sh
npm install lowdb
```
```js
const low = require('lowdb')
const FileSync = require('lowdb/adapters/FileSync')
const adapter = new FileSync('db.json')
const db = low(adapter)
// Set some defaults
db.defaults({ posts: [], user: {} })
.write()
// Add a post
db.get('posts')
.push({ id: 1, title: 'lowdb is awesome'})
.write()
// Set a user using Lodash shorthand syntax
db.set('user.name', 'typicode')
.write()
```
Data is saved to `db.json`
```json
{
"posts": [
{ "id": 1, "title": "lowdb is awesome"}
],
"user": {
"name": "typicode"
}
}
```
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.
```js
// Use .value() instead of .write() if you're only reading from db
db.get('posts')
.find({ id: 1 })
.value()
```
Lowdb is perfect for CLIs, small servers, Electron apps and npm packages in general.
It supports __Node__, the __browser__ and uses __lodash API__, so it's very simple to learn. Actually, if you know Lodash, you already know how to use lowdb :wink:
* [Usage examples](https://github.com/typicode/lowdb/tree/master/examples)
* [CLI](https://github.com/typicode/lowdb/tree/master/examples#cli)
* [Browser](https://github.com/typicode/lowdb/tree/master/examples#browser)
* [Server](https://github.com/typicode/lowdb/tree/master/examples#server)
* [In-memory](https://github.com/typicode/lowdb/tree/master/examples#in-memory)
* [JSFiddle live example](https://jsfiddle.net/typicode/4kd7xxbu/)
__Important__ lowdb doesn't support Cluster and may have issues with very large JSON files (~200MB).
## Install
```sh
npm install lowdb
```
Alternatively, if you're using [yarn](https://yarnpkg.com/)
```sh
yarn add lowdb
```
A UMD build is also available on [unpkg](https://unpkg.com/) for testing and quick prototyping:
```html
<script src="https://unpkg.com/lodash@4/lodash.min.js"></script>
<script src="https://unpkg.com/lowdb@0.17/dist/low.min.js"></script>
<script src="https://unpkg.com/lowdb@0.17/dist/LocalStorage.min.js"></script>
<script>
var adapter = new LocalStorage('db')
var db = low(adapter)
</script>
```
## API
__low(adapter)__
Returns a lodash [chain](https://lodash.com/docs/4.17.4#chain) with additional properties and functions described below.
__db.[...].write()__
__db.[...].value()__
`write()` is syntactic sugar for calling `value()` and `db.write()` in one line.
On the other hand, `value()` is just [\_.protoype.value()](https://lodash.com/docs/4.17.4#prototype-value) and should be used to execute a chain that doesn't change database state.
```js
db.set('user.name', 'typicode')
.write()
// is equivalent to
db.set('user.name', 'typicode')
.value()
db.write()
```
__db.___
Database lodash instance. Use it to add your own utility functions or third-party mixins like [underscore-contrib](https://github.com/documentcloud/underscore-contrib) or [lodash-id](https://github.com/typicode/lodash-id).
```js
db._.mixin({
second: function(array) {
return array[1]
}
})
db.get('posts')
.second()
.value()
```
__db.getState()__
Returns database state.
```js
db.getState() // { posts: [ ... ] }
```
__db.setState(newState)__
Replaces database state.
```js
const newState = {}
db.setState(newState)
```
__db.write()__
Persists database using `adapter.write` (depending on the adapter, may return a promise).
```js
// With lowdb/adapters/FileSync
db.write()
console.log('State has been saved')
// With lowdb/adapters/FileAsync
db.write()
.then(() => console.log('State has been saved'))
```
__db.read()__
Reads source using `storage.read` option (depending on the adapter, may return a promise).
```js
// With lowdb/FileSync
db.read()
console.log('State has been updated')
// With lowdb/FileAsync
db.write()
.then(() => console.log('State has been updated'))
```
## Adapters API
Please note this only applies to adapters bundled with Lowdb. Third-party adapters may have different options.
For convenience, `FileSync`, `FileAsync` and `LocalBrowser` accept the following options:
* __defaultValue__ if file doesn't exist, this value will be used to set the initial state (default: `{}`)
* __serialize/deserialize__ functions used before writing and after reading (default: `JSON.stringify` and `JSON.parse`)
```js
const adapter = new FileSync('array.yaml', {
defaultValue: [],
serialize: (array) => toYamlString(array),
deserialize: (string) => fromYamlString(string)
})
```
## Guide
### How to query
With lowdb, you get access to the entire [lodash API](http://lodash.com/), so there are many ways to query and manipulate data. Here are a few examples to get you started.
Please note that data is returned by reference, this means that modifications to returned objects may change the database. To avoid such behaviour, you need to use `.cloneDeep()`.
Also, the execution of methods is lazy, that is, execution is deferred until `.value()` or `.write()` is called.
#### Examples
Check if posts exists.
```js
db.has('posts')
.value()
```
Set posts.
```js
db.set('posts', [])
.write()
```
Sort the top five posts.
```js
db.get('posts')
.filter({published: true})
.sortBy('views')
.take(5)
.value()
```
Get post titles.
```js
db.get('posts')
.map('title')
.value()
```
Get the number of posts.
```js
db.get('posts')
.size()
.value()
```
Get the title of first post using a path.
```js
db.get('posts[0].title')
.value()
```
Update a post.
```js
db.get('posts')
.find({ title: 'low!' })
.assign({ title: 'hi!'})
.write()
```
Remove posts.
```js
db.get('posts')
.remove({ title: 'low!' })
.write()
```
Remove a property.
```js
db.unset('user.name')
.write()
```
Make a deep clone of posts.
```js
db.get('posts')
.cloneDeep()
.value()
```
### How to use id based resources
Being able to get data using an id can be quite useful, particularly in servers. To add id-based resources support to lowdb, you have 2 options.
[shortid](https://github.com/dylang/shortid) is more minimalist and returns a unique id that you can use when creating resources.
```js
const shortid = require('shortid')
const postId = db
.get('posts')
.push({ id: shortid.generate(), title: 'low!' })
.write()
.id
const post = db
.get('posts')
.find({ id: postId })
.value()
```
[lodash-id](https://github.com/typicode/lodash-id) provides a set of helpers for creating and manipulating id-based resources.
```js
const lodashId = require('lodash-id')
const db = low('db.json')
db._.mixin(lodashId)
const post = db
.get('posts')
.insert({ title: 'low!' })
.write()
const post = db
.get('posts')
.getById(post.id)
.value()
```
### How to create custom adapters
`low()` accepts custom Adapter, so you can virtually save your data to any storage using any format.
```js
class MyStorage {
constructor() {
// ...
}
read() {
// Should return data (object or array) or a Promise
}
write(data) {
// Should return nothing or a Promise
}
}
const adapter = new MyStorage(args)
const db = low()
```
See [src/adapters](src/adapters) for examples.
### How to encrypt data
`FileSync`, `FileAsync` and `LocalStorage` accept custom `serialize` and `deserialize` functions. You can use them to add encryption logic.
```js
const adapter = new FileSync('db.json', {
serialize: (data) => encrypt(JSON.stringify(data))
deserialize: (data) => JSON.parse(decrypt(data))
})
```
## Changelog
See changes for each version in the [release notes](https://github.com/typicode/lowdb/releases).
## Limits
Lowdb is a convenient method for storing data without setting up a database server. It is fast enough and safe to be used as an embedded database.
However, if you seek high performance and scalability more than simplicity, you should probably stick to traditional databases like MongoDB.
## License
MIT - [Typicode :cactus:](https://github.com/typicode)

24
node_modules/lowdb/adapters/Base.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var stringify = require('./_stringify');
var Base = function Base(source) {
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
_ref$defaultValue = _ref.defaultValue,
defaultValue = _ref$defaultValue === undefined ? {} : _ref$defaultValue,
_ref$serialize = _ref.serialize,
serialize = _ref$serialize === undefined ? stringify : _ref$serialize,
_ref$deserialize = _ref.deserialize,
deserialize = _ref$deserialize === undefined ? JSON.parse : _ref$deserialize;
_classCallCheck(this, Base);
this.source = source;
this.defaultValue = defaultValue;
this.serialize = serialize;
this.deserialize = deserialize;
};
module.exports = Base;

65
node_modules/lowdb/adapters/FileAsync.js generated vendored Normal file
View File

@@ -0,0 +1,65 @@
'use strict';
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
// Not using async/await on purpose to avoid adding regenerator-runtime
// to lowdb dependencies
var fs = require('graceful-fs');
var pify = require('pify');
var steno = require('steno');
var Base = require('./Base');
var readFile = pify(fs.readFile);
var writeFile = pify(steno.writeFile);
var FileAsync = function (_Base) {
_inherits(FileAsync, _Base);
function FileAsync() {
_classCallCheck(this, FileAsync);
return _possibleConstructorReturn(this, (FileAsync.__proto__ || Object.getPrototypeOf(FileAsync)).apply(this, arguments));
}
_createClass(FileAsync, [{
key: 'read',
value: function read() {
var _this2 = this;
// fs.exists is deprecated but not fs.existsSync
if (fs.existsSync(this.source)) {
// Read database
return readFile(this.source, 'utf-8').then(function (data) {
// Handle blank file
var trimmed = data.trim();
return trimmed ? _this2.deserialize(trimmed) : _this2.defaultValue;
}).catch(function (e) {
if (e instanceof SyntaxError) {
e.message = `Malformed JSON in file: ${_this2.source}\n${e.message}`;
}
throw e;
});
} else {
// Initialize
return writeFile(this.source, this.serialize(this.defaultValue)).then(function () {
return _this2.defaultValue;
});
}
}
}, {
key: 'write',
value: function write(data) {
return writeFile(this.source, this.serialize(data));
}
}]);
return FileAsync;
}(Base);
module.exports = FileAsync;

60
node_modules/lowdb/adapters/FileSync.js generated vendored Normal file
View File

@@ -0,0 +1,60 @@
'use strict';
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var fs = require('graceful-fs');
var Base = require('./Base');
var readFile = fs.readFileSync;
var writeFile = fs.writeFileSync;
// Same code as in FileAsync, minus `await`
var FileSync = function (_Base) {
_inherits(FileSync, _Base);
function FileSync() {
_classCallCheck(this, FileSync);
return _possibleConstructorReturn(this, (FileSync.__proto__ || Object.getPrototypeOf(FileSync)).apply(this, arguments));
}
_createClass(FileSync, [{
key: 'read',
value: function read() {
// fs.exists is deprecated but not fs.existsSync
if (fs.existsSync(this.source)) {
// Read database
try {
var data = readFile(this.source, 'utf-8').trim();
// Handle blank file
return data ? this.deserialize(data) : this.defaultValue;
} catch (e) {
if (e instanceof SyntaxError) {
e.message = `Malformed JSON in file: ${this.source}\n${e.message}`;
}
throw e;
}
} else {
// Initialize
writeFile(this.source, this.serialize(this.defaultValue));
return this.defaultValue;
}
}
}, {
key: 'write',
value: function write(data) {
return writeFile(this.source, this.serialize(data));
}
}]);
return FileSync;
}(Base);
module.exports = FileSync;

44
node_modules/lowdb/adapters/LocalStorage.js generated vendored Normal file
View File

@@ -0,0 +1,44 @@
'use strict';
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/* global localStorage */
var Base = require('./Base');
var LocalStorage = function (_Base) {
_inherits(LocalStorage, _Base);
function LocalStorage() {
_classCallCheck(this, LocalStorage);
return _possibleConstructorReturn(this, (LocalStorage.__proto__ || Object.getPrototypeOf(LocalStorage)).apply(this, arguments));
}
_createClass(LocalStorage, [{
key: 'read',
value: function read() {
var data = localStorage.getItem(this.source);
if (data) {
return this.deserialize(data);
} else {
localStorage.setItem(this.source, this.serialize(this.defaultValue));
return this.defaultValue;
}
}
}, {
key: 'write',
value: function write(data) {
localStorage.setItem(this.source, this.serialize(data));
}
}]);
return LocalStorage;
}(Base);
module.exports = LocalStorage;

33
node_modules/lowdb/adapters/Memory.js generated vendored Normal file
View File

@@ -0,0 +1,33 @@
'use strict';
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Base = require('./Base');
module.exports = function (_Base) {
_inherits(Memory, _Base);
function Memory() {
_classCallCheck(this, Memory);
return _possibleConstructorReturn(this, (Memory.__proto__ || Object.getPrototypeOf(Memory)).apply(this, arguments));
}
_createClass(Memory, [{
key: 'read',
value: function read() {
return this.defaultValue;
}
}, {
key: 'write',
value: function write() {}
}]);
return Memory;
}(Base);

6
node_modules/lowdb/adapters/_stringify.js generated vendored Normal file
View File

@@ -0,0 +1,6 @@
"use strict";
// Pretty stringify
module.exports = function stringify(obj) {
return JSON.stringify(obj, null, 2);
};

164
node_modules/lowdb/dist/LocalStorage.js generated vendored Normal file
View File

@@ -0,0 +1,164 @@
/*! lowdb v1.0.0 */
var LocalStorage =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ 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)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // 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;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // 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 = 3);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */,
/* 1 */,
/* 2 */,
/* 3 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/* global localStorage */
var Base = __webpack_require__(4);
var LocalStorage = function (_Base) {
_inherits(LocalStorage, _Base);
function LocalStorage() {
_classCallCheck(this, LocalStorage);
return _possibleConstructorReturn(this, (LocalStorage.__proto__ || Object.getPrototypeOf(LocalStorage)).apply(this, arguments));
}
_createClass(LocalStorage, [{
key: 'read',
value: function read() {
var data = localStorage.getItem(this.source);
if (data) {
return this.deserialize(data);
} else {
localStorage.setItem(this.source, this.serialize(this.defaultValue));
return this.defaultValue;
}
}
}, {
key: 'write',
value: function write(data) {
localStorage.setItem(this.source, this.serialize(data));
}
}]);
return LocalStorage;
}(Base);
module.exports = LocalStorage;
/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var stringify = __webpack_require__(5);
var Base = function Base(source) {
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
_ref$defaultValue = _ref.defaultValue,
defaultValue = _ref$defaultValue === undefined ? {} : _ref$defaultValue,
_ref$serialize = _ref.serialize,
serialize = _ref$serialize === undefined ? stringify : _ref$serialize,
_ref$deserialize = _ref.deserialize,
deserialize = _ref$deserialize === undefined ? JSON.parse : _ref$deserialize;
_classCallCheck(this, Base);
this.source = source;
this.defaultValue = defaultValue;
this.serialize = serialize;
this.deserialize = deserialize;
};
module.exports = Base;
/***/ }),
/* 5 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// Pretty stringify
module.exports = function stringify(obj) {
return JSON.stringify(obj, null, 2);
};
/***/ })
/******/ ]);

2
node_modules/lowdb/dist/LocalStorage.min.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
/*! lowdb v1.0.0 */
var LocalStorage=function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=3)}([,,,function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var u=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),a=r(4),s=function(e){function t(){return n(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return i(t,e),u(t,[{key:"read",value:function(){var e=localStorage.getItem(this.source);return e?this.deserialize(e):(localStorage.setItem(this.source,this.serialize(this.defaultValue)),this.defaultValue)}},{key:"write",value:function(e){localStorage.setItem(this.source,this.serialize(e))}}]),t}(a);e.exports=s},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=r(5),i=function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=r.defaultValue,u=void 0===i?{}:i,a=r.serialize,s=void 0===a?o:a,c=r.deserialize,l=void 0===c?JSON.parse:c;n(this,e),this.source=t,this.defaultValue=u,this.serialize=s,this.deserialize=l};e.exports=i},function(e,t,r){"use strict";e.exports=function(e){return JSON.stringify(e,null,2)}}]);

144
node_modules/lowdb/dist/low.js generated vendored Normal file
View File

@@ -0,0 +1,144 @@
/*! lowdb v1.0.0 */
var low =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ 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)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // 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;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // 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 = 0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var lodash = __webpack_require__(1);
var isPromise = __webpack_require__(2);
module.exports = function (adapter) {
if (typeof adapter !== 'object') {
throw new Error('An adapter must be provided, see https://github.com/typicode/lowdb/#usage');
}
// Create a fresh copy of lodash
var _ = lodash.runInContext();
var db = _.chain({});
// Add write function to lodash
// Calls save before returning result
_.prototype.write = _.wrap(_.prototype.value, function (func) {
var funcRes = func.apply(this);
return db.write(funcRes);
});
function plant(state) {
db.__wrapped__ = state;
return db;
}
// Lowdb API
// Expose _ for mixins
db._ = _;
db.read = function () {
var r = adapter.read();
return isPromise(r) ? r.then(plant) : plant(r);
};
db.write = function (returnValue) {
var w = adapter.write(db.getState());
return isPromise(w) ? w.then(function () {
return returnValue;
}) : returnValue;
};
db.getState = function () {
return db.__wrapped__;
};
db.setState = function (state) {
return plant(state);
};
return db.read();
};
/***/ }),
/* 1 */
/***/ (function(module, exports) {
module.exports = _;
/***/ }),
/* 2 */
/***/ (function(module, exports) {
module.exports = isPromise;
function isPromise(obj) {
return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
}
/***/ })
/******/ ]);

2
node_modules/lowdb/dist/low.min.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
/*! lowdb v1.0.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.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=0)}([function(t,e,r){"use strict";var n=r(1),o=r(2);t.exports=function(t){function e(t){return u.__wrapped__=t,u}if("object"!=typeof t)throw new Error("An adapter must be provided, see https://github.com/typicode/lowdb/#usage");var r=n.runInContext(),u=r.chain({});return r.prototype.write=r.wrap(r.prototype.value,function(t){var e=t.apply(this);return u.write(e)}),u._=r,u.read=function(){var r=t.read();return o(r)?r.then(e):e(r)},u.write=function(e){var r=t.write(u.getState());return o(r)?r.then(function(){return e}):e},u.getState=function(){return u.__wrapped__},u.setState=function(t){return e(t)},u.read()}},function(t,e){t.exports=_},function(t,e){function r(t){return!!t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then}t.exports=r}]);

113
node_modules/lowdb/examples/README.md generated vendored Normal file
View File

@@ -0,0 +1,113 @@
# Examples
## CLI
```js
const low = require('lowdb')
const FileSync = require('lowdb/adapters/FileSync')
const adapter = new FileSync('db.json')
const db = low(adapter)
db.defaults({ posts: [] })
.write()
const result = db.get('posts')
.push({ name: process.argv[2] })
.write()
console.log(result)
```
```sh
$ node cli.js hello
# [ { title: 'hello' } ]
```
## Browser
```js
import low from 'lowdb'
import LocalStorage from 'lowdb/adapters/LocalStorage'
const adapter = new LocalStorage('db')
const db = low(adapter)
db.defaults({ posts: [] })
.write()
// Data is automatically saved to localStorage
db.get('posts')
.push({ title: 'lowdb' })
.write()
```
## Server
Please __note__ that if you're developing a local server and don't expect to get concurrent requests, it's often easier to use `file-sync` storage, which is the default.
But if you need to avoid blocking requests, you can do so by using `file-async` storage.
```js
const express = require('express')
const low = require('lowdb')
const FileAsync = require('lowdb/adapters/FileAsync')
// Create server
const app = express()
// Routes
// GET /posts/:id
app.get('/posts/:id', (req, res) => {
const post = db.get('posts')
.find({ id: req.params.id })
.value()
res.send(post)
})
// POST /posts
app.post('/posts', (req, res) => {
db.get('posts')
.push(req.body)
.last()
.assign({ id: Date.now() })
.write()
.then(post => res.send(post))
})
// Create database instance and start server
const adapter = new FileAsync('db.json')
low(adapter)
.then(db => {
db.defaults({ posts: [] })
.write()
})
.then(() => {
app.listen(3000, () => console.log('listening on port 3000')
})
```
## In-memory
With this adapter, calling `write` will do nothing. One use case for this adapter can be for tests.
```js
const fs = require('fs')
const low = require('low')
const FileSync = require('low/adapters/FileSync')
const Memory = require('low/adapters/Memory')
const db = low(
process.env.NODE_ENV === 'test'
? new Memory()
: new FileSync('db.json')
)
db.defaults({ posts: [] })
.write()
db.get('posts')
.push({ title: 'lowdb' })
.write()
```

58
node_modules/lowdb/examples/fp.md generated vendored Normal file
View File

@@ -0,0 +1,58 @@
# lowdb/lib/fp
__:warning: Experimental__
`lowdb/lib/fp` 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.
It can help reducing the size of your `bundle.js`
## Usage
```js
import low from 'lowdb/lib/fp'
import { concat, find, sortBy, take, random } from 'lodash/fp'
const db = low()
// Get posts
const defaultValue = []
const posts = db('posts', defaultValue)
// replace posts with a new array resulting from concat
// and persist database
posts.write(
concat({ title: 'lowdb is awesome', views: random(0, 5) })
)
// Find post by id
const post = posts(
find({ id: 1 })
)
// Find top 5 fives posts
const popular = posts([
sortBy('views'),
take(5)
])
```
## API
`lowdb/lib/fp` shares the same API as `lowdb` except for the two following methods.
__db(path, [defaultValue])([funcs])__
Returns a new array or object without modifying the database state.
```js
db('posts')(filter({ published: true }))
```
__db(path, [defaultValue]).write([funcs])__
Add `.write` when you want the result to be written back to `path`
```js
db('posts').write(concat(newPost))
db('user.name').write(set('typicode'))
```

41
node_modules/lowdb/lib/common.js generated vendored Normal file
View File

@@ -0,0 +1,41 @@
'use strict';
var isPromise = require('is-promise');
var init = function init(db, key, adapter) {
db.read = function () {
var r = adapter.read();
return isPromise(r) ? r.then(db.plant) : db.plant(r);
};
db.write = function () {
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : db.getState();
var w = adapter.write(db.getState());
return isPromise(w) ? w.then(function () {
return value;
}) : value;
};
db.plant = function (state) {
db[key] = state;
return db;
};
db.getState = function () {
return db[key];
};
db.setState = function (state) {
db.plant(state);
return db;
};
return db.read();
};
module.exports = {
init
};

25
node_modules/lowdb/lib/fp.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
'use strict';
var flow = require('lodash/flow');
var get = require('lodash/get');
var set = require('lodash/set');
var common = require('./common');
module.exports = function (adapter) {
function db(path, defaultValue) {
function getValue(funcs) {
var result = get(db.getState(), path, defaultValue);
return flow(funcs)(result);
}
getValue.write = function () {
var result = getValue.apply(undefined, arguments);
set(db.getState(), path, result);
return db.write();
};
return getValue;
}
return common.init(db, '__state__', adapter);
};

52
node_modules/lowdb/lib/main.js generated vendored Normal file
View File

@@ -0,0 +1,52 @@
'use strict';
var lodash = require('lodash');
var isPromise = require('is-promise');
module.exports = function (adapter) {
if (typeof adapter !== 'object') {
throw new Error('An adapter must be provided, see https://github.com/typicode/lowdb/#usage');
}
// Create a fresh copy of lodash
var _ = lodash.runInContext();
var db = _.chain({});
// Add write function to lodash
// Calls save before returning result
_.prototype.write = _.wrap(_.prototype.value, function (func) {
var funcRes = func.apply(this);
return db.write(funcRes);
});
function plant(state) {
db.__wrapped__ = state;
return db;
}
// Lowdb API
// Expose _ for mixins
db._ = _;
db.read = function () {
var r = adapter.read();
return isPromise(r) ? r.then(plant) : plant(r);
};
db.write = function (returnValue) {
var w = adapter.write(db.getState());
return isPromise(w) ? w.then(function () {
return returnValue;
}) : returnValue;
};
db.getState = function () {
return db.__wrapped__;
};
db.setState = function (state) {
return plant(state);
};
return db.read();
};

7
node_modules/lowdb/lib/nano.js generated vendored Normal file
View File

@@ -0,0 +1,7 @@
'use strict';
var common = require('./common');
module.exports = function (adapter) {
return common.init({}, '__state__', adapter);
};

80
node_modules/lowdb/package.json generated vendored Normal file
View File

@@ -0,0 +1,80 @@
{
"name": "lowdb",
"version": "1.0.0",
"description": "Small JSON database for Node, Electron and the browser. Powered by Lodash.",
"keywords": [
"flat",
"file",
"local",
"database",
"storage",
"JSON",
"lodash",
"localStorage",
"electron",
"embed",
"embeddable"
],
"main": "./lib/main.js",
"scripts": {
"test": "jest && npm run lint",
"lint": "eslint . --ignore-path .gitignore",
"fix": "npm run lint -- --fix",
"prepublishOnly": "npm run build && pkg-ok",
"build": "npm run build:lib && npm run build:dist",
"build:lib": "rimraf lib && babel src --out-dir lib && npm run mvAdapters",
"build:dist": "rimraf dist && webpack && webpack -p",
"mvAdapters": "rimraf adapters && mv lib/adapters .",
"precommit": "npm test"
},
"repository": {
"type": "git",
"url": "git://github.com/typicode/lowdb.git"
},
"author": "Typicode <typicode@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/typicode/lowdb/issues"
},
"homepage": "https://github.com/typicode/lowdb",
"dependencies": {
"graceful-fs": "^4.1.3",
"is-promise": "^2.1.0",
"lodash": "4",
"pify": "^3.0.0",
"steno": "^0.4.1"
},
"devDependencies": {
"babel-cli": "^6.2.0",
"babel-eslint": "^7.0.0",
"babel-jest": "^20.0.3",
"babel-loader": "^7.1.1",
"babel-polyfill": "^6.9.1",
"babel-preset-env": "^1.6.0",
"babel-register": "^6.9.0",
"delay": "^2.0.0",
"eslint": "^4.5.0",
"eslint-config-prettier": "^2.3.0",
"eslint-config-standard": "^10.2.1",
"eslint-plugin-import": "^2.6.1",
"eslint-plugin-node": "^5.1.0",
"eslint-plugin-prettier": "^2.1.2",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-standard": "^3.0.1",
"husky": "^0.14.3",
"jest": "^20.0.4",
"lodash-id": "^0.14.0",
"mv": "^2.1.1",
"pkg-ok": "^1.0.1",
"prettier": "^1.5.2",
"ramda": "^0.24.1",
"regenerator-runtime": "^0.11.0",
"rimraf": "^2.5.4",
"sinon": "^3.2.1",
"tempfile": "^2.0.0",
"webpack": "^3.3.0"
},
"engines": {
"node": ">=4"
}
}

25
node_modules/lowdb/webpack.config.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
var path = require('path')
var webpack = require('webpack')
var pkg = require('./package.json')
var banner = 'lowdb v' + pkg.version
module.exports = {
entry: {
low: './src/main.js',
LocalStorage: './src/adapters/LocalStorage'
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: process.argv.indexOf('-p') !== -1 ? '[name].min.js' : '[name].js',
library: '[name]'
},
externals: {
lodash: '_'
},
plugins: [new webpack.BannerPlugin(banner)],
module: {
loaders: [
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' }
]
}
}