Skip to content

Commit 573cc7d

Browse files
committed
Merge pull request #92 from typicode/next
Update build
2 parents e95c164 + 6142dd2 commit 573cc7d

File tree

6 files changed

+48
-8
lines changed

6 files changed

+48
-8
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ tmp
44
.DS_Store
55
.idea
66
/*.js
7+
dist
8+
!webpack.config.js

README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,34 @@ db('posts').find({ title: 'lowdb is awesome' })
3030

3131
__[Click here to try lowdb in the browser.](http://typicode.github.io/lowdb/)__
3232

33-
## Support
33+
## ES2015
3434

35-
Examples use ES2015 syntax, it's supported by Node 5+. Node 0.12 is supported too but you need to use the older syntax.
35+
Examples use ES2015 syntax for convenience, but you can use ES5 syntax too. For example:
3636

3737
```js
38-
// For Node 0.12
3938
var db = low('db.json', { storage: storage })
4039
```
4140

4241
Please note also that lowdb can only be run in one instance of Node, it doesn't support Cluster.
4342

44-
## Install
43+
## Installation
44+
45+
Using npm:
4546

4647
```bash
4748
npm install lowdb --save
4849
```
4950

51+
A standalone UMD build is also available on [npmcdn](https://npmcdn.com/):
52+
53+
```html
54+
<script src="http://npmcdn.com/lowdb@^0.12.4/dist/lowdb.min.js"></script>
55+
<script>
56+
var db = low() // in-memory
57+
var db = low('db', { storage: low.localStorage }) // localStorage
58+
</script>
59+
```
60+
5061
## Features
5162

5263
* Very small (~100 lines for core)

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
"test": "babel-node test/all | tap-spec",
2222
"prepublish": "npm run build",
2323
"precommit": "npm test",
24-
"build": "babel src --out-dir ."
24+
"build": "npm run babel && npm run umd && npm run min",
25+
"babel": "babel src --out-dir . --ignore dist.js",
26+
"umd": "webpack src/dist.js dist/lowdb.js --output-library low",
27+
"min": "webpack -p src/dist.js dist/lowdb.min.js --output-library low"
2528
},
2629
"repository": {
2730
"type": "git",
@@ -43,6 +46,7 @@
4346
"devDependencies": {
4447
"babel-cli": "^6.2.0",
4548
"babel-eslint": "^4.1.6",
49+
"babel-loader": "^6.2.2",
4650
"babel-preset-es2015": "^6.1.18",
4751
"babel-preset-stage-3": "^6.3.13",
4852
"husky": "^0.11.0",
@@ -51,7 +55,8 @@
5155
"tap-spec": "^4.1.1",
5256
"tape": "^4.2.2",
5357
"tempfile": "^1.1.1",
54-
"underscore-db": "^0.9.0"
58+
"underscore-db": "^0.9.0",
59+
"webpack": "^1.12.13"
5560
},
5661
"engines": {
5762
"node": ">= 0.12"

src/dist.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Entry point for standalone build
2+
const index = require('./')
3+
index.localStorage = require('./browser')
4+
module.exports = index

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ function lowChain (_, array, save) {
1515
const chain = _.chain(array)
1616

1717
_.functionsIn(chain)
18-
.forEach((method) => {
19-
chain[method] = _.flow(chain[method], (arg) => {
18+
.forEach(method => {
19+
chain[method] = _.flow(chain[method], arg => {
2020
let v
2121
if (arg) {
2222
v = _.isFunction(arg.value) ? arg.value() : arg

webpack.config.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var webpack = require('webpack')
2+
var pkg = require('./package.json')
3+
var banner = 'lowdb v' + pkg.version
4+
5+
module.exports = {
6+
output: {
7+
path: './dist',
8+
libraryTarget: 'umd'
9+
},
10+
plugins: [
11+
new webpack.BannerPlugin(banner)
12+
],
13+
module: {
14+
loaders: [
15+
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel' }
16+
]
17+
}
18+
}

0 commit comments

Comments
 (0)